PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_tsa_uni_diff (g13aa)
Purpose
nag_tsa_uni_diff (g13aa) carries out non-seasonal and seasonal differencing on a time series. Information which allows the original series to be reconstituted from the differenced series is also produced. This information is required in time series forecasting.
Syntax
Description
Let
be the
th value of a time series
, for
after non-seasonal differencing of order
and seasonal differencing of order
(with period or seasonality
). In general,
|
|
|
|
|
|
|
|
Non-seasonal differencing up to the required order
is obtained using
|
|
|
for |
|
|
|
for |
|
|
|
|
|
|
|
for |
Seasonal differencing up to the required order
is then obtained using
|
|
|
for |
|
|
|
for |
|
|
|
|
|
|
|
for |
Mathematically, the sequence in which the differencing operations are performed does not affect the final resulting series of values.
References
None.
Parameters
Compulsory Input Parameters
- 1:
– double array
-
The undifferenced time series,
, for .
- 2:
– int64int32nag_int scalar
-
, the order of non-seasonal differencing.
Constraint:
.
- 3:
– int64int32nag_int scalar
-
, the order of seasonal differencing.
Constraint:
.
- 4:
– int64int32nag_int scalar
-
, the seasonality.
Constraints:
- if , ;
- if , .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the array
x.
, the number of values in the undifferenced time series.
Constraint:
.
Output Parameters
- 1:
– double array
-
The differenced values in elements to , and reconstitution data in the remainder of the array.
- 2:
– int64int32nag_int scalar
-
The number of differenced values in the array
xd.
- 3:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
On entry, | , |
or | , |
or | , |
or | when . |
-
-
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
The computations are believed to be stable.
Further Comments
The time taken by nag_tsa_uni_diff (g13aa) is approximately proportional to .
Example
This example reads in a set of data consisting of observations from a time series. Non-seasonal differencing of order and seasonal differencing of order (with seasonality of ) are applied to the input data, giving an output array holding differenced values and values which can be used to reconstitute the output array.
Open in the MATLAB editor:
g13aa_example
function g13aa_example
fprintf('g13aa example results\n\n');
x = [120; 108; 98; 118; 135;
131; 118; 125; 121; 100;
82; 82; 89; 88; 86;
96; 108; 110; 99; 105];
nd = int64(2);
nds = int64(1);
ns = int64(4);
[xd, nxd, ifail] = g13aa( ...
x, nd, nds, ns);
nx = numel(xd);
fprintf(' Non-seasonal differencing of order %4d\n', nd);
fprintf(' and seasonal differencing of order %4d\n', nds);
fprintf(' are applied with seasonality %4d\n\n',ns);
fprintf('The output array holds %4d values,\n',nx);
fprintf(' of which the first %4d are differenced values\n\n',nxd);
for j = 1:7:nxd
fprintf('%7.0f',xd(j:min(j+6,nxd)));
fprintf('\n');
end
fprintf('\n');
for j = nxd+1:7:nx
fprintf('%7.0f',xd(j:min(j+6,nx)));
fprintf('\n');
end
g13aa example results
Non-seasonal differencing of order 2
and seasonal differencing of order 1
are applied with seasonality 4
The output array holds 20 values,
of which the first 14 are differenced values
-11 -10 -8 4 12 -2 18
9 -4 -6 -5 -2 -12 5
2 -10 -13 17 6 105
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015