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

C#
public static void g13aa(
	double[] x,
	int nx,
	int nd,
	int nds,
	int ns,
	double[] xd,
	out int nxd,
	out int ifail
)
Visual Basic
Public Shared Sub g13aa ( _
	x As Double(), _
	nx As Integer, _
	nd As Integer, _
	nds As Integer, _
	ns As Integer, _
	xd As Double(), _
	<OutAttribute> ByRef nxd As Integer, _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void g13aa(
	array<double>^ x, 
	int nx, 
	int nd, 
	int nds, 
	int ns, 
	array<double>^ xd, 
	[OutAttribute] int% nxd, 
	[OutAttribute] int% ifail
)
F#
static member g13aa : 
        x : float[] * 
        nx : int * 
        nd : int * 
        nds : int * 
        ns : int * 
        xd : float[] * 
        nxd : int byref * 
        ifail : int byref -> unit 

Parameters

x
Type: array<System..::..Double>[]()[][]
An array of size [nx]
On entry: the undifferenced time series, xi, for i=1,2,,n.
nx
Type: System..::..Int32
On entry: n, the number of values in the undifferenced time series.
Constraint: nx>nd+nds×ns.
nd
Type: System..::..Int32
On entry: d, the order of non-seasonal differencing.
Constraint: nd0.
nds
Type: System..::..Int32
On entry: D, the order of seasonal differencing.
Constraint: nds0.
ns
Type: System..::..Int32
On entry: s, the seasonality.
Constraints:
  • if nds>0, ns>0;
  • if nds=0, ns0.
xd
Type: array<System..::..Double>[]()[][]
An array of size [nx]
On exit: the differenced values in elements 0 to nxd-1, and reconstitution data in the remainder of the array.
nxd
Type: System..::..Int32%
On exit: the number of differenced values in the array xd.
ifail
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

Description

Let dsDxi be the ith value of a time series xi, for i=1,2,,n after non-seasonal differencing of order d and seasonal differencing of order D (with period or seasonality s). In general,
dsDxi=d-1sDxi+1-d-1sDxid>0
dsDxi=dsD-1xi+s-dsD-1xiD>0
Non-seasonal differencing up to the required order d is obtained using
1xi=xi+1-xifor i=1,2,,n-1
2xi=1xi+1-1xifor i=1,2,,n-2
   
dxi=d-1xi+1-d-1xifor i=1,2,,n-d
Seasonal differencing up to the required order D is then obtained using
ds1xi=dxi+s-dxifor i=1,2,,n-d-s
ds2xi=ds1xi+s-ds1xifor i=1,2,,n-d-2s
   
dsDxi=dsD-1xi+s-dsD-1xifor i=1,2,,n-d-D×s
Mathematically, the sequence in which the differencing operations are performed does not affect the final resulting series of m=n-d-D×s values.

References

None.

Error Indicators and Warnings

Errors or warnings detected by the method:
ifail=1
On entry,nd<0,
ornds<0,
orns<0,
orns=0 when nds>0.
ifail=2
On entry,nxnd+nds×ns.
ifail=-9000
An error occured, see message report.
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value

Accuracy

The computations are believed to be stable.

Parallelism and Performance

None.

Further Comments

The time taken by g13aa is approximately proportional to nd+nds×nx.

Example

This example reads in a set of data consisting of 20 observations from a time series. Non-seasonal differencing of order 2 and seasonal differencing of order 1 (with seasonality of 4) are applied to the input data, giving an output array holding 14 differenced values and 6 values which can be used to reconstitute the output array.

Example program (C#): g13aae.cs

Example program data: g13aae.d

Example program results: g13aae.r

See Also