hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_tsa_multi_varma_diag (g13ds)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_tsa_multi_varma_diag (g13ds) is a diagnostic checking function suitable for use after fitting a vector ARMA model to a multivariate time series using nag_tsa_multi_varma_estimate (g13dd). The residual cross-correlation matrices are returned along with an estimate of their asymptotic standard errors and correlations. Also, nag_tsa_multi_varma_diag (g13ds) calculates the modified Li–McLeod portmanteau statistic and its significance level for testing model adequacy.

Syntax

[qq, r0, r, rcm, chi, idf, siglev, ifail] = g13ds(v, ip, iq, m, par, parhld, qq, ishow, 'k', k, 'n', n)
[qq, r0, r, rcm, chi, idf, siglev, ifail] = nag_tsa_multi_varma_diag(v, ip, iq, m, par, parhld, qq, ishow, 'k', k, 'n', n)

Description

Let Wt = w1t,w2t,,wktT , for t=1,2,,n, denote a vector of k time series which is assumed to follow a multivariate ARMA model of the form
Wt-μ= ϕ1Wt-1-μ+ϕ2Wt-2-μ++ϕpWt-p-μ +εt-θ1εt-1-θ2εt-2--θqεt-q, (1)
where εt = ε1t,ε2t,,εktT , for t=1,2,,n, is a vector of k residual series assumed to be Normally distributed with zero mean and positive definite covariance matrix Σ. The components of εt are assumed to be uncorrelated at non-simultaneous lags. The ϕi and θj are k by k matrices of parameters. ϕi, for i=1,2,,p, are called the autoregressive (AR) parameter matrices, and θi, for i=1,2,,q, the moving average (MA) parameter matrices. The parameters in the model are thus the p (k by k) ϕ-matrices, the q (k by k) θ-matrices, the mean vector μ and the residual error covariance matrix Σ. Let
Aϕ= ϕ1 I 0 . . . 0 ϕ2 0 I 0 . . 0 . . . . . . ϕp-1 0 . . . 0 I ϕp 0 . . . 0 0 pk×pk   and  Bθ= θ1 I 0 . . . 0 θ2 0 I 0 . . 0 . . . . . . θq-1 0 . . . I θq 0 . . . . 0 qk×qk  
where I denotes the k by k identity matrix.
The ARMA model (1) is said to be stationary if the eigenvalues of Aϕ lie inside the unit circle, and invertible if the eigenvalues of Bθ lie inside the unit circle. The ARMA model is assumed to be both stationary and invertible. Note that some of the elements of the ϕ- and/or θ-matrices may have been fixed at pre-specified values (for example by calling nag_tsa_multi_varma_estimate (g13dd)).
The estimated residual cross-correlation matrix at lag l is defined to the k by k matrix R^l whose i,jth element is computed as
r ^ i j l = t = l + 1 n ε ^ i t - l - ε - i ε ^ j t - ε - j t = 1 n ε ^ i t - ε - i 2 t = 1 n ε ^ j t - ε - j 2 ,   l =0,1,,i​ and ​j=1,2,,k ,  
where ε^it denotes an estimate of the tth residual for the ith series εit and ε-i=t=1nε^it/n. (Note that R^l is an estimate of Eεt-lεtT, where E is the expected value.)
A modified portmanteau statistic, Q m *, is calculated from the formula (see Li and McLeod (1981))
Qm * = k2 mm+1 2n + n l=1 m r^ lT R^ 0 -1 R^ 0 -1 r^ l ,  
where  denotes Kronecker product, R^0 is the estimated residual cross-correlation matrix at lag zero and r^l=vec R^lT , where vec of a k by k matrix is a vector with the i,jth element in position i-1k+j. m denotes the number of residual cross-correlation matrices computed. (Advice on the choice of m is given in Choice of .) Let lC denote the total number of ‘free’ parameters in the ARMA model excluding the mean, μ, and the residual error covariance matrix Σ. Then, under the hypothesis of model adequacy, Q m *, has an asymptotic χ2-distribution on mk2-lC degrees of freedom.
Let r^̲=vec R1T ,vec R2T ,,vec RmT  then the covariance matrix of r^̲ is given by
Varr̲^=Y-XXTGGTX-1XT/n,  
where Y=ImΔΔ and G=ImGGT. Δ is the dispersion matrix Σ in correlation form and G a nonsingular k by k matrix such that GGT=Δ-1 and GΔGT=Ik. The construction of the matrix X is discussed in Li and McLeod (1981). (Note that the mean, μ, plays no part in calculating Varr̲^ and therefore is not required as input to nag_tsa_multi_varma_diag (g13ds).)

References

Li W K and McLeod A I (1981) Distribution of the residual autocorrelations in multivariate ARMA time series models J. Roy. Statist. Soc. Ser. B 43 231–239

