g13 Chapter Contents
g13 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_tsa_multi_auto_corr_part (g13dbc)

## 1  Purpose

nag_tsa_multi_auto_corr_part (g13dbc) calculates the multivariate partial autocorrelation function of a multivariate time series.

## 2  Specification

 #include #include
 void nag_tsa_multi_auto_corr_part (const double c0[], const double c[], Integer ns, Integer nl, Integer nk, double p[], double *v0, double v[], double d[], double db[], double w[], double wb[], Integer *nvp, NagError *fail)

## 3  Description

The input is a set of lagged autocovariance matrices ${C}_{0},{C}_{1},{C}_{2},\dots ,{C}_{m}$. These will generally be sample values such as are obtained from a multivariate time series using nag_tsa_multi_cross_corr (g13dmc).
The main calculation is the recursive determination of the coefficients in the finite lag (forward) prediction equation
 $xt = Φl,1 xt-1 +⋯+ Φl,l xt-l + el,t$
and the associated backward prediction equation
 $xt-l- 1=Ψl,1xt-l+⋯+Ψl,lxt- 1+fl,t$
together with the covariance matrices ${D}_{l}$ of ${e}_{l,t}$ and ${G}_{l}$ of ${f}_{l,t}$.
The recursive cycle, by which the order of the prediction equation is extended from $l$ to $l+1$, is to calculate
 $Ml+1 = Cl+1T - Φ l,1 ClT -⋯- Φl,l C1T$ (1)
then ${\Phi }_{l+1,l+1}={M}_{l+1}{D}_{l}^{-1}$, $\text{ }{\Psi }_{l+1,l+1}={{M}^{\mathrm{T}}}_{l+1}{G}_{l}^{-1}$
from which
 $Φl+1,j=Φl,j-Φl+1,l+1Ψl,l+1-j, j=1,2,…,l$ (2)
and
 $Ψl+1,j=Ψl,j-Ψl+1,l+1Φl,l+1-j, j=1,2,…,l.$ (3)
Finally, ${D}_{l+1}={D}_{l}-{M}_{l+1}{{\Phi }^{\mathrm{T}}}_{l+1,l+1}$ and ${G}_{l+1}={G}_{l}-{{M}^{\mathrm{T}}}_{l+1}{{\Psi }^{\mathrm{T}}}_{l+1,l+1}$.
(Here $\mathrm{T}$ denotes the transpose of a matrix.)
The cycle is initialized by taking (for $l=0$)
 $D0=G0=C0.$
In the step from $l=0$ to $1$, the above equations contain redundant terms and simplify. Thus (1) becomes ${M}_{1}={{C}^{\mathrm{T}}}_{1}$ and neither (2) or (3) are needed.
Quantities useful in assessing the effectiveness of the prediction equation are generalized variance ratios
 $vl = det⁡Dl / det⁡C0 , l=1,2,…$
and multiple squared partial autocorrelations
 $pl2 = 1 - vl / v l-1 .$

## 4  References

Akaike H (1971) Autoregressive model fitting for control Ann. Inst. Statist. Math. 23 163–180
Whittle P (1963) On the fitting of multivariate autoregressions and the approximate canonical factorization of a spectral density matrix Biometrika 50 129–134

## 5  Arguments

