Detrend - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


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

data

(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

detrend_data

(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

signal_data

(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]