Statistics - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Statistics and Data Analysis : Statistics Package : Data Manipulation : Statistics/Detrend

Statistics

  

Detrend

  

remove any trend from a set of data

 

Calling Sequence

Parameters

Options

Description

Notes

Examples

Compatibility

Calling Sequence

Detrend( XY, options )

Detrend( Y, options )

Detrend( X, Y, options )

Parameters

XY

-

data set, DataFrame; Matrix or DataFrame of values with 2 columns

X, Y

-

data set, DataSeries; numeric list of values

options

-

(optional) equation(s) of the form option=value where option can be mode

Options

• 

mode    : one of the names mean or linear; specifies the method used to detrend the data. The mode mean removes the mean value of the data from the data. The mode linear removes the line of best-fit from the data. The default is linear.

Description

The Detrend command is used to remove any trend from a set of data. The Detrend command returns a Vector containing the detrended values.

• 

If the argument XY is a 2-column rtable or DataFrame, the first column is used as the independent variables and the Detrend command is applied to the dependent values in the second column. Note that values in the first column do not need to be equally spaced.

• 

If the argument Y is a 1-column rtable or DataSeries and there is no specified value for X, the Detrend command uses the index positions for each value in Y as the independent values and the Detrend command is applied to the dependent values in Y.

• 

If the argument X and argument Y are 1-column rtables or DataSeries, the values in X are treated as the independent variables and the Detrend command is applied to the dependent values in Y.

Notes

To print the model used by the Detrend command, set infolevel[Statistics] to 1.

Examples

withStatistics:

Specify some data:

dataMatrix0,1.8,1,0.7,2.5,2.8,4,4.2,6.2,3

01.810.72.52.844.26.23

(1)

Fit a linear model to the data:

lmLinearFita+bx,data,x

lm1.49598376946009+0.366429281218947x

(2)

It can be observed that from the plot of the data and the linear model that there is some upward trend.

plots:-displayScatterPlotdata,symbol=solidcircle,symbolsize=15,color=Black,legend=Original Data,plotlm,color=Black,legend=Trend,linestyle=dash,view=mindata..,10.1..maxdata..,1+0.1,mindata..,20.1..maxdata..,2+0.1

The Detrend command removes any trend from the data.

detrend_dataDetrenddata

0.304016230539913671.1624130506790330.387943027492546831.23829910566412730.7678453130175553

(3)

This can be observed in the following plot:

plots:-displayScatterPlotdata,color=Black,legend=Original Data,symbol=solidcircle,symbolsize=15,plotlm,color=Black,legend=Trend,linestyle=dash,ScatterPlotdata..,1,detrend_data,color=Red,legend=Detrended Data,symbol=diamond,symbolsize=15,plotMeandetrend_data,color=Red,legend=Mean of Detrended Data,linestyle=dot,view=mindata..,10.1..maxdata..,1+0.1,default

Generate a random signal with an added trend.

withSignalProcessing:

signal_dataGenerateGaussian100,0.5,0.3+seqi,i=0.01..1,0.01

0.55953718734127790.453894302538642050.88487538518469990.471490368157071850.83890290781871950.478772298848602061.15790208261943040.96485319071590850.67841796407208180.49446642128892660.26843503400556830.23314418140457770.79618790857608131.49233354186976760.417848440033405040.415868875254272630.79945124858342560.91899029917958150.74778274261780850.55959474616785640.84565156489907410.433855978436666070.214102590554551410.6811319647174530.64115827235876010.92885351239129290.64749025066170860.50431082741263520.98275304779782950.67658216350874080.95245078289853620.59879180664010410.51351028040945691.11371690606628730.66378871968618810.82873726767630430.98280613891037570.80331913545094550.81250662838083041.0202366769927731.04755756992399380.67327703246102021.32519751109485680.6209651685680380.67040968940085631.58249165722786820.52258584661237511.1868951141839280.92821159328309590.69481684133560080.369681819764137170.6084289084328651.26611045327983220.78203335747953131.02481939140651420.90608608326330680.88057574161087830.91375520892980380.82851590603565761.33947029504704181.25083296273547441.18322662435023140.91865258447248220.83785166011963351.16153531351518981.20139144279806361.37658612835765611.3356843711538291.02264172744596871.30642700353356121.1365472691171351.33511004462902961.37805770474645861.88165055122890480.86721802514375051.01045519229733281.3939842908731471.40432629841890271.23423478459809831.4344973546826561.45466271931219241.13227192294404061.4749373770435061.07717680261414571.4578206944494641.01266292787836431.16876813493636681.171751657331692.0901251047272791.4662014786904681.23589386222095591.83756654983002841.15198292742838751.19637582449269631.29001419359774541.05105959177927551.71897488948592621.8650549546566321.5526488196180471.2634576295297608

(4)

Plot the signal and the trend line.

plots:-displaySignalPlotsignal_data,legend=Data,plotLinearFita+bx,seq1..100,signal_data,x,x=1..100,color=Black,legend=Trend,linestyle=dash

Plot the signal, the detrended signal, the trend line and the mean of the detrended data.

plots:-displaySignalPlotsignal_data,legend=Original Data,plotLinearFita+bx,seq1..100,signal_data,x,x=1..100,color=Black,legend=Trend,linestyle=dash,SignalPlotsignal_data,detrend,color=Red,legend=Detrended Data,plotMeanDetrendsignal_data,x=1..100,color=Red,legend=Mean of Detrended Data,linestyle=dot

Compatibility

• 

The Statistics[Detrend] command was introduced in Maple 2019.

• 

For more information on Maple 2019 changes, see Updates in Maple 2019.

See Also

Statistics

Statistics[Mean]

Statistics[Scale]

TimeSeriesAnalysis[Decomposition]