NAG Library Routine Document
G13DNF
1 Purpose
G13DNF calculates the sample partial lag correlation matrices of a multivariate time series. A set of
${\chi}^{2}$statistics and their significance levels are also returned. A call to
G13DMF is usually made prior to calling this routine in order to calculate the sample crosscorrelation matrices.
2 Specification
SUBROUTINE G13DNF ( 
K, N, M, KMAX, R0, R, MAXLAG, PARLAG, X, PVALUE, WORK, LWORK, IFAIL) 
INTEGER 
K, N, M, KMAX, MAXLAG, LWORK, IFAIL 
REAL (KIND=nag_wp) 
R0(KMAX,K), R(KMAX,KMAX,M), PARLAG(KMAX,KMAX,M), X(M), PVALUE(M), WORK(LWORK) 

3 Description
Let
${W}_{\mathit{t}}={\left({w}_{1\mathit{t}},{w}_{2\mathit{t}},\dots ,{w}_{\mathit{k}\mathit{t}}\right)}^{\mathrm{T}}$, for
$\mathit{t}=1,2,\dots ,n$, denote
$n$ observations of a vector of
$k$ time series. The partial lag correlation matrix at lag
$l$,
$P\left(l\right)$, is defined to be the correlation matrix between
${W}_{t}$ and
${W}_{t+l}$, after removing the linear dependence on each of the intervening vectors
${W}_{t+1},{W}_{t+2},\dots ,{W}_{t+l1}$. It is the correlation matrix between the residual vectors resulting from the regression of
${W}_{t+l}$ on the carriers
${W}_{t+l1},\dots ,{W}_{t+1}$ and the regression of
${W}_{t}$ on the same set of carriers; see
Heyse and Wei (1985).
$P\left(l\right)$ has the following properties.
(i) 
If ${W}_{t}$ follows a vector autoregressive model of order $p$, then $P\left(l\right)=0$ for $l>p$; 
(ii) 
When $k=1$, $P\left(l\right)$ reduces to the univariate partial autocorrelation at lag $l$; 
(iii) 
Each element of $P\left(l\right)$ is a properly normalized correlation coefficient; 
(iv) 
When $l=1$, $P\left(l\right)$ is equal to the crosscorrelation matrix at lag $1$ (a natural property which also holds for the univariate partial autocorrelation function). 
Sample estimates of the partial lag correlation matrices may be obtained using the recursive algorithm described in
Wei (1990). They are calculated up to lag
$m$, which is usually taken to be at most
$n/4$. Only the sample crosscorrelation matrices (
$\hat{R}\left(\mathit{l}\right)$, for
$\mathit{l}=0,1,\dots ,m$) and the standard deviations of the series are required as input to G13DNF. These may be computed by
G13DMF. Under the hypothesis that
${W}_{t}$ follows an autoregressive model of order
$s1$, the elements of the sample partial lag matrix
$\hat{P}\left(s\right)$, denoted by
${\hat{P}}_{ij}\left(s\right)$, are asymptotically Normally distributed with mean zero and variance
$1/n$. In addition the statistic
has an asymptotic
${\chi}^{2}$distribution with
${k}^{2}$ degrees of freedom. These quantities,
$X\left(l\right)$, are useful as a diagnostic aid for determining whether the series follows an autoregressive model and, if so, of what order.
4 References
Heyse J F and Wei W W S (1985) The partial lag autocorrelation function Technical Report No. 32 Department of Statistics, Temple University, Philadelphia
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:
${\mathbf{K}}\ge 1$.
 2: N – INTEGERInput
On entry: $n$, the number of observations in each series.
Constraint:
${\mathbf{N}}\ge 2$.
 3: M – INTEGERInput
On entry:
$m$, the number of partial lag correlation matrices to be computed. Note this also specifies the number of sample crosscorrelation matrices that must be contained in the array
R.
Constraint:
$1\le {\mathbf{M}}<{\mathbf{N}}$.
 4: KMAX – INTEGERInput
On entry: the first dimension of the arrays
R0,
R and
PARLAG and the second dimension of the arrays
R and
PARLAG as declared in the (sub)program from which G13DNF is called.
Constraint:
${\mathbf{KMAX}}\ge {\mathbf{K}}$.
 5: R0(KMAX,K) – REAL (KIND=nag_wp) arrayInput
On entry: if $i\ne j$, then ${\mathbf{R0}}\left(i,j\right)$ must contain the $\left(i,j\right)$th element of the sample crosscorrelation matrix at lag zero, ${\hat{R}}_{ij}\left(0\right)$. If $i=j$, then ${\mathbf{R0}}\left(i,i\right)$ must contain the standard deviation of the $i$th series.
 6: R(KMAX,KMAX,M) – REAL (KIND=nag_wp) arrayInput
On entry:
${\mathbf{R}}\left(i,j,l\right)$ must contain the
$\left(i,j\right)$th element of the sample crosscorrelation at lag
$l$,
${\hat{R}}_{\mathit{i}\mathit{j}}\left(\mathit{l}\right)$, for
$\mathit{l}=1,2,\dots ,m$,
$\mathit{i}=1,2,\dots ,k$ and
$\mathit{j}=1,2,\dots ,k$, where series
$\mathit{j}$ leads series
$\mathit{i}$ (see
Section 8).
 7: MAXLAG – INTEGEROutput