Parameters

The output quantities k, n, v, kmax, ip, iq, par, parhld and qq from nag_tsa_multi_varma_estimate (g13dd) are suitable for input to nag_tsa_multi_varma_diag (g13ds).

Compulsory Input Parameters

1:     vkmaxn – double array
kmax, the first dimension of the array, must satisfy the constraint kmaxk.
vit must contain an estimate of the ith component of εt, for i=1,2,,k and t=1,2,,n.
Constraints:
  • no two rows of v may be identical;
  • in each row there must be at least two distinct elements.
2:     ip int64int32nag_int scalar
p, the number of AR parameter matrices.
Constraint: ip0.
3:     iq int64int32nag_int scalar
q, the number of MA parameter matrices.
Constraint: iq0.
Note: ip=iq=0 is not permitted.
4:     m int64int32nag_int scalar
The value of m, the number of residual cross-correlation matrices to be computed. See Choice of for advice on the choice of m.
Constraint: ip+iq<m<n.
5:     parip+iq×k×k – double array
The parameter estimates read in row by row in the order ϕ1,ϕ2,,ϕp, θ1,θ2,,θq.
Thus,
  • if ip>0, parl-1×k×k+i-1×k+j must be set equal to an estimate of the i,jth element of ϕl, for l=1,2,,p and i=1,2,,k;
  • if iq0, parp×k×k+l-1×k×k+i-1×k+j must be set equal to an estimate of the i,jth element of θl, for l=1,2,,q and i=1,2,,k.
The first p×k×k elements of par must satisfy the stationarity condition and the next q×k×k elements of par must satisfy the invertibility condition.
6:     parhldip+iq×k×k – logical array
parhldi must be set to true if pari has been held constant at a pre-specified value and false if pari is a free parameter, for i=1,2,,p+q×k×k.
7:     qqkmaxk – double array
kmax, the first dimension of the array, must satisfy the constraint kmaxk.
qqij is an efficient estimate of the i,jth element of Σ. The lower triangle only is needed.
Constraint: qq must be positive definite.
8:     ishow int64int32nag_int scalar
Must be nonzero if the residual cross-correlation matrices r^ijl and their standard errors ser^ijl, the modified portmanteau statistic with its significance and a summary table are to be printed. The summary table indicates which elements of the residual correlation matrices are significant at the 5% level in either a positive or negative direction; i.e., if r^ijl>1.96×ser^ijl then a ‘+’ is printed, if r^ijl<-1.96×ser^ijl then a ‘-’ is printed, otherwise a fullstop (.) is printed. The summary table is only printed if k6 on entry.
The residual cross-correlation matrices, their standard errors and the modified portmanteau statistic with its significance are available also as output variables in r, rcm, chi, idf and siglev.

Optional Input Parameters

1:     k int64int32nag_int scalar
Default: the first dimension of the arrays v, qq and the second dimension of the array qq. (An error is raised if these dimensions are not equal.)
k, the number of residual time series.
Constraint: k1.
2:     n int64int32nag_int scalar
Default: the second dimension of the array v.
n, the number of observations in each residual series.

Output Parameters

1:     qqkmaxk – double array
If ifail1, then the upper triangle is set equal to the lower triangle.
2:     r0kmaxk – double array
If ij, then r0ij contains an estimate of the i,jth element of the residual cross-correlation matrix at lag zero, R^0. When i=j, r0ij contains the standard deviation of the ith residual series. If ifail=3 on exit then the first k rows and columns of r0 are set to zero.
3:     rkmaxkmaxm – double array
rlij is an estimate of the i,jth element of the residual cross-correlation matrix at lag l, for i=1,2,,k, j=1,2,,k and l=1,2,,m. If ifail=3 on exit then all elements of r are set to zero.
4:     rcmldrcmm×k×k – double array
The estimated standard errors and correlations of the elements in the array r. The correlation between rlij and rl2i2j2 is returned as rcmst where s=l-1×k×k+j-1×k+i and t=l2-1×k×k+j2-1×k+i2 except that if s=t, then rcmst contains the standard error of rlij. If on exit, ifail5, then all off-diagonal elements of rcm are set to zero and all diagonal elements are set to 1/n.
5:     chi – double scalar
The value of the modified portmanteau statistic, Q m *. If ifail=3 on exit then chi is returned as zero.
6:     idf int64int32nag_int scalar
The number of degrees of freedom of chi.
7:     siglev – double scalar
The significance level of chi based on idf degrees of freedom. If ifail=3 on exit, siglev is returned as one.
8:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Note: nag_tsa_multi_varma_diag (g13ds) may return useful information for one or more of the following detected errors or 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
On entry,k<1,
orkmax<k,
orip<0,
oriq<0,
orip=iq=0,
ormip+iq,
ormn,
orldrcm<m×k×k,
orliw is too small,
orlwork is too small.
   ifail=2
