hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

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

[xd, nxd, ifail] = g13aa(x, nd, nds, ns, 'nx', nx)
[xd, nxd, ifail] = nag_tsa_uni_diff(x, nd, nds, ns, 'nx', nx)

Description

Let dsDxidsDxi be the iith value of a time series xixi, for i = 1,2,,ni=1,2,,n after non-seasonal differencing of order dd and seasonal differencing of order DD (with period or seasonality ss). In general,
dsDxidsDxi = = d1sDxi + 1d1sDxid-1sDxi+1-d-1sDxi d > 0d>0
dsDxidsDxi = = dsD1xi + sdsD1xidsD-1xi+s-dsD-1xi D > 0D>0
Non-seasonal differencing up to the required order dd is obtained using
1xi1xi = = xi + 1xixi+1-xi for i = 1,2,,(n1)i=1,2,,(n-1)
2xi2xi = = 1xi + 11xi1xi+1-1xi for i = 1,2,,(n2)i=1,2,,(n-2)
     
dxidxi = = d1xi + 1d1xid-1xi+1-d-1xi for i = 1,2,,(nd)i=1,2,,(n-d)
Seasonal differencing up to the required order DD is then obtained using
ds1xids1xi = = dxi + sdxidxi+s-dxi for i = 1,2,,(nds)i=1,2,,(n-d-s)
ds2xids2xi = = ds1xi + sds1xids1xi+s-ds1xi for i = 1,2,,(nd2s)i=1,2,,(n-d-2s)
     
dsDxidsDxi = = dsD1xi + sdsD1xidsD-1xi+s-dsD-1xi for i = 1,2,,(ndD × s)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 = ndD × sm=n-d-D×s values.

References

None.

Parameters

Compulsory Input Parameters

1:     x(nx) – double array
nx, the dimension of the array, must satisfy the constraint nx > nd + (nds × ns)nx>nd+(nds×ns).
The undifferenced time series, xixi, for i = 1,2,,ni=1,2,,n.
2:     nd – int64int32nag_int scalar
dd, the order of non-seasonal differencing.
Constraint: nd0nd0.
3:     nds – int64int32nag_int scalar
DD, the order of seasonal differencing.
Constraint: nds0nds0.
4:     ns – int64int32nag_int scalar
ss, the seasonality.
Constraints:
  • if nds > 0nds>0, ns > 0ns>0;
  • if nds = 0nds=0, ns0ns0.

Optional Input Parameters

1:     nx – int64int32nag_int scalar
Default: The dimension of the array x.
nn, the number of values in the undifferenced time series.
Constraint: nx > nd + (nds × ns)nx>nd+(nds×ns).

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     xd(nx) – double array
The differenced values in elements 11 to nxdnxd, and reconstitution data in the remainder of the array.
2:     nxd – int64int32nag_int scalar
The number of differenced values in the array xd.
3:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,nd < 0nd<0,
ornds < 0nds<0,
orns < 0ns<0,
orns = 0ns=0 when nds > 0nds>0.
  ifail = 2ifail=2
On entry,nxnd + (nds × ns)nxnd+(nds×ns).

Accuracy

The computations are believed to be stable.

Further Comments

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

Example

function nag_tsa_uni_diff_example
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] = nag_tsa_uni_diff(x, nd, nds, ns)
 

xd =

   -11
   -10
    -8
     4
    12
    -2
    18
     9
    -4
    -6
    -5
    -2
   -12
     5
     2
   -10
   -13
    17
     6
   105


nxd =

                   14


ifail =

                    0


function g13aa_example
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)
 

xd =

   -11
   -10
    -8
     4
    12
    -2
    18
     9
    -4
    -6
    -5
    -2
   -12
     5
     2
   -10
   -13
    17
     6
   105


nxd =

                   14


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013