G13 Chapter Contents
G13 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG13DBF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

G13DBF calculates the multivariate partial autocorrelation function of a multivariate time series.

## 2  Specification

 SUBROUTINE G13DBF ( C0, C, LDC0, NS, NL, NK, P, V0, V, D, DB, W, WB, NVP, WA, IWA, IFAIL)
 INTEGER LDC0, NS, NL, NK, NVP, IWA, IFAIL REAL (KIND=nag_wp) C0(LDC0,NS), C(LDC0,LDC0,NL), P(NK), V0, V(NK), D(LDC0,LDC0,NK), DB(LDC0,NS), W(LDC0,LDC0,NK), WB(LDC0,LDC0,NK), WA(IWA)

## 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 G13DMF.
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  Parameters

1:     C0(LDC0,NS) – REAL (KIND=nag_wp) arrayInput
On entry: contains the zero lag cross-covariances between the NS series as returned by G13DMF. (C0 is assumed to be symmetric, upper triangle only is used.)
2:     C(LDC0,LDC0,NL) – REAL (KIND=nag_wp) arrayInput
On entry: contains the cross-covariances at lags $1$ to NL. ${\mathbf{C}}\left(i,j,k\right)$ must contain the cross-covariance, ${c}_{ijk}$, of series $i$ and series $j$ at lag $k$. Series $j$ leads series $i$.
3:     LDC0 – INTEGERInput
On entry: the first dimension of the arrays C0, C, D, DB, W and WB and the second dimension of the arrays C, D, W and WB as declared in the (sub)program from which G13DBF is called.
Constraint: ${\mathbf{LDC0}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{NS}},1\right)$.
4:     NS – INTEGERInput
On entry: $k$, the number of time series whose cross-covariances are supplied in C and C0.
Constraint: ${\mathbf{NS}}\ge 1$.
5:     NL – INTEGERInput
On entry: $m$, the maximum lag for which cross-covariances are supplied in C.
Constraint: ${\mathbf{NL}}\ge 1$.
6:     NK – INTEGERInput
On entry: the number of lags to which partial auto-correlations are to be calculated.
Constraint: $1\le {\mathbf{NK}}\le {\mathbf{NL}}$.
7:     P(NK) – REAL (KIND=nag_wp) arrayOutput
On exit: the multiple squared partial autocorrelations from lags $1$ to NVP; that is, ${\mathbf{P}}\left(l\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.
8:     V0 – REAL (KIND=nag_wp)Output
On exit: the lag zero prediction error variance (equal to the determinant of C0).
9:     V(NK) – REAL (KIND=nag_wp) arrayOutput
On exit: the prediction error variance ratios from lags $1$ to NVP; that is, ${\mathbf{V}}\left(\mathit{l}\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.
10:   D(LDC0,LDC0,NK) – REAL (KIND=nag_wp) arrayOutput
On exit: the prediction error variance matrices at lags $1$ to NVP.
Element $\left(i,j,\mathit{k}\right)$ of D contains the prediction error covariance of series $i$ and series $j$ at lag $\mathit{k}$, for $\mathit{k}=1,2,\dots ,{\mathbf{NVP}}$. Series $j$ leads series $i$; that is, the $\left(i,j\right)$th element of ${D}_{k}$. For lags ${\mathbf{NVP}}+1$ to NK the elements of D are set to zero.
11:   DB(LDC0,NS) – REAL (KIND=nag_wp) arrayOutput
On exit: the backward prediction error variance matrix at lag NVP.
${\mathbf{DB}}\left(i,j\right)$ contains the backward prediction error covariance of series $i$ and series $j$; that is, the $\left(i,j\right)$th element of the ${G}_{k}$, where $k={\mathbf{NVP}}$.
12:   W(LDC0,LDC0,NK) – REAL (KIND=nag_wp) arrayOutput
On exit: the prediction coefficient matrices at lags $1$ to NVP.
${\mathbf{W}}\left(i,j,\mathit{l}\right)$ contains the $j$th prediction coefficient of series $i$ at lag $\mathit{l}$; that is, the $\left(i,j\right)$th element of ${\Phi }_{k\mathit{l}}$, where $k={\mathbf{NVP}}$, for $\mathit{l}=1,2,\dots ,{\mathbf{NVP}}$. For lags ${\mathbf{NVP}}+1$ to NK the elements of W are set to zero.
13:   WB(LDC0,LDC0,NK) – REAL (KIND=nag_wp) arrayOutput
On exit: the backward prediction coefficient matrices at lags $1$ to NVP.
${\mathbf{WB}}\left(i,j,\mathit{l}\right)$ contains the $j$th backward prediction coefficient of series $i$ at lag $\mathit{l}$; that is, the $\left(i,j\right)$th element of ${\Psi }_{k\mathit{l}}$, where $k={\mathbf{NVP}}$, for $\mathit{l}=1,2,\dots ,{\mathbf{NVP}}$. For lags ${\mathbf{NVP}}+1$ to NK the elements of WB are set to zero.
14:   NVP – INTEGEROutput
On exit: the maximum lag, $L$, for which calculation of P, V, D, DB, W and WB was successful. If the routine completes successfully NVP will equal NK.
15:   WA(IWA) – REAL (KIND=nag_wp) arrayWorkspace
16:   IWA – INTEGERInput
On entry: the dimension of the array WA as declared in the (sub)program from which G13DBF is called.
Constraint: ${\mathbf{IWA}}\ge \left(2×{\mathbf{NS}}+1\right)×{\mathbf{NS}}$.
17:   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{LDC0}}<1$, or ${\mathbf{NS}}<1$, or ${\mathbf{NS}}>{\mathbf{LDC0}}$, or ${\mathbf{NL}}<1$, or ${\mathbf{NK}}<1$, or ${\mathbf{NK}}>{\mathbf{NL}}$, or ${\mathbf{IWA}}<\left(2×{\mathbf{NS}}+1\right)×{\mathbf{NS}}$.
${\mathbf{IFAIL}}=2$
C0 is not positive definite.
V0, V, P, D, DB, W, WB and NVP are set to zero.
${\mathbf{IFAIL}}=3$
At lag $k={\mathbf{NVP}}+1\le {\mathbf{NK}}$, ${D}_{k}$ was found not to be positive definite. Up to lag NVP, V0, V, P, D, W and WB contain the values calculated so far and from lag ${\mathbf{NVP}}+1$ to lag NK the matrices contain zero. DB contains the backward prediction coefficients for lag NVP.

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

The time taken by G13DBF 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 G13DMF, you must replace the diagonal elements of ${C}_{0}$ (otherwise used to hold the series variances) by $1$.

## 9  Example

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

### 9.1  Program Text

Program Text (g13dbfe.f90)

### 9.2  Program Data

Program Data (g13dbfe.d)

### 9.3  Program Results

Program Results (g13dbfe.r)