NAG CL Interface
g13dpc (multi_​regmat_​partial)

Settings help

CL Name Style:


1 Purpose

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 <nag.h>
void  g13dpc (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)
The function may be called by the names: g13dpc, nag_tsa_multi_regmat_partial or nag_tsa_multi_part_regsn.

3 Description

Let Wt = (w1t,w2t,,wkt) T , for t=1,2,,n, denote a vector of k time series. The partial autoregression matrix at lag l, Pl, is defined to be the last matrix coefficient when a vector autoregressive model of order l is fitted to the series. Pl has the property that if Wt follows a vector autoregressive model of order p then Pl=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 g02dcc and 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 P^l and an estimate of the residual variance-covariance matrix Σ^l, for l=1,2,,m. If Sl denotes the residual sum of squares and cross-products matrix after fitting an AR(l) model to the series then under the null hypothesis H0:Pl=0 the test statistic
Xl= - ((n-m-1)-12-lk) log( |Sl| |Sl-1| )  
is asymptotically distributed as χ2 with k2 degrees of freedom. Xl provides a useful diagnostic aid in determining the order of an autoregressive model. (Note that Σ^l=Sl/(n-l).) 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: k Integer Input
On entry: k, the number of time series.
Constraint: k1.
2: n Integer Input
On entry: n, the number of observations in the time series.
Constraint: n4.
3: z[k×n] const double Input
On entry: z[(t-1)k+i-1] must contain the value for the ith series at time t, for i=1,2,,k and t=1,2,,n.
4: m Integer Input
On entry: m, the number of partial autoregression matrices to be computed. If in doubt set m=10.
Constraint: m1 and n-m-(k×m+1)k.
5: maxlag Integer * 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 fail.code= MATRIX_ILL_CONDITIONED on exit then maxlag will be less than m.
6: parlag[k×k×m] double Output
On exit: parlag[(l-1)k2+(j-1)k+i-1] contains an estimate of the (i,j)th element of the partial autoregression matrix at lag l, for l=1,2,,maxlag, i=1,2,,k and j=1,2,,k.
7: se[k×k×m] double Output
On exit: se[(l-1)k2+(j-1)k+i-1] contains an estimate of the standard error of the corresponding element in parlag.
8: qq[k×k×m] double Output
On exit: qq[(l-1)k2+(j-1)k+i-1] contains an estimate of the (i,j)th element of the residual variance-covariance matrix, Σ^l, for l=1,2,,maxlag, i=1,2,,k and j=1,2,,k.
9: x[m] double Output
On exit: x[l-1] contains Xl, the likelihood ratio statistic at lag l, for l=1,2,,maxlag.
10: pvalue[m] double Output
On exit: pvalue[l-1] contains the significance level of the statistic in the corresponding element of x.
11: loglhd[m] double Output
On exit: loglhd[l-1] contains an estimate of the maximum of the log-likelihood function when an AR(l-1) model has been fitted to the series, for l=1,2,,maxlag.
12: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

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 value. All output quantities in the arrays parlag, se, qq, x, pvalue and loglhd up to and including lag maxlag will be correct. For your settings of k and n the value returned in maxlag is the largest permissible value of m for which the model is not overparameterised.
NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INT
On entry, k=value.
Constraint: k1.
On entry, m=value.
Constraint: m1.
On entry, n=value.
Constraint: n4.
NE_INT_3
On entry, k=value, m=value and n=value.
Constraint: n-m-(k×m+1)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.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.

7 Accuracy

The computations are believed to be stable.

8 Parallelism and Performance

g13dpc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
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.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9 Further Comments

The time taken is roughly proportional to nmk.
For each order of autoregressive model that has been estimated, 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×loglhd[l]+2lk2 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)