g13 Chapter Contents
g13 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_tsa_multi_part_regsn (g13dpc)

## 1  Purpose

nag_tsa_multi_part_regsn (g13dpc) calculates the sample partial autoregression matrices of a multivariate time series. A set of likelihood ratio statistics and their significance levels are also returned. These quantities are useful for determining whether the series follows an autoregressive model and, if so, of what order.

## 2  Specification

 #include #include
 void nag_tsa_multi_part_regsn (Integer k, Integer n, const double z[], Integer m, Integer *maxlag, double parlag[], double se[], double qq[], double x[], double pvalue[], double loglhd[], 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 a vector of $k$ time series. The partial autoregression matrix at lag $l$, ${P}_{l}$, is defined to be the last matrix coefficient when a vector autoregressive model of order $l$ is fitted to the series. ${P}_{l}$ has the property that if ${W}_{t}$ follows a vector autoregressive model of order $p$ then ${P}_{l}=0$ for $l>p$.
Sample estimates of the partial autoregression matrices may be obtained by fitting autoregressive models of successively higher orders by multivariate least squares; see Tiao and Box (1981) and Wei (1990). These models are fitted using a $QR$ algorithm based on the functions nag_regsn_mult_linear_addrem_obs (g02dcc) and nag_regsn_mult_linear_delete_var (g02dfc). They are calculated up to lag $m$, which is usually taken to be at most $n/4$.
The function also returns the asymptotic standard errors of the elements of ${\stackrel{^}{P}}_{l}$ and an estimate of the residual variance-covariance matrix ${\stackrel{^}{\Sigma }}_{l}$, for $l=1,2,\dots ,m$. If ${S}_{l}$ denotes the residual sum of squares and cross-products matrix after fitting an $\text{AR}\left(l\right)$ model to the series then under the null hypothesis ${H}_{0}:{P}_{l}=0$ the test statistic
 $Xl= - n-m-1 -12-lk log Sl Sl-1$
is asymptotically distributed as ${\chi }^{2}$ with ${k}^{2}$ degrees of freedom. ${X}_{l}$ provides a useful diagnostic aid in determining the order of an autoregressive model. (Note that ${\stackrel{^}{\Sigma }}_{l}={S}_{l}/\left(n-l\right)$.) The function also returns an estimate of the maximum of the log-likelihood function for each AR model that has been fitted.

## 4  References

Tiao G C and Box G E P (1981) Modelling multiple time series with applications J. Am. Stat. Assoc. 76 802–816
Wei W W S (1990) Time Series Analysis: Univariate and Multivariate Methods Addison–Wesley

## 5  Arguments

1:     kIntegerInput
On entry: $k$, the number of time series.
Constraint: ${\mathbf{k}}\ge 1$.
2:     nIntegerInput
On entry: $n$, the number of observations in the time series.
Constraint: ${\mathbf{n}}\ge 4$.
3:     z[${\mathbf{k}}×{\mathbf{n}}$]const doubleInput
On entry: ${\mathbf{z}}\left[\left(\mathit{t}-1\right)k+\mathit{i}-1\right]$ must contain the value for the $\mathit{i}$th series at time $\mathit{t}$, for $\mathit{i}=1,2,\dots ,k$ and $\mathit{t}=1,2,\dots ,n$.
4:     mIntegerInput
On entry: $m$, the number of partial autoregression matrices to be computed. If in doubt set ${\mathbf{m}}=10$.
Constraint: ${\mathbf{m}}\ge 1$ and ${\mathbf{n}}-{\mathbf{m}}-\left({\mathbf{k}}×{\mathbf{m}}+1\right)\ge {\mathbf{k}}$.
5:     maxlagInteger *Output
On exit: the maximum lag up to which partial autoregression matrices (along with their likelihood ratio statistics and their significance levels) have been successfully computed. On a successful exit maxlag will equal m. If ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ MATRIX_ILL_CONDITIONED on exit then maxlag will be less than m.
6:     parlag[${\mathbf{k}}×{\mathbf{k}}×{\mathbf{m}}$]doubleOutput
On exit: ${\mathbf{parlag}}\left[\left(\mathit{l}-1\right){k}^{2}+\left(\mathit{j}-1\right)k+\mathit{i}-1\right]$ contains an estimate of the $\left(\mathit{i},\mathit{j}\right)$th element of the partial autoregression 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$.
7:     se[${\mathbf{k}}×{\mathbf{k}}×{\mathbf{m}}$]doubleOutput
On exit: ${\mathbf{se}}\left[\left(l-1\right){k}^{2}+\left(j-1\right)k+i-1\right]$ contains an estimate of the standard error of the corresponding element in parlag.
8:     qq[${\mathbf{k}}×{\mathbf{k}}×{\mathbf{m}}$]doubleOutput
On exit: ${\mathbf{qq}}\left[\left(\mathit{l}-1\right){k}^{2}+\left(\mathit{j}-1\right)k+\mathit{i}-1\right]$ contains an estimate of the $\left(\mathit{i},\mathit{j}\right)$th element of the residual variance-covariance matrix, ${\stackrel{^}{\Sigma }}_{\mathit{l}}$, for $\mathit{l}=1,2,\dots ,{\mathbf{maxlag}}$, $\mathit{i}=1,2,\dots ,k$ and $\mathit{j}=1,2,\dots ,k$.
9:     x[m]doubleOutput
On exit: ${\mathbf{x}}\left[\mathit{l}-1\right]$ contains ${X}_{\mathit{l}}$, the likelihood ratio statistic at lag $\mathit{l}$, for $\mathit{l}=1,2,\dots ,{\mathbf{maxlag}}$.
10:   pvalue[m]doubleOutput
On exit: ${\mathbf{pvalue}}\left[l-1\right]$ contains the significance level of the statistic in the corresponding element of x.
11:   loglhd[m]doubleOutput
On exit: ${\mathbf{loglhd}}\left[\mathit{l}-1\right]$ contains an estimate of the maximum of the log-likelihood function when an $\text{AR}\left(\mathit{l}-1\right)$ model has been fitted to the series, for $\mathit{l}=1,2,\dots ,{\mathbf{maxlag}}$.
12:   failNagError *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 autoregression matrices are ill-conditioned. They have been computed up to lag $⟨\mathit{\text{value}}⟩$.
NE_ALLOC_FAIL
Dynamic memory allocation failed.
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 4$.
NE_INT_3
On entry, ${\mathbf{k}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}-{\mathbf{m}}-\left({\mathbf{k}}×{\mathbf{m}}+1\right)\ge {\mathbf{k}}$.
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 computations are believed to be stable.

## 8  Parallelism and Performance

nag_tsa_multi_part_regsn (g13dpc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_tsa_multi_part_regsn (g13dpc) 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 is roughly proportional to $nmk$.
For each order of autoregressive model that has been estimated, nag_tsa_multi_part_regsn (g13dpc) returns the maximum of the log-likelihood function. An alternative means of choosing the order of a vector AR process is to choose the order for which Akaike's information criterion is smallest. That is, choose the value of $l$ for which $-2×{\mathbf{loglhd}}\left[l\right]+2l{k}^{2}$ is smallest. You should be warned that this does not always lead to the same choice of $l$ as indicated by the sample partial autoregression matrices and the likelihood ratio statistics.

## 10  Example

This example computes the sample partial autoregression matrices of two time series of length $48$ up to lag $10$.

### 10.1  Program Text

Program Text (g13dpce.c)

### 10.2  Program Data

Program Data (g13dpce.d)

### 10.3  Program Results

Program Results (g13dpce.r)