NAG FL Interfaceg13dlf (multi_​diff)

▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

1Purpose

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.

2Specification

Fortran Interface
 Subroutine g13dlf ( k, n, z, kmax, tr, id, w, nd, work,
 Integer, Intent (In) :: k, n, kmax, id(k) Integer, Intent (Inout) :: ifail Integer, Intent (Out) :: nd Real (Kind=nag_wp), Intent (In) :: z(kmax,n), delta(kmax,*) Real (Kind=nag_wp), Intent (Inout) :: w(kmax,*) Real (Kind=nag_wp), Intent (Out) :: work(k*n) Character (1), Intent (In) :: tr(k)
#include <nag.h>
 void g13dlf_ (const Integer *k, const Integer *n, const double z[], const Integer *kmax, const char tr[], const Integer id[], const double delta[], double w[], Integer *nd, double work[], Integer *ifail, const Charlen length_tr)
The routine may be called by the names g13dlf or nagf_tsa_multi_diff.

3Description

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 $i$th series is ${\mathit{d}}_{i}$, then the differencing operator is defined by ${\delta }_{i}\left(B\right)=1-{\delta }_{i1}B-{\delta }_{i2}{B}^{2}-\cdots -{\delta }_{i{\mathit{d}}_{i}}{B}^{{\mathit{d}}_{i}}$, where $B$ is the backward shift operator; that is, $B{Z}_{t}={Z}_{t-1}$. Let $\mathit{d}$ denote the maximum of the orders of differencing, ${\mathit{d}}_{i}$, over the $k$ series. The routine computes values of the differenced/transformed series ${W}_{\mathit{t}}={\left({w}_{1\mathit{t}},{w}_{2\mathit{t}},\dots ,{w}_{\mathit{k}\mathit{t}}\right)}^{\mathrm{T}}$, for $\mathit{t}=\mathit{d}+1,\dots ,n$, as follows:
 $wit=δi(B)zit*, i=1,2,…,k$
where ${z}_{it}^{*}$ are the transformed values of the original $k$-dimensional time series ${Z}_{t}={\left({z}_{1t},{z}_{2t},\dots ,{z}_{kt}\right)}^{\mathrm{T}}$.
The differencing parameters ${\delta }_{ij}$, for $i=1,2,\dots ,k$ and $j=1,2,\dots ,{\mathit{d}}_{i}$, must be supplied by you. If the $i$th series does not require differencing, then ${\mathit{d}}_{i}=0$.

4References

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

5Arguments

1: $\mathbf{k}$Integer Input
On entry: $k$, the dimension of the multivariate time series.
Constraint: ${\mathbf{k}}\ge 1$.
2: $\mathbf{n}$Integer Input
On entry: $n$, the number of observations in the series, prior to differencing.
Constraint: ${\mathbf{n}}\ge 1$.
3: $\mathbf{z}\left({\mathbf{kmax}},{\mathbf{n}}\right)$Real (Kind=nag_wp) array Input
On entry: ${\mathbf{z}}\left(\mathit{i},\mathit{t}\right)$ must contain, ${z}_{\mathit{i}\mathit{t}}$, the $\mathit{i}$th component of ${Z}_{\mathit{t}}$, for $\mathit{i}=1,2,\dots ,k$ and $\mathit{t}=1,2,\dots ,n$.
Constraints:
• if ${\mathbf{tr}}\left(i\right)=\text{'L'}$, ${\mathbf{z}}\left(i,t\right)>0.0$;
• if ${\mathbf{tr}}\left(i\right)=\text{'S'}$, ${\mathbf{z}}\left(\mathit{i},\mathit{t}\right)\ge 0.0$, for $\mathit{i}=1,2,\dots ,k$ and $\mathit{t}=1,2,\dots ,n$.
4: $\mathbf{kmax}$Integer Input
On entry: the first dimension of the arrays z, delta and w as declared in the (sub)program from which g13dlf is called.
Constraint: ${\mathbf{kmax}}\ge {\mathbf{k}}$.
5: $\mathbf{tr}\left({\mathbf{k}}\right)$Character(1) array Input
On entry: ${\mathbf{tr}}\left(\mathit{i}\right)$ indicates whether the $\mathit{i}$th time series is to be transformed, for $\mathit{i}=1,2,\dots ,k$.
${\mathbf{tr}}\left(i\right)=\text{'N'}$
No transformation is used.
${\mathbf{tr}}\left(i\right)=\text{'L'}$
A log transformation is used.
${\mathbf{tr}}\left(i\right)=\text{'S'}$
A square root transformation is used.
Constraint: ${\mathbf{tr}}\left(\mathit{i}\right)=\text{'N'}$, $\text{'L'}$ or $\text{'S'}$, for $\mathit{i}=1,2,\dots ,k$.
6: $\mathbf{id}\left({\mathbf{k}}\right)$Integer array Input
On entry: the order of differencing for each series, ${\mathit{d}}_{1},{\mathit{d}}_{2},\dots ,{\mathit{d}}_{k}$.
Constraint: $0\le {\mathbf{id}}\left(\mathit{i}\right)<{\mathbf{n}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{k}}$.
7: $\mathbf{delta}\left({\mathbf{kmax}},*\right)$Real (Kind=nag_wp) array Input
Note: the second dimension of the array delta must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\mathit{d}\right)$, where $\mathit{d}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{id}}\left(i\right)\right)$.
On entry: if ${\mathbf{id}}\left(i\right)>0$, then ${\mathbf{delta}}\left(\mathit{i},\mathit{j}\right)$ must be set equal to ${\delta }_{\mathit{i}\mathit{j}}$, for $\mathit{j}=1,2,\dots ,{\mathit{d}}_{i}$ and $\mathit{i}=1,2,\dots ,k$.
If $\mathit{d}=0$, delta is not referenced.
8: $\mathbf{w}\left({\mathbf{kmax}},*\right)$Real (Kind=nag_wp) array Output
Note: the second dimension of the array w must be at least ${\mathbf{n}}-\mathit{d}$, where $\mathit{d}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{id}}\left(i\right)\right)$.
On exit: ${\mathbf{w}}\left(\mathit{i},\mathit{t}\right)$ contains the value of ${w}_{\mathit{i},\mathit{t}+\mathit{d}}$, for $\mathit{i}=1,2,\dots ,k$ and $\mathit{t}=1,2,\dots ,n-\mathit{d}$.
9: $\mathbf{nd}$Integer Output
On exit: the number of differenced values, $n-\mathit{d}$, in the series, where $\mathit{d}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{id}}\left(i\right)\right)$.
10: $\mathbf{work}\left({\mathbf{k}}×{\mathbf{n}}\right)$Real (Kind=nag_wp) array Workspace
11: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ or $\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