On entry, either qq is not positive definite or the autoregressive parameter matrices are extremely close to or outside the stationarity region, or the moving average parameter matrices are extremely close to or outside the invertibility region. To proceed, you must supply different parameter estimates in the arrays par and qq.
W  ifail=3
On entry, at least one of the k residual series is such that all its elements are practically identical giving zero (or near zero) variance or at least two of the residual series are identical. In this case chi is set to zero, siglev to one and all the elements of r0 and r set to zero.
   ifail=4
This is an unlikely exit brought about by an excessive number of iterations being needed to evaluate the zeros of the determinantal polynomials detAϕ and detBθ. All output arguments are undefined.
   ifail=5
On entry, either the eigenvalues and eigenvectors of Δ (the matrix qq in correlation form) could not be computed or the determinantal polynomials detAϕ and detBθ have a factor in common. To proceed, you must either supply different parameter estimates in the array qq or delete this common factor from the model. In this case, the off-diagonal elements of rcm are returned as zero and the diagonal elements set to 1/n. All other output quantities will be correct.
   ifail=6
This is an unlikely exit. At least one of the diagonal elements of rcm was found to be either negative or zero. In this case all off-diagonal elements of rcm are returned as zero and all diagonal elements of rcm set to 1/n.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

The computations are believed to be stable.

Further Comments

Timing

The time taken by nag_tsa_multi_varma_diag (g13ds) depends upon the number of residual cross-correlation matrices to be computed, m, and the number of time series, k.

Choice of m

The number of residual cross-correlation matrices to be computed, m, should be chosen to ensure that when the ARMA model (1) is written as either an infinite order autoregressive process, i.e.,
Wt-μ=j=1πjWt-j-μ+εt  
or as an infinite order moving average process, i.e.,
Wt-μ=j= 1ψjεt-j+εt  
then the two sequences of k by k matrices π1,π2, and ψ1,ψ2, are such that πj and ψj are approximately zero for j>m. An overestimate of m is therefore preferable to an under-estimate of m. In many instances the choice m=10 will suffice. In practice, to be on the safe side, you should try setting m=20.

Checking a ‘White Noise’ Model

If you have fitted the ‘white noise’ model
Wt-μ=εt  
then nag_tsa_multi_varma_diag (g13ds) should be entered with p=1, q=0, and the first k2 elements of par and parhld set to zero and true respectively.

Approximate Standard Errors

When ifail=5 or 6 all the standard errors in rcm are set to 1/n. This is the asymptotic standard error of r^ijl when all the autoregressive and moving average parameters are assumed to be known rather than estimated.

Alternative Tests

R^0 is useful in testing for instantaneous causality. If you wish to carry out a likelihood ratio test then the covariance matrix at lag zero C^0 can be used. It can be recovered from R^0 by setting
C^0i,j =R^0i,j×R^0i,i×R^0j,j, for ​ij =R^0i,j×R^0i,j, for ​i=j  

Example

This example fits a bivariate AR(1) model to two series each of length 48. μ has been estimated but ϕ12,1 has been constrained to be zero. Ten residual cross-correlation matrices are to be computed.
function g13ds_example


fprintf('g13ds example results\n\n');

w = [ -1.49 -1.62  5.20  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.40  2.26  3.34 ...
       5.09  5.00  4.78  4.11  3.45  1.65  1.29  4.09  6.32  7.50 ...
       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.00  8.350;
       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.40  6.24  7.93  4.04  3.73  5.60 ...
       5.35  6.81  8.27  7.68  6.65  6.08 10.25  9.14 17.75 13.30 ...
       9.63  6.80  4.08  5.06  4.94  6.65  7.94 10.76 11.89  5.85 ...
       9.01  7.50 10.02 10.38  8.15  8.37 10.73 12.14];

[k, n] = size(w);
ip = int64(1);
iq = int64(0);
mean_p = true;
m = int64(10);

% Control parameters
iprint = int64(-1);
cgetol =  0.0001;
dishow = int64(2);
ishow  = int64(1);
exact = true;

% Initial parameters estimates and hold flags
par    = zeros(6,1);
parhld = [false;  false;  true;  false;  false;  false];

% Initial covariance matrix
qq = zeros(k,k);

% Fit VARMA model
[par, qq, niter, rlogl, v, g, cm, ifail] = ...
  g13dd( ...
	 ip, iq, mean_p, par, qq, w, parhld, exact, iprint, cgetol, dishow);

fprintf('\nOutput from g13ds\n\n');

% Display diagnostics
[qq, r0, r, rcm, chi, idf, siglev, ifail] = ...
    g13ds( ...
           v, ip, iq, m, par, parhld, qq, ishow);


