compute lagged differences between elements in a data set
Difference( X )
Difference( X, options )
data set, DataSeries, DataFrame, or TimeSeries; numeric list of values
(optional) equation(s) of the form option=value where option can be times or lag
times : posint; positive integer value indicating the number of times (order) to perform lagged differences. The default is 1.
lag : posint; positive integer value indicating the lag (staggering) of the differenced elements. The default is 1.
The Difference command is used to compute lagged differences between elements in a data set. If X is a vector of length n and times = 1, then the computed result is equal to the successive differences X[(1+lag)..n] - X[1..(n-lag)]. If X is a multi-column data set, then the differencing algorithm is run on each column of data individually.
Define some data:
x ≔ seq⁡i2,i=1..10
To compute the differences between terms in the data, the Difference command is used.
The times option makes it possible to apply the difference multiple times.
Note that this is equivalent to running:
The lag option staggers the differencing. Using a lag of 2 subtracts the first value from the third value, the second from the fourth, and so on:
The Difference command can also be applied directly to TimeSeries data.
ts ≔ TimeSeriesAnalysis:-TimeSeries⁡1,4,9,16
ts≔Time seriesdata set4 rows of data:2019 - 2022
Time seriesdata set (differenced)3 rows of data:2020 - 2022
The Statistics[Difference] command was introduced in Maple 2019.
For more information on Maple 2019 changes, see Updates in Maple 2019.
Download Help Document