6Error Indicators and Warnings

If on entry ${\mathbf{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:
${\mathbf{ifail}}=1$
On entry, ${\mathbf{k}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{k}}\ge 1$.
On entry, ${\mathbf{kmax}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{k}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{kmax}}\ge {\mathbf{k}}$.
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 1$.
${\mathbf{ifail}}=2$
On entry, $i=⟨\mathit{\text{value}}⟩$, ${\mathbf{id}}\left(i\right)=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{id}}<{\mathbf{n}}$.
On entry, $i=⟨\mathit{\text{value}}⟩$ and ${\mathbf{id}}\left(i\right)=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{id}}\left(i\right)\ge 0$.
${\mathbf{ifail}}=3$
On entry, $i=⟨\mathit{\text{value}}⟩$ and ${\mathbf{tr}}\left(i\right)$ is invalid.
Constraint: ${\mathbf{tr}}\left(i\right)=\text{'N'}$, $\text{'L'}$ or $\text{'S'}$.
${\mathbf{ifail}}=4$
On entry, one (or more) of the transformations requested is invalid. Check that you are not trying to log or square-root a series, some of whose values are negative.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7Accuracy

The computations are believed to be stable.

8Parallelism and Performance

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.

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 ${\nabla }^{2}$ to the first series and the first-order differencing operator $\nabla$ to the second series:
 $w1t =∇2z1t= (1-B) 2z1t=(1-2B+B2)z1t, and w2t =∇z2t=(1-B)z2t.$
Then ${\mathit{d}}_{1}=2,{\mathit{d}}_{2}=1$, $\mathit{d}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathit{d}}_{1},{\mathit{d}}_{2}\right)=2$, and
 $delta = [ δ11 δ12 δ21 ] = [ 2 −1 1 ] .$

10Example

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.1Program Text

Program Text (g13dlfe.f90)

10.2Program Data

Program Data (g13dlfe.d)

10.3Program Results

Program Results (g13dlfe.r)