1:     c0[${\mathbf{ns}}×{\mathbf{ns}}$]const doubleInput
On entry: contains the zero lag cross-covariances between the ns series as returned by nag_tsa_multi_cross_corr (g13dmc). (c0 is assumed to be symmetric, upper triangle only is used.)
2:     c[${\mathbf{ns}}×{\mathbf{ns}}×{\mathbf{nl}}$]const doubleInput
On entry: the $k$ cross-covariances as returned by nag_tsa_multi_cross_corr (g13dmc).
3:     nsIntegerInput
On entry: $k$, the number of time series whose cross-covariances are supplied in c and c0.
Constraint: ${\mathbf{ns}}\ge 1$.
4:     nlIntegerInput
On entry: $m$, the maximum lag for which cross-covariances are supplied in c.
Constraint: ${\mathbf{nl}}\ge 1$.
5:     nkIntegerInput
On entry: the number of lags to which partial auto-correlations are to be calculated.
Constraint: $1\le {\mathbf{nk}}\le {\mathbf{nl}}$.
6:     p[nk]doubleOutput
On exit: the multiple squared partial autocorrelations from lags $1$ to nvp; that is, ${\mathbf{p}}\left[l-1\right]$ contains ${p}_{\mathit{l}}^{2}$, for $\mathit{l}=1,2,\dots ,{\mathbf{nvp}}$. For lags ${\mathbf{nvp}}+1$ to nk the elements of p are set to zero.
7:     v0double *Output
On exit: the lag zero prediction error variance (equal to the determinant of c0).
8:     v[nk]doubleOutput
On exit: the prediction error variance ratios from lags $1$ to nvp; that is, ${\mathbf{v}}\left[\mathit{l}-1\right]$ contains ${v}_{\mathit{l}}$, for $\mathit{l}=1,2,\dots ,{\mathbf{nvp}}$. For lags ${\mathbf{nvp}}+1$ to nk the elements of v are set to zero.
9:     d[${\mathbf{ns}}×{\mathbf{ns}}×{\mathbf{nk}}$]doubleOutput
On exit: the prediction error variance matrices at lags $1$ to nvp, ${\mathbf{d}}\left[\left(l-1\right){k}^{2}+\left(j-1\right)k+i-1\right]$ contains the $\left(i,j\right)$th prediction error covariance of series $i$ and series $j$ at lag $l$. Series $j$ leads series $i$.
10:   db[${\mathbf{ns}}×{\mathbf{ns}}$]doubleOutput
On exit: the backward prediction error variance matrix at lag nvp, ${\mathbf{db}}\left[\left(j-1\right)k+i-1\right]$ contains the backward prediction error covariance of series $i$ and series $j$.
11:   w[${\mathbf{ns}}×{\mathbf{ns}}×{\mathbf{nk}}$]doubleOutput
On exit: the prediction coefficient matrices at lags $1$ to nvp, ${\mathbf{w}}\left[\left(l-1\right){k}^{2}+\left(j-1\right)k+i-1\right]$ contains the $j$th prediction coefficient of series $i$ at lag $l$ (i.e., the $\left(i,j\right)$th element of ${\Phi }_{L,l}$).
12:   wb[${\mathbf{ns}}×{\mathbf{ns}}×{\mathbf{nk}}$]doubleOutput
On exit: the backward prediction coefficient matrices at lags $1$ to nvp, ${\mathbf{wb}}\left[\left(l-1\right){k}^{2}+\left(j-1\right)+i-1\right]$ contains the $j$th backward prediction coefficient of series $i$ at lag $l$ (i.e., the $\left(i,j\right)$th element of ${\Psi }_{L,l}$).
13:   nvpInteger *Output
On exit: the maximum lag, $L$, for which calculation of p, v, d, db, w and wb was successful. If the function completes successfully nvp will equal nk.
14:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_INT
On entry, ${\mathbf{nk}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nk}}\ge 1$.
On entry, ${\mathbf{nl}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nl}}\ge 1$.
On entry, ${\mathbf{ns}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ns}}\ge 1$.
NE_INT_2
On entry, ${\mathbf{nk}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{nl}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nk}}\le {\mathbf{nl}}$.
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.
NE_POS_DEF
At lag ${\mathbf{nvp}}+1\le {\mathbf{nk}}$, d is not positive definite, ${\mathbf{nvp}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{nk}}=⟨\mathit{\text{value}}⟩$.
c0 is not positive definite.

## 7  Accuracy

The conditioning of the problem depends on the prediction error variance ratios. Very small values of these may indicate loss of accuracy in the computations.

## 8  Parallelism and Performance

nag_tsa_multi_auto_corr_part (g13dbc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_tsa_multi_auto_corr_part (g13dbc) 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.

The time taken by nag_tsa_multi_auto_corr_part (g13dbc) is roughly proportional to ${{\mathbf{nk}}}^{2}×{{\mathbf{ns}}}^{3}$.
If sample autocorrelation matrices are used as input, then the output will be relevant to the original series scaled by their standard deviations. If these autocorrelation matrices are produced by nag_tsa_multi_cross_corr (g13dmc), you must replace the diagonal elements of ${C}_{0}$ (otherwise used to hold the series variances) by $1$.

## 10  Example

This example reads the autocovariance matrices for four series from lag $0$ to $5$. It calls nag_tsa_multi_auto_corr_part (g13dbc) to calculate the multivariate partial autocorrelation function and other related matrices of statistics up to lag $3$. It prints the results.

### 10.1  Program Text

Program Text (g13dbce.c)

### 10.2  Program Data

Program Data (g13dbce.d)

### 10.3  Program Results

Program Results (g13dbce.r)