On exit: the maximum lag up to which partial lag correlation matrices (along with
${\chi}^{2}$statistics and their significance levels) have been successfully computed. On a successful exit
MAXLAG will equal
M. If
${\mathbf{IFAIL}}={\mathbf{2}}$ on exit, then
MAXLAG will be less than
M.
 8: PARLAG(KMAX,KMAX,M) – REAL (KIND=nag_wp) arrayOutput
On exit: ${\mathbf{PARLAG}}\left(i,j,l\right)$ contains the $\left(i,j\right)$th element of the sample partial lag correlation matrix at lag $l$,
${\hat{P}}_{\mathit{i}\mathit{j}}\left(\mathit{l}\right)$, for $\mathit{l}=1,2,\dots ,{\mathbf{MAXLAG}}$, $\mathit{i}=1,2,\dots ,k$ and $\mathit{j}=1,2,\dots ,k$.
 9: X(M) – REAL (KIND=nag_wp) arrayOutput
On exit: ${\mathbf{X}}\left(\mathit{l}\right)$ contains the ${\chi}^{2}$statistic at lag $\mathit{l}$, for $\mathit{l}=1,2,\dots ,{\mathbf{MAXLAG}}$.
 10: PVALUE(M) – REAL (KIND=nag_wp) arrayOutput
On exit:
${\mathbf{PVALUE}}\left(\mathit{l}\right)$ contains the significance level of the corresponding
${\chi}^{2}$statistic in
X, for
$\mathit{l}=1,2,\dots ,{\mathbf{MAXLAG}}$.
 11: WORK(LWORK) – REAL (KIND=nag_wp) arrayWorkspace
 12: LWORK – INTEGERInput
On entry: the dimension of the array
WORK as declared in the (sub)program from which G13DNF is called.
Constraint:
${\mathbf{LWORK}}\ge \left(5{\mathbf{M}}+6\right){{\mathbf{K}}}^{2}+{\mathbf{K}}$.
 13: IFAIL – INTEGERInput/Output

On entry:
IFAIL must be set to
$0$,
$1\text{ 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\text{ 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 $\mathbf{1}\text{ 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).
6 Error Indicators and Warnings
If on entry
${\mathbf{IFAIL}}={\mathbf{0}}$ or
${{\mathbf{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}}<1$, 
or  ${\mathbf{N}}<2$, 
or  ${\mathbf{M}}<1$, 
or  ${\mathbf{M}}\ge {\mathbf{N}}$, 
or  ${\mathbf{KMAX}}<{\mathbf{K}}$, 
or  ${\mathbf{LWORK}}<\left(5{\mathbf{M}}+6\right){{\mathbf{K}}}^{2}+{\mathbf{K}}$. 
 ${\mathbf{IFAIL}}=2$
The recursive equations used to compute the sample partial lag correlation matrices have broken down at lag
${\mathbf{MAXLAG}}+1$. All output quantities in the arrays
PARLAG,
X and
PVALUE up to and including lag
MAXLAG will be correct.
7 Accuracy
The accuracy will depend upon the accuracy of the sample crosscorrelations.
The time taken is roughly proportional to ${m}^{2}{k}^{3}$.
If you have calculated the sample crosscorrelation matrices in the arrays
R0 and
R, without calling
G13DMF, then care must be taken to ensure they are supplied as described in
Section 5. In particular, for
$l\ge 1$,
${\hat{R}}_{ij}\left(l\right)$ must contain the sample crosscorrelation coefficient between
${w}_{i\left(tl\right)}$ and
${w}_{jt}$.
The routine
G13DBF computes squared partial autocorrelations for a specified number of lags. It may also be used to estimate a sequence of partial autoregression matrices at lags
$1,2,\dots \text{}$ by making repeated calls to the routine with the parameter
NK set to
$1,2,\dots \text{}$. The
$\left(i,j\right)$th element of the sample partial autoregression matrix at lag
$l$ is given by
$W\left(i,j,l\right)$ when
NK is set equal to
$l$ on entry to
G13DBF. Note that this is the ‘Yule–Walker’ estimate. Unlike the partial lag correlation matrices computed by G13DNF, when
${W}_{t}$ follows an autoregressive model of order
$s1$, the elements of the sample partial autoregressive matrix at lag
$s$ do not have variance
$1/n$, making it very difficult to spot a possible cutoff point. The differences between these matrices are discussed further by
Wei (1990).
Note that
G13DBF takes the sample crosscovariance matrices as input whereas this routine requires the sample crosscorrelation matrices to be input.
9 Example
This example computes the sample partial lag correlation matrices of two time series of length $48$, up to lag $10$. The matrices, their ${\chi}^{2}$statistics and significance levels and a plot of symbols indicating which elements of the sample partial lag correlation matrices are significant are printed. Three * represent significance at the $0.5$% level, two * represent significance at the 1% level and a single * represents significance at the 5% level. The * are plotted above or below the central line depending on whether the elements are significant in a positive or negative direction.
9.1 Program Text
Program Text (g13dnfe.f90)
9.2 Program Data
Program Data (g13dnfe.d)
9.3 Program Results
Program Results (g13dnfe.r)