g13ds example results


 VALUE OF LOG LIKELIHOOD FUNCTION ON EXIT = -0.20280E+03

 MAXIMUM LIKELIHOOD ESTIMATES OF AR PARAMETER MATRICES
 -----------------------------------------------------

 PHI(1)    ROW-WISE :    0.802   0.065
                       ( 0.091)( 0.102)

                         0.000   0.575
                       ( 0.000)( 0.121)

 MAXIMUM LIKELIHOOD ESTIMATE OF PROCESS MEAN
 -------------------------------------------

                         4.271   7.825
                       ( 1.219)( 0.776)

 MAXIMUM LIKELIHOOD ESTIMATE OF SIGMA MATRIX
 -------------------------------------------

                         2.964

                         0.637   5.380

           RESIDUAL SERIES NUMBER  1
           -------------------------

   T     1      2      3      4      5      6      7      8
 V(T)  -3.33  -1.24   5.75   1.27   0.32   0.11  -1.27  -0.73

   T     9     10     11     12     13     14     15     16
 V(T)  -0.58  -1.26  -0.67  -1.13  -2.02  -0.57   1.24  -0.13

   T    17     18     19     20     21     22     23     24
 V(T)  -0.77  -2.09   1.34   0.95   1.71   0.23  -0.01  -0.60

   T    25     26     27     28     29     30     31     32
 V(T)  -0.68  -1.89  -0.77   2.05   2.11   0.94  -3.32  -2.50

   T    33     34     35     36     37     38     39     40
 V(T)   3.16   0.47   0.05   2.77  -0.82   0.25   3.99   0.20

   T    41     42     43     44     45     46     47     48
 V(T)  -0.70   1.07   0.44   0.28   1.09   0.50  -0.10   1.70

           RESIDUAL SERIES NUMBER  2
           -------------------------

   T     1      2      3      4      5      6      7      8
 V(T)  -0.19  -1.20  -0.02   1.21  -1.62  -2.16  -1.63  -1.13

   T     9     10     11     12     13     14     15     16
 V(T)  -1.34  -1.30   4.82   0.43   2.54   0.35  -2.88  -0.77

   T    17     18     19     20     21     22     23     24
 V(T)   1.02  -3.85  -1.92   0.13  -1.20   0.41   1.03  -0.40

   T    25     26     27     28     29     30     31     32
 V(T)  -1.09  -1.07   3.43  -0.08   9.17  -0.23  -1.34  -2.06

   T    33     34     35     36     37     38     39     40
 V(T)  -3.16  -0.61  -1.30   0.48   0.79   2.87   2.38  -4.31

   T    41     42     43     44     45     46     47     48
 V(T)   2.32  -1.01   2.38   1.29  -1.14   0.36   2.59   2.64

Output from g13ds


 RESIDUAL CROSS-CORRELATION MATRICES
 -----------------------------------

 LAG     1           :    0.130   0.112
                        ( 0.119)( 0.143)
                          0.094   0.043
                        ( 0.069)( 0.102)

 LAG     2           :   -0.312   0.021
                        ( 0.128)( 0.144)
                         -0.162   0.098
                        ( 0.125)( 0.132)

 LAG     3           :    0.004  -0.176
                        ( 0.134)( 0.144)
                         -0.168  -0.091
                        ( 0.139)( 0.140)

 LAG     4           :   -0.090  -0.120
                        ( 0.137)( 0.144)
                          0.099  -0.232
                        ( 0.142)( 0.143)

 LAG     5           :    0.041   0.093
                        ( 0.140)( 0.144)
                         -0.009  -0.089
                        ( 0.144)( 0.144)

 LAG     6           :    0.234  -0.008
                        ( 0.141)( 0.144)
                          0.069  -0.103
                        ( 0.144)( 0.144)

 LAG     7           :   -0.076   0.007
                        ( 0.142)( 0.144)
                          0.168   0.000
                        ( 0.144)( 0.144)

 LAG     8           :   -0.074   0.559
                        ( 0.143)( 0.144)
                          0.008  -0.101
                        ( 0.144)( 0.144)

 LAG     9           :    0.091   0.193
                        ( 0.144)( 0.144)
                          0.055   0.170
                        ( 0.144)( 0.144)

 LAG    10           :   -0.060   0.061
                        ( 0.144)( 0.144)
                          0.191   0.089
                        ( 0.144)( 0.144)

 SUMMARY TABLE
 -------------

 LAGS   1 -  10

 ***************************
 *            *            *
 * .-........ * .......+.. *
 *            *            *
 ***************************
 *            *            *
 * .......... * .......... *
 *            *            *
 ***************************

 LI-MCLEOD PORTMANTEAU STATISTIC =     49.234
              SIGNIFICANCE LEVEL =      0.086
 (BASED ON  37 DEGREES OF FREEDOM)

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015