TimeSeriesAnalysis[Difference]  differencing transformation

Calling Sequence


Apply(Difference, timeseries)
Apply(Difference(times = n, lag = k), timeseries)
Unapply(Difference, forecast)
Unapply(Difference(times = n, lag = k), forecast)
Unapply(Difference(times = n, lag = k), forecast, origin = o)


Parameters


timeseries



TimeSeries data set

n



positive integer (optional)

k



positive integer (optional)

forecast



TimeSeries data set, typically obtained from a forecasting method

o



specification of origin ; list of Matrices





Description


•

The differencing transformation takes a time series and returns the time series .

•

Apply this transformation to a time series using the Apply command. Translate differenced information such as forecasts back to the original domain by using the Unapply command.

This is done so that Unapply can recover the data.
In the example above, only a single number was needed. However, if contains data sets, then a Vector of origins is needed  one for every data set. Moreover, if , then each data set needs independent origins; all of these are arranged in a x_m_ Matrix. Finally, with , we need such a Matrix for every differencing operation that is undone.
The most explicit way to specify the origin argument is therefore as a list of Matrices, each of size x_m_. However, several shortcuts are available:
–

A Matrix can be specified as a list or Vector of the elements needed.

–

A Matrix can be specified as the list or Vector of the elements of its first row; this row will be repeated times.

–

A Matrix can be specified as a single number, which the Matrix will be filled with.

–

Finally, if you specify a single number, it will be used to fill all of the



Compatibility


•

The TimeSeriesAnalysis[Difference] command was introduced in Maple 18.



Examples


>


>


 (1) 
>


 (2) 
>


 (3) 
Here are the differences in sales from week to week.
>


 (4) 
>


 (5) 
Reconstructing the original data (except for the first row):
>


 (6) 
>


 (7) 
The original data, differenced twice:
>


 (8) 
>


 (9) 
You can do this in one step, too. The header gets a bit nicer name in this case:
>


 (10) 
>


 (11) 
Unapplying differencing twice leads to the original data (minus the first two rows).
>


 (12) 
>


 (13) 
>


 (14) 
>


 (15) 
You can also perform two operations of unapplying differencing once, to either or .
>


 (16) 
>


 (17) 
>


 (18) 
>


 (19) 
>


 (20) 
>


 (21) 
>


 (22) 
>


 (23) 
If you expect a biweekly pattern, you can difference with lag = 2.
>


 (24) 
>


 (25) 
If one of the data points were missing, you can still do the transformation and backtransformation.
>


 (26) 
>


 (27) 
>


 (28) 
>


 (29) 
>


 (30) 

Specifying the option


•

Consider the following time series.

>


 (31) 
>


 (32) 
•

If you try to unapply a differencing operation, Maple complains that it cannot find the origin.

>


>


 (33) 
>


 (34) 
•

This can also be specified as just the list .

>


 (35) 
>


 (36) 
•

If you set , you need to specify values for three previous data points for each data set. You can give a list with a single Matrix  or just specify the Matrix directly.

>


 (37) 
>


 (38) 
•

If you set and , then you need to specify all these values for both times that you unapply differencing. The two matrices need to be specified in a list, in the order in which they will be used.

>


 (39) 
>


 (40) 


