Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_tsa_multi_corrmat_partlag (g13dn)

## Purpose

nag_tsa_multi_corrmat_partlag (g13dn) calculates the sample partial lag correlation matrices of a multivariate time series. A set of χ2${\chi }^{2}$-statistics and their significance levels are also returned. A call to nag_tsa_multi_corrmat_cross (g13dm) is usually made prior to calling this function in order to calculate the sample cross-correlation matrices.

## Syntax

[maxlag, parlag, x, pvalue, ifail] = g13dn(n, m, r0, r, 'k', k)
[maxlag, parlag, x, pvalue, ifail] = nag_tsa_multi_corrmat_partlag(n, m, r0, r, 'k', k)

## Description

Let Wt = (w1t,w2t,,wkt)T ${W}_{\mathit{t}}={\left({w}_{1\mathit{t}},{w}_{2\mathit{t}},\dots ,{w}_{\mathit{k}\mathit{t}}\right)}^{\mathrm{T}}$, for t = 1,2,,n$\mathit{t}=1,2,\dots ,n$, denote n$n$ observations of a vector of k$k$ time series. The partial lag correlation matrix at lag l$l$, P(l)$P\left(l\right)$, is defined to be the correlation matrix between Wt${W}_{t}$ and Wt + l${W}_{t+l}$, after removing the linear dependence on each of the intervening vectors Wt + 1,Wt + 2,,Wt + l1${W}_{t+1},{W}_{t+2},\dots ,{W}_{t+l-1}$. It is the correlation matrix between the residual vectors resulting from the regression of Wt + l${W}_{t+l}$ on the carriers Wt + l1,,Wt + 1${W}_{t+l-1},\dots ,{W}_{t+1}$ and the regression of Wt${W}_{t}$ on the same set of carriers; see Heyse and Wei (1985).
P(l)$P\left(l\right)$ has the following properties.
 (i) If Wt${W}_{t}$ follows a vector autoregressive model of order p$p$, then P(l) = 0$P\left(l\right)=0$ for l > p$l>p$; (ii) When k = 1$k=1$, P(l)$P\left(l\right)$ reduces to the univariate partial autocorrelation at lag l$l$; (iii) Each element of P(l)$P\left(l\right)$ is a properly normalized correlation coefficient; (iv) When l = 1$l=1$, P(l)$P\left(l\right)$ is equal to the cross-correlation matrix at lag 1$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$m$, which is usually taken to be at most n / 4$n/4$. Only the sample cross-correlation matrices ((l)$\stackrel{^}{R}\left(\mathit{l}\right)$, for l = 0,1,,m$\mathit{l}=0,1,\dots ,m$) and the standard deviations of the series are required as input to nag_tsa_multi_corrmat_partlag (g13dn). These may be computed by nag_tsa_multi_corrmat_cross (g13dm). Under the hypothesis that Wt${W}_{t}$ follows an autoregressive model of order s1$s-1$, the elements of the sample partial lag matrix (s)$\stackrel{^}{P}\left(s\right)$, denoted by ij(s)${\stackrel{^}{P}}_{ij}\left(s\right)$, are asymptotically Normally distributed with mean zero and variance 1 / n$1/n$. In addition the statistic
 k k X(s) = n ∑ ∑ P̂ij(s)2 i = 1 j = 1
$X(s)=n∑i=1k∑j=1kP^ij (s) 2$
has an asymptotic χ2${\chi }^{2}$-distribution with k2${k}^{2}$ degrees of freedom. These quantities, X(l)$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.

## 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

## Parameters

### Compulsory Input Parameters

1:     n – int64int32nag_int scalar
n$n$, the number of observations in each series.
Constraint: n2${\mathbf{n}}\ge 2$.
2:     m – int64int32nag_int scalar
m$m$, the number of partial lag correlation matrices to be computed. Note this also specifies the number of sample cross-correlation matrices that must be contained in the array r.
Constraint: 1m < n$1\le {\mathbf{m}}<{\mathbf{n}}$.
3:     r0(kmax,k) – double array
kmax, the first dimension of the array, must satisfy the constraint kmaxk$\mathit{kmax}\ge {\mathbf{k}}$.
If ij$i\ne j$, then r0(i,j)${\mathbf{r0}}\left(i,j\right)$ must contain the (i,j)$\left(i,j\right)$th element of the sample cross-correlation matrix at lag zero, ij(0)${\stackrel{^}{R}}_{ij}\left(0\right)$. If i = j$i=j$, then r0(i,i)${\mathbf{r0}}\left(i,i\right)$ must contain the standard deviation of the i$i$th series.
4:     r(kmax,kmax,m) – double array
kmax, the first dimension of the array, must satisfy the constraint kmaxk$\mathit{kmax}\ge {\mathbf{k}}$.
r(i,j,l)${\mathbf{r}}\left(i,j,l\right)$ must contain the (i,j)$\left(i,j\right)$th element of the sample cross-correlation at lag l$l$, ij(l)${\stackrel{^}{R}}_{\mathit{i}\mathit{j}}\left(\mathit{l}\right)$, for l = 1,2,,m$\mathit{l}=1,2,\dots ,m$, i = 1,2,,k$\mathit{i}=1,2,\dots ,k$ and j = 1,2,,k$\mathit{j}=1,2,\dots ,k$, where series j$\mathit{j}$ leads series i$\mathit{i}$ (see Section [Further Comments]).

### Optional Input Parameters

1:     k – int64int32nag_int scalar
Default: The first dimension of the arrays r0, r and the second dimension of the array r0. (An error is raised if these dimensions are not equal.)
k$k$, the dimension of the multivariate time series.
Constraint: k1${\mathbf{k}}\ge 1$.

kmax work lwork

### Output Parameters

1:     maxlag – int64int32nag_int scalar
The maximum lag up to which partial lag correlation matrices (along with χ2${\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.
2:     parlag(kmax,kmax,m) – double array
kmaxk$\mathit{kmax}\ge {\mathbf{k}}$.
parlag(i,j,l)${\mathbf{parlag}}\left(i,j,l\right)$ contains the (i,j)$\left(i,j\right)$th element of the sample partial lag correlation matrix at lag l$l$, ij(l)${\stackrel{^}{P}}_{\mathit{i}\mathit{j}}\left(\mathit{l}\right)$, for l = 1,2,,maxlag$\mathit{l}=1,2,\dots ,{\mathbf{maxlag}}$, i = 1,2,,k$\mathit{i}=1,2,\dots ,k$ and j = 1,2,,k$\mathit{j}=1,2,\dots ,k$.
3:     x(m) – double array
x(l)${\mathbf{x}}\left(\mathit{l}\right)$ contains the χ2${\chi }^{2}$-statistic at lag l$\mathit{l}$, for l = 1,2,,maxlag$\mathit{l}=1,2,\dots ,{\mathbf{maxlag}}$.
4:     pvalue(m) – double array
pvalue(l)${\mathbf{pvalue}}\left(\mathit{l}\right)$ contains the significance level of the corresponding χ2${\chi }^{2}$-statistic in x, for l = 1,2,,maxlag$\mathit{l}=1,2,\dots ,{\mathbf{maxlag}}$.
5:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

ifail = 1${\mathbf{ifail}}=1$
 On entry, k < 1${\mathbf{k}}<1$, or n < 2${\mathbf{n}}<2$, or m < 1${\mathbf{m}}<1$, or m ≥ n${\mathbf{m}}\ge {\mathbf{n}}$, or kmax < k$\mathit{kmax}<{\mathbf{k}}$, or lwork < (5m + 6)k2 + k$\mathit{lwork}<\left(5{\mathbf{m}}+6\right){{\mathbf{k}}}^{2}+{\mathbf{k}}$.
W ifail = 2${\mathbf{ifail}}=2$
The recursive equations used to compute the sample partial lag correlation matrices have broken down at lag maxlag + 1${\mathbf{maxlag}}+1$. All output quantities in the arrays parlag, x and pvalue up to and including lag maxlag will be correct.

## Accuracy

The accuracy will depend upon the accuracy of the sample cross-correlations.

The time taken is roughly proportional to m2k3${m}^{2}{k}^{3}$.
If you have calculated the sample cross-correlation matrices in the arrays r0 and r, without calling nag_tsa_multi_corrmat_cross (g13dm), then care must be taken to ensure they are supplied as described in Section [Parameters]. In particular, for l1$l\ge 1$, ij(l)${\stackrel{^}{R}}_{ij}\left(l\right)$ must contain the sample cross-correlation coefficient between wi(tl)${w}_{i\left(t-l\right)}$ and wjt${w}_{jt}$.
The function nag_tsa_multi_autocorr_part (g13db) 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,$1,2,\dots \text{}$ by making repeated calls to the function with the parameter nk set to 1,2,$1,2,\dots \text{}$. The (i,j)$\left(i,j\right)$th element of the sample partial autoregression matrix at lag l$l$ is given by W(i,j,l)$W\left(i,j,l\right)$ when nk is set equal to l$l$ on entry to nag_tsa_multi_autocorr_part (g13db). Note that this is the ‘Yule–Walker’ estimate. Unlike the partial lag correlation matrices computed by nag_tsa_multi_corrmat_partlag (g13dn), when Wt${W}_{t}$ follows an autoregressive model of order s1$s-1$, the elements of the sample partial autoregressive matrix at lag s$s$ do not have variance 1 / n$1/n$, making it very difficult to spot a possible cut-off point. The differences between these matrices are discussed further by Wei (1990).
Note that nag_tsa_multi_autocorr_part (g13db) takes the sample cross-covariance matrices as input whereas this function requires the sample cross-correlation matrices to be input.

## Example

```function nag_tsa_multi_corrmat_partlag_example
n = int64(48);
m = int64(10);
r0 = [2.817550272831091, 0.2493409556934405;
0.2493409556934405, 2.815040887355392];
r(:,:,1) = ...
[0.73593863031348350, 0.17433878570803560; 0.21134574083468491, 0.55456558496897801];
r(:,:,2) = ...
[0.45574297048635831, 0.076489684716733147; 0.069281866929831626, 0.26045462989184309];
r(:,:,3) = ...
[0.37916838732214042, 0.013853352862656621; 0.02598655726548196, -0.038097764295735172];
r(:,:,4) = ...
[0.32240436132974731, 0.11001758294806301; 0.09328031343627570, -0.23585487058651339];
r(:,:,5) = ...
[0.34106636103987392, 0.26947269669730167; 0.087228549020231153, -0.25006674266294399];
r(:,:,6) = ...
[0.36305329805369058, 0.34359213396780991; 0.13229630902251391, -0.22651914298634429];
r(:,:,7) = ...
[0.27995096372005901, 0.42541532263330151; 0.20691314644794351, -0.12843515289063159];
r(:,:,8) = ...
[0.24797414664441220, 0.52175528114652636; 0.19701668447924531, -0.084636152820583122];
r(:,:,9) = ...
[0.23975877705555310, 0.26643728652348198; 0.25365298730974162, 0.074574867932390251];
r(:,:,10) = ...
[0.16192879425385229, -0.019718535446637431; 0.26664581656740433, 0.004727174709710211];
[maxlag, parlag, x, pvalue, ifail] = nag_tsa_multi_corrmat_partlag(n, m, r0, r)
```
```

maxlag =

10

parlag(:,:,1) =

0.7359    0.1743
0.2113    0.5546

parlag(:,:,2) =

-0.1869   -0.0832
-0.1805   -0.0724

parlag(:,:,3) =

0.2775   -0.0069
0.0837   -0.2133

parlag(:,:,4) =

-0.0843    0.2268
0.1284   -0.1763

parlag(:,:,5) =

0.2362    0.2384
-0.0468   -0.0455

parlag(:,:,6) =

-0.0164    0.0873
0.0996   -0.0810

parlag(:,:,7) =

-0.0355    0.2611
0.1257    0.0121

parlag(:,:,8) =

0.0768    0.3815
0.0268   -0.1492

parlag(:,:,9) =

-0.0651   -0.3867
0.1887    0.0565

parlag(:,:,10) =

-0.0261   -0.2861
0.0279   -0.1729

x =

44.3621
3.8239
6.2189
5.0941
5.6094
1.1698
4.0983
8.3707
9.2440
5.4353

pvalue =

0.0000
0.4304
0.1834
0.2778
0.2303
0.8830
0.3929
0.0789
0.0553
0.2455

ifail =

0

```
```function g13dn_example
n = int64(48);
m = int64(10);
r0 = [2.817550272831091, 0.2493409556934405;
0.2493409556934405, 2.815040887355392];
r(:,:,1) = ...
[0.73593863031348350, 0.17433878570803560; 0.21134574083468491, 0.55456558496897801];
r(:,:,2) = ...
[0.45574297048635831, 0.076489684716733147; 0.069281866929831626, 0.26045462989184309];
r(:,:,3) = ...
[0.37916838732214042, 0.013853352862656621; 0.02598655726548196, -0.038097764295735172];
r(:,:,4) = ...
[0.32240436132974731, 0.11001758294806301; 0.09328031343627570, -0.23585487058651339];
r(:,:,5) = ...
[0.34106636103987392, 0.26947269669730167; 0.087228549020231153, -0.25006674266294399];
r(:,:,6) = ...
[0.36305329805369058, 0.34359213396780991; 0.13229630902251391, -0.22651914298634429];
r(:,:,7) = ...
[0.27995096372005901, 0.42541532263330151; 0.20691314644794351, -0.12843515289063159];
r(:,:,8) = ...
[0.24797414664441220, 0.52175528114652636; 0.19701668447924531, -0.084636152820583122];
r(:,:,9) = ...
[0.23975877705555310, 0.26643728652348198; 0.25365298730974162, 0.074574867932390251];
r(:,:,10) = ...
[0.16192879425385229, -0.019718535446637431; 0.26664581656740433, 0.004727174709710211];
[maxlag, parlag, x, pvalue, ifail] = g13dn(n, m, r0, r)
```
```

maxlag =

10

parlag(:,:,1) =

0.7359    0.1743
0.2113    0.5546

parlag(:,:,2) =

-0.1869   -0.0832
-0.1805   -0.0724

parlag(:,:,3) =

0.2775   -0.0069
0.0837   -0.2133

parlag(:,:,4) =

-0.0843    0.2268
0.1284   -0.1763

parlag(:,:,5) =

0.2362    0.2384
-0.0468   -0.0455

parlag(:,:,6) =

-0.0164    0.0873
0.0996   -0.0810

parlag(:,:,7) =

-0.0355    0.2611
0.1257    0.0121

parlag(:,:,8) =

0.0768    0.3815
0.0268   -0.1492

parlag(:,:,9) =

-0.0651   -0.3867
0.1887    0.0565

parlag(:,:,10) =

-0.0261   -0.2861
0.0279   -0.1729

x =

44.3621
3.8239
6.2189
5.0941
5.6094
1.1698
4.0983
8.3707
9.2440
5.4353

pvalue =

0.0000
0.4304
0.1834
0.2778
0.2303
0.8830
0.3929
0.0789
0.0553
0.2455

ifail =

0

```