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_regmat_partial (g13dp)

## Purpose

nag_tsa_multi_regmat_partial (g13dp) 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.

## Syntax

[maxlag, parlag, se, qq, x, pvalue, loglhd, ifail] = g13dp(k, z, m, 'n', n)
[maxlag, parlag, se, qq, x, pvalue, loglhd, ifail] = nag_tsa_multi_regmat_partial(k, z, m, 'n', n)

## 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 a vector of k$k$ time series. The partial autoregression matrix at lag l$l$, Pl${P}_{l}$, is defined to be the last matrix coefficient when a vector autoregressive model of order l$l$ is fitted to the series. Pl${P}_{l}$ has the property that if Wt${W}_{t}$ follows a vector autoregressive model of order p$p$ then Pl = 0${P}_{l}=0$ for l > p$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$QR$ algorithm based on the functions nag_correg_linregm_obs_edit (g02dc) and nag_correg_linregm_var_del (g02df). They are calculated up to lag m$m$, which is usually taken to be at most n / 4$n/4$.
The function also returns the asymptotic standard errors of the elements of l${\stackrel{^}{P}}_{l}$ and an estimate of the residual variance-covariance matrix Σ̂l${\stackrel{^}{\Sigma }}_{l}$, for l = 1,2,,m$l=1,2,\dots ,m$. If Sl${S}_{l}$ denotes the residual sum of squares and cross-products matrix after fitting an AR(l)$\text{AR}\left(l\right)$ model to the series then under the null hypothesis H0 : Pl = 0${H}_{0}:{P}_{l}=0$ the test statistic
 Xl = − ((n − m − 1) − (1/2) − lk) log((|Sl|)/(|Sl − 1|)) $Xl= - ( (n-m-1) -12-lk ) log( |Sl| |Sl-1| )$
