G13DLF (PDF version)
G13 Chapter Contents
G13 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

G13DLF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

G13DLF differences and/or transforms a multivariate time series. It is intended to be used prior to G13DDF to fit a vector autoregressive moving average (VARMA) model to the differenced/transformed series.

2  Specification

SUBROUTINE G13DLF ( K, N, Z, KMAX, TR, ID, DELTA, W, ND, WORK, IFAIL)
INTEGER  K, N, KMAX, ID(K), ND, IFAIL
REAL (KIND=nag_wp)  Z(KMAX,N), DELTA(KMAX,*), W(KMAX,*), WORK(K*N)
CHARACTER(1)  TR(K)

3  Description

For certain time series it may first be necessary to difference the original data to obtain a stationary series before calculating autocorrelations, etc. This routine also allows you to apply either a square root or a log transformation to the original time series to stabilize the variance if required.
If the order of differencing required for the ith series is di, then the differencing operator is defined by δiB=1-δi1B-δi2B2--δidiBdi, where B is the backward shift operator; that is, BZt=Zt-1. Let d denote the maximum of the orders of differencing, di, over the k series. The routine computes values of the differenced/transformed series Wt = w1t,w2t,,wktT , for t=d+1,,n, as follows:
wit=δiBzit*,  i=1,2,,k  
where zit* are the transformed values of the original k-dimensional time series Zt = z1t,z2t,,zktT .
The differencing parameters δij, for i=1,2,,k and j=1,2,,di, must be supplied by you. If the ith series does not require differencing, then di=0.

4  References

Box G E P and Jenkins G M (1976) Time Series Analysis: Forecasting and Control (Revised Edition) Holden–Day
Wei W W S (1990) Time Series Analysis: Univariate and Multivariate Methods Addison–Wesley

5  Parameters

1:     K – INTEGERInput
On entry: k, the dimension of the multivariate time series.
Constraint: K1.
2:     N – INTEGERInput
On entry: n, the number of observations in the series, prior to differencing.
Constraint: N1.
3:     ZKMAXN – REAL (KIND=nag_wp) arrayInput
On entry: Zit must contain, zit, the ith component of Zt, for i=1,2,,k and t=1,2,,n.
Constraints:
  • if TRi='L', Zit>0.0;
  • if TRi='S', Zit0.0, for i=1,2,,k and t=1,2,,n.
4:     KMAX – INTEGERInput
On entry: the first dimension of the arrays Z, DELTA and W as declared in the (sub)program from which G13DLF is called.
Constraint: KMAXK.
5:     TRK – CHARACTER(1) arrayInput
On entry: TRi indicates whether the ith time series is to be transformed, for i=1,2,,k.
TRi='N'
No transformation is used.
TRi='L'
A log transformation is used.
TRi='S'
A square root transformation is used.
Constraint: TRi='N', 'L' or 'S', for i=1,2,,k.
6:     IDK – INTEGER arrayInput
On entry: the order of differencing for each series, d1,d2,,dk.
Constraint: 0IDi<N, for i=1,2,,K.
7:     DELTAKMAX* – REAL (KIND=nag_wp) arrayInput
Note: the second dimension of the array DELTA must be at least max1,d, where d=maxIDi.
On entry: if IDi>0, then DELTAij must be set equal to δij, for j=1,2,,di and i=1,2,,k.
If d=0, then DELTA is not referenced.
8:     WKMAX* – REAL (KIND=nag_wp) arrayOutput
Note: the second dimension of the array W must be at least N-d, where d=maxIDi.
On exit: Wit contains the value of wi,t+d, for i=1,2,,k and t=1,2,,n-d.
9:     ND – INTEGEROutput
On exit: the number of differenced values, n-d, in the series, where d=maxIDi.
10:   WORKK×N – REAL (KIND=nag_wp) arrayWorkspace
11:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
IFAIL=1
On entry,K<1,
orN<1,
orKMAX<K.
IFAIL=2
On entry,IDi<0, for some i=1,2,,k,
orIDiN, for some i=1,2,,k.
IFAIL=3
On entry,at least one of the first k elements of TR is not equal to 'N', 'L' or 'S'.
IFAIL=4
On entry, one or more of the elements of Z is invalid, for the transformation requested; that is, you may be trying to log or square root a series, some of whose values are negative.
IFAIL=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.8 in the Essential Introduction for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

7  Accuracy

The computations are believed to be stable.

8  Parallelism and Performance

G13DLF is not threaded by NAG in any implementation.
G13DLF makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9  Further Comments

The same differencing operator does not have to be applied to all the series. For example, suppose we have k=2, and wish to apply the second-order differencing operator 2 to the first series and the first-order differencing operator  to the second series:
w1t =2z1t= 1-B 2z1t=1-2B+B2z1t,   and w2t =z2t=1-Bz2t.  
Then d1=2,d2=1, d=maxd1,d2=2, and
DELTA = δ11 δ12 δ21 = 2 -1 1 .  

10  Example

A program to difference (non-seasonally) each of two time series of length 48. No transformation is to be applied to either of the series.

10.1  Program Text

Program Text (g13dlfe.f90)

10.2  Program Data

Program Data (g13dlfe.d)

10.3  Program Results

Program Results (g13dlfe.r)


G13DLF (PDF version)
G13 Chapter Contents
G13 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2015