# NAG Library Function Documentnag_tsa_multi_part_lag_corr (g13dnc)

## 1  Purpose

nag_tsa_multi_part_lag_corr (g13dnc) 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 nag_tsa_multi_cross_corr (g13dmc) is usually made prior to calling this function in order to calculate the sample cross-correlation matrices.

## 2  Specification

#include <nag.h>
#include <nagg13.h>

void  nag_tsa_multi_part_lag_corr (Integer k, Integer n, Integer m, const double r0[], const double r[], Integer *maxlag, double parlag[], double x[], double pvalue[],  NagError *fail)

## 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+l-1}$. It is the correlation matrix between the residual vectors resulting from the regression of ${W}_{t+l}$ on the carriers ${W}_{t+l-1},\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 cross-correlation 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 cross-correlation matrices ($\stackrel{^}{R}\left(\mathit{l}\right)$, for $\mathit{l}=0,1,\dots ,m$) and the standard deviations of the series are required as input to nag_tsa_multi_part_lag_corr (g13dnc). These may be computed by nag_tsa_multi_cross_corr (g13dmc). Under the hypothesis that ${W}_{t}$ follows an autoregressive model of order $s-1$, the elements of the sample partial lag matrix $\stackrel{^}{P}\left(s\right)$, denoted by ${\stackrel{^}{P}}_{ij}\left(s\right)$, are asymptotically Normally distributed with mean zero and variance $1/n$. In addition the statistic

$Xs=n∑i=1k∑j=1kP^ij s 2$
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  Arguments

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 cross-correlation matrices that must be contained in the array r.
Constraint: $1\le {\mathbf{m}}<{\mathbf{n}}$.
4:     r0[${\mathbf{k}}×{\mathbf{k}}$] – const doubleInput
On entry: the sample cross-correlations at lag zero/standard deviations as provided by nag_tsa_multi_cross_corr (g13dmc), that is, ${\mathbf{r0}}\left[\left(\mathit{j}-1\right)k+\mathit{i}-1\right]$ must contain the $\left(\mathit{i},\mathit{j}\right)$th element of the sample cross-correlation matrix at lag zero if $\mathit{i}\ne \mathit{j}$ and the standard deviation of $\mathit{i}=\mathit{j}$, for $\mathit{i}=1,2,\dots ,k$ and $\mathit{j}=1,2,\dots ,k$.
5:     r[${\mathbf{k}}×{\mathbf{k}}×{\mathbf{m}}$] – const doubleInput
On entry: the sample cross-correlations as provided by nag_tsa_multi_cross_corr (g13dmc), that is, ${\mathbf{r}}\left[\left(\mathit{l}-1\right){k}^{2}+\left(\mathit{j}-1\right)k+\mathit{i}-1\right]$ must contain the $\left(\mathit{i},\mathit{j}\right)$th element of the sample cross-correlation at lag $\mathit{l}$, 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}$.
6:     maxlag – Integer *Output
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 MATRIX_ILL_CONDITIONED on exit, then maxlag will be less than m.
7:     parlag[${\mathbf{k}}×{\mathbf{k}}×{\mathbf{m}}$] – doubleInput/Output
On exit: ${\mathbf{parlag}}\left[\left(\mathit{l}-1\right){k}^{2}+\left(\mathit{j}-1\right)k+\mathit{i}-1\right]$ contains the $\left(\mathit{i},\mathit{j}\right)$th element of the sample partial lag correlation matrix at lag $\mathit{l}$, for $\mathit{l}=1,2,\dots ,{\mathbf{maxlag}}$, $\mathit{i}=1,2,\dots ,k$ and $\mathit{j}=1,2,\dots ,k$.
8:     x[m] – doubleOutput
On exit: ${\mathbf{x}}\left[\mathit{l}-1\right]$ contains the ${\chi }^{2}$-statistic at lag $\mathit{l}$, for $\mathit{l}=1,2,\dots ,{\mathbf{maxlag}}$.
9:     pvalue[m] – doubleOutput
On exit: ${\mathbf{pvalue}}\left[\mathit{l}-1\right]$ contains the significance level of the corresponding ${\chi }^{2}$-statistic in x, for $\mathit{l}=1,2,\dots ,{\mathbf{maxlag}}$.
10:   fail – NagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

MATRIX_ILL_CONDITIONED
The recursive equations used to compute the partial lag correlation matrices are ill-conditioned (they have been computed up to lag $〈\mathit{\text{value}}〉$).
NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_BAD_PARAM
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_INT
On entry, ${\mathbf{k}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{k}}\ge 1$.
On entry, ${\mathbf{m}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{m}}\ge 1$.
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 2$.
NE_INT_2
On entry, ${\mathbf{m}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{m}}<{\mathbf{n}}$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.

## 7  Accuracy

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

## 8  Further Comments

The time taken is roughly proportional to ${m}^{2}{k}^{3}$.
If you have calculated the sample cross-correlation matrices in the arrays r0 and r, without calling nag_tsa_multi_cross_corr (g13dmc), then care must be taken to ensure they are supplied as described in Section 5. In particular, for $l\ge 1$, ${\stackrel{^}{R}}_{ij}\left(l\right)$ must contain the sample cross-correlation coefficient between ${w}_{i\left(t-l\right)}$ and ${w}_{jt}$.
The function nag_tsa_multi_auto_corr_part (g13dbc) 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 function with the argument 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 nag_tsa_multi_auto_corr_part (g13dbc). Note that this is the ‘Yule–Walker’ estimate. Unlike the partial lag correlation matrices computed by nag_tsa_multi_part_lag_corr (g13dnc), when ${W}_{t}$ follows an autoregressive model of order $s-1$, 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 cut-off point. The differences between these matrices are discussed further by Wei (1990).
Note that nag_tsa_multi_auto_corr_part (g13dbc) takes the sample cross-covariance matrices as input whereas this function requires the sample cross-correlation 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 (g13dnce.c)

### 9.2  Program Data

Program Data (g13dnce.d)

### 9.3  Program Results

Program Results (g13dnce.r)
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 105, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.7482621669769287, "perplexity_flag": "middle"}