is asymptotically distributed as χ2${\chi }^{2}$ with k2${k}^{2}$ degrees of freedom. Xl${X}_{l}$ provides a useful diagnostic aid in determining the order of an autoregressive model. (Note that Σ̂l = Sl / (nl)${\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.

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

## Parameters

### Compulsory Input Parameters

1:     k – int64int32nag_int scalar
k$k$, the number of time series.
Constraint: k1${\mathbf{k}}\ge 1$.
2:     z(kmax,n) – double array
kmax, the first dimension of the array, must satisfy the constraint kmaxk$\mathit{kmax}\ge {\mathbf{k}}$.
z(i,t)${\mathbf{z}}\left(\mathit{i},\mathit{t}\right)$ must contain the observation wit${w}_{\mathit{i}\mathit{t}}$, for i = 1,2,,k$\mathit{i}=1,2,\dots ,k$ and t = 1,2,,n$\mathit{t}=1,2,\dots ,n$.
3:     m – int64int32nag_int scalar
m$m$, the number of partial autoregression matrices to be computed. If in doubt set m = 10${\mathbf{m}}=10$.
Constraint: m1${\mathbf{m}}\ge 1$ and nm(k × m + 1)k${\mathbf{n}}-{\mathbf{m}}-\left({\mathbf{k}}×{\mathbf{m}}+1\right)\ge {\mathbf{k}}$.

### Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The second dimension of the array z.
n$n$, the number of observations in the time series.
Constraint: n4${\mathbf{n}}\ge 4$.

### Input Parameters Omitted from the MATLAB Interface

kmax work lwork iwork

### Output Parameters

1:     maxlag – int64int32nag_int scalar
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{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 an estimate of the (i,j)$\left(i,j\right)$th element of the partial autoregression matrix at lag l$l$, l(ij)${\stackrel{^}{P}}_{l}\left(ij\right)$, for l = 1,2,,maxlag$l=1,2,\dots ,{\mathbf{maxlag}}$, i = 1,2,,k$i=1,2,\dots ,k$ and j = 1,2,,k$j=1,2,\dots ,k$.
3:     se(kmax,kmax,m) – double array
kmaxk$\mathit{kmax}\ge {\mathbf{k}}$.
se(i,j,l)${\mathbf{se}}\left(i,j,l\right)$ contains an estimate of the standard error of the corresponding element in the array parlag.
4:     qq(kmax,kmax,m) – double array
kmaxk$\mathit{kmax}\ge {\mathbf{k}}$.
qq(i,j,l)${\mathbf{qq}}\left(\mathit{i},\mathit{j},\mathit{l}\right)$ contains an estimate of the (i,j)$\left(\mathit{i},\mathit{j}\right)$th element of the corresponding variance-covariance matrix Σ̂l${\stackrel{^}{\Sigma }}_{\mathit{l}}$, 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$.
5:     x(m) – double array
x(l)${\mathbf{x}}\left(\mathit{l}\right)$ contains Xl${X}_{\mathit{l}}$, the likelihood ratio statistic at lag l$\mathit{l}$, for l = 1,2,,maxlag$\mathit{l}=1,2,\dots ,{\mathbf{maxlag}}$.
6:     pvalue(m) – double array
pvalue(l)${\mathbf{pvalue}}\left(l\right)$ contains the significance level of the statistic in the corresponding element of x.
7:     loglhd(m) – double array
loglhd(l)${\mathbf{loglhd}}\left(\mathit{l}\right)$ contains an estimate of the maximum of the log-likelihood function when an AR(l)$\text{AR}\left(\mathit{l}\right)$ model has been fitted to the series, for l = 1,2,,maxlag$\mathit{l}=1,2,\dots ,{\mathbf{maxlag}}$.
8:     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 < 4${\mathbf{n}}<4$, or kmax < k$\mathit{kmax}<{\mathbf{k}}$, or m < 1${\mathbf{m}}<1$, or n − m − (k × m + 1) < k${\mathbf{n}}-{\mathbf{m}}-\left({\mathbf{k}}×{\mathbf{m}}+1\right)<{\mathbf{k}}$, or lwork is too small.
W ifail = 2${\mathbf{ifail}}=2$
The recursive equations used to compute the sample partial autoregression matrices have broken down at lag maxlag + 1${\mathbf{maxlag}}+1$. This exit could occur if the regression model is overparameterised. For your settings of k$k$ and n$n$ the value returned by maxlag is the largest permissible value of m$m$ for which the model is not overparameterised. All output quantities in the arrays parlag, se, qq, x, pvalue and loglhd up to and including lag maxlag will be correct.

## Accuracy

The computations are believed to be stable.

The time taken is roughly proportional to nmk$nmk$.
For each order of autoregressive model that has been estimated, nag_tsa_multi_regmat_partial (g13dp) 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$l$ for which 2 × loglhd(l) + 2lk2$-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$l$ as indicated by the sample partial autoregression matrices and the likelihood ratio statistics.

## Example

```function nag_tsa_multi_regmat_partial_example
k = int64(2);
z = [-1.49, -1.62, 5.2, 6.23, 6.21, 5.86, 4.09, 3.18, 2.62, 1.49, 1.17, ...
0.85, -0.35, 0.24, 2.44, 2.58, 2.04, 0.4, 2.26, 3.34, 5.09, 5, 4.78, ...
4.11, 3.45, 1.65, 1.29, 4.09, 6.32, 7.5, 3.89, 1.58, 5.21, 5.25, 4.93, ...
7.38, 5.87, 5.81, 9.68, 9.07, 7.29, 7.84, 7.55, 7.32, 7.97, 7.76, 7, 8.35;
7.34, 6.35, 6.96, 8.54, 6.62, 4.97, 4.55, 4.81, 4.75, ...
4.76, 10.88, 10.01, 11.62, 10.36, 6.4, 6.24, 7.93, 4.04, 3.73, 5.6, ...
5.35, 6.81, 8.27, 7.68, 6.65, 6.08, 10.25, 9.14, 17.75, 13.3, ...
9.63, 6.8, 4.08, 5.06, 4.94, 6.65, 7.94, 10.76, 11.89, ...
5.85, 9.01, 7.5, 10.02, 10.38, 8.15, 8.37, 10.73, 12.14];
m = int64(10);
[maxlag, parlag, se, qq, x, pvalue, loglhd, ifail] = nag_tsa_multi_regmat_partial(k, z, m);
maxlag, x, pvalue, loglhd, ifail
```
```

maxlag =

10

x =

49.8836
3.3467
13.9619
7.0706
5.1838
2.0826
5.0744
10.9907
3.9365
3.1748

pvalue =

0.0000
0.5016
0.0074
0.1322
0.2690
0.7206
0.2797
0.0267
0.4147
0.5290

loglhd =

-196.2102
-190.6563
-177.2009
-168.7939
-161.7405
-157.1822
-149.8045
-136.4157
-129.8435
-123.8453

ifail =

0

```
```function g13dp_example
k = int64(2);
z = [-1.49, -1.62, 5.2, 6.23, 6.21, 5.86, 4.09, 3.18, 2.62, 1.49, 1.17, ...
0.85, -0.35, 0.24, 2.44, 2.58, 2.04, 0.4, 2.26, 3.34, 5.09, 5, 4.78, ...
4.11, 3.45, 1.65, 1.29, 4.09, 6.32, 7.5, 3.89, 1.58, 5.21, 5.25, 4.93, ...
7.38, 5.87, 5.81, 9.68, 9.07, 7.29, 7.84, 7.55, 7.32, 7.97, 7.76, 7, 8.35;
7.34, 6.35, 6.96, 8.54, 6.62, 4.97, 4.55, 4.81, 4.75, ...
4.76, 10.88, 10.01, 11.62, 10.36, 6.4, 6.24, 7.93, 4.04, 3.73, 5.6, ...
5.35, 6.81, 8.27, 7.68, 6.65, 6.08, 10.25, 9.14, 17.75, 13.3, ...
9.63, 6.8, 4.08, 5.06, 4.94, 6.65, 7.94, 10.76, 11.89, ...
5.85, 9.01, 7.5, 10.02, 10.38, 8.15, 8.37, 10.73, 12.14];
m = int64(10);
[maxlag, parlag, se, qq, x, pvalue, loglhd, ifail] = g13dp(k, z, m);
maxlag, x, pvalue, loglhd, ifail
```
```

maxlag =

10

x =

49.8836
3.3467
13.9619
7.0706
5.1838
2.0826
5.0744
10.9907
3.9365
3.1748

pvalue =

0.0000
0.5016
0.0074
0.1322
0.2690
0.7206
0.2797
0.0267
0.4147
0.5290

loglhd =

-196.2102
-190.6563
-177.2009
-168.7939
-161.7405
-157.1822
-149.8045
-136.4157
-129.8435
-123.8453

ifail =

0

```