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_varma_diag (g13ds)

## 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,,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 which is assumed to follow a multivariate ARMA model of the form
 Wt − μ = φ1(Wt − 1 − μ) + φ2(Wt − 2 − μ) + ⋯ + φp(Wt − p − μ) + εt − θ1εt − 1 − θ2εt − 2 − ⋯ − θqεt − q,
$Wt-μ= ϕ1(Wt-1-μ)+ϕ2(Wt-2-μ)+⋯+ϕp(Wt-p-μ) +εt-θ1εt-1-θ2εt-2-⋯-θqεt-q,$
(1)
where εt = (ε1t,ε2t,,εkt)T ${\epsilon }_{\mathit{t}}={\left({\epsilon }_{1\mathit{t}},{\epsilon }_{2\mathit{t}},\dots ,{\epsilon }_{k\mathit{t}}\right)}^{\mathrm{T}}$, for t = 1,2,,n$\mathit{t}=1,2,\dots ,n$, is a vector of k$k$ residual series assumed to be Normally distributed with zero mean and positive definite covariance matrix Σ$\Sigma$. The components of εt${\epsilon }_{t}$ are assumed to be uncorrelated at non-simultaneous lags. The φi${\varphi }_{i}$ and θj${\theta }_{j}$ are k$k$ by k$k$ matrices of parameters. {φi}$\left\{{\varphi }_{\mathit{i}}\right\}$, for i = 1,2,,p$\mathit{i}=1,2,\dots ,p$, are called the autoregressive (AR) parameter matrices, and {θi}$\left\{{\theta }_{\mathit{i}}\right\}$, for i = 1,2,,q$\mathit{i}=1,2,\dots ,q$, the moving average (MA) parameter matrices. The parameters in the model are thus the p$p$ (k$k$ by k$k$) φ$\varphi$-matrices, the q$q$ (k$k$ by k$k$) θ$\theta$-matrices, the mean vector μ$\mu$ and the residual error covariance matrix Σ$\Sigma$. 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
$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$I$ denotes the k$k$ by k$k$ identity matrix.
The ARMA model (1) is said to be stationary if the eigenvalues of A(φ)$A\left(\varphi \right)$ lie inside the unit circle, and invertible if the eigenvalues of B(θ)$B\left(\theta \right)$ lie inside the unit circle. The ARMA model is assumed to be both stationary and invertible. Note that some of the elements of the φ$\varphi$- and/or θ$\theta$-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$l$ is defined to the k$k$ by k$k$ matrix l${\stackrel{^}{R}}_{l}$ whose (i,j)$\left(i,j\right)$th element is computed as
 r̂ i j (l) = ( ∑ t = l + 1 n (ε̂ i t − l − εi) (ε̂ j t − εj) )/(sqrt( ∑ t = 1 n (ε̂ i t − εi)2 ∑ t = 1 n (ε̂ j t − εj)2 )) ,   l = 0,1, … ,i​ and ​j = 1,2, … ,k , $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${\stackrel{^}{\epsilon }}_{it}$ denotes an estimate of the t$t$th residual for the i$i$th series εit${\epsilon }_{it}$ and εi = t = 1nε̂it / n${\stackrel{-}{\epsilon }}_{i}=\sum _{t=1}^{n}{\stackrel{^}{\epsilon }}_{it}/n$. (Note that l${\stackrel{^}{R}}_{l}$ is an estimate of E(εtlεtT)$E\left({\epsilon }_{t-l}{\epsilon }_{t}^{\mathrm{T}}\right)$, where E$E$ is the expected value.)
A modified portmanteau statistic, Q(m) * ${Q}_{\left(m\right)}^{*}$, is calculated from the formula (see Li and McLeod (1981))
 m Q(m) * = ( k2 m(m + 1) )/(2n) + n ∑ r̂(l)T(R̂0 − 1 ⊗ R̂0 − 1)r̂(l), l = 1
$Q(m) * = k2 m(m+1) 2n + n ∑ l=1 m r^ (l)T ( R^ 0 -1 ⊗ R^ 0 -1 ) r^ (l) ,$
where $\otimes$ denotes Kronecker product, 0${\stackrel{^}{R}}_{0}$ is the estimated residual cross-correlation matrix at lag zero and (l) = vec(lT)$\stackrel{^}{r}\left(l\right)=\mathrm{vec}\left({\stackrel{^}{R}}_{l}^{\mathrm{T}}\right)$, where vec$\text{vec}$ of a k$k$ by k$k$ matrix is a vector with the (i,j)$\left(i,j\right)$th element in position (i1)k + j$\left(i-1\right)k+j$. m$m$ denotes the number of residual cross-correlation matrices computed. (Advice on the choice of m$m$ is given in Section [Choice of ].) Let lC${l}_{C}$ denote the total number of ‘free’ parameters in the ARMA model excluding the mean, μ$\mu$, and the residual error covariance matrix Σ$\Sigma$. Then, under the hypothesis of model adequacy, Q(m) * ${Q}_{\left(m\right)}^{*}$, has an asymptotic χ2${\chi }^{2}$-distribution on mk2lC$m{k}^{2}-{l}_{C}$ degrees of freedom.
Let
 r̂ = (vec(R1T),vec(R2T), … ,vec(RmT)) ̲
$\underline{\stackrel{^}{r}}=\left(\mathrm{vec}\left({R}_{1}^{\mathrm{T}}\right),\mathrm{vec}\left({R}_{2}^{\mathrm{T}}\right),\dots ,\mathrm{vec}\left({R}_{m}^{\mathrm{T}}\right)\right)$ then the covariance matrix of
 r̂ ̲
$\underline{\stackrel{^}{r}}$ is given by
 Var(r ̲ ^) = [Y − X(XTGGTX) − 1XT] / n, $Var(r̲^)=[Y-X(XTGGTX)-1XT]/n,$
where Y = Im(ΔΔ)$Y={I}_{m}\otimes \left(\Delta \otimes \Delta \right)$ and G = Im(GGT)$G={I}_{m}\left(G{G}^{\mathrm{T}}\right)$. Δ$\Delta$ is the dispersion matrix Σ$\Sigma$ in correlation form and G$G$ a nonsingular k$k$ by k$k$ matrix such that GGT = Δ1$G{G}^{\mathrm{T}}={\Delta }^{-1}$ and GΔGT = Ik$G\Delta {G}^{\mathrm{T}}={I}_{k}$. The construction of the matrix X$X$ is discussed in Li and McLeod (1981). (Note that the mean, μ$\mu$, plays no part in calculating Var(r ̲ ^)$\mathrm{Var}\left(\stackrel{^}{\underline{r}}\right)$ 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:     v(kmax,n) – double array
kmax, the first dimension of the array, must satisfy the constraint kmaxk$\mathit{kmax}\ge {\mathbf{k}}$.
v(i,t)${\mathbf{v}}\left(\mathit{i},\mathit{t}\right)$ must contain an estimate of the i$\mathit{i}$th component of εt${\epsilon }_{\mathit{t}}$, for i = 1,2,,k$\mathit{i}=1,2,\dots ,k$ and t = 1,2,,n$\mathit{t}=1,2,\dots ,n$.
Constraints:
• no two rows of v${\mathbf{v}}$ may be identical;
• in each row there must be at least two distinct elements.
2:     ip – int64int32nag_int scalar
p$p$, the number of AR parameter matrices.
Constraint: ip0${\mathbf{ip}}\ge 0$.
3:     iq – int64int32nag_int scalar
q$q$, the number of MA parameter matrices.
Constraint: iq0${\mathbf{iq}}\ge 0$.
Note: ip = iq = 0${\mathbf{ip}}={\mathbf{iq}}=0$ is not permitted.
4:     m – int64int32nag_int scalar
The value of m$m$, the number of residual cross-correlation matrices to be computed. See Section [Choice of ] for advice on the choice of m.
Constraint: ip + iq < m < n${\mathbf{ip}}+{\mathbf{iq}}<{\mathbf{m}}<{\mathbf{n}}$.
5:     par((ip + iq) × k × k$\left({\mathbf{ip}}+{\mathbf{iq}}\right)×{\mathbf{k}}×{\mathbf{k}}$) – double array
The parameter estimates read in row by row in the order φ1,φ2,,φp${\varphi }_{1},{\varphi }_{2},\dots ,{\varphi }_{p}$, θ1,θ2,,θq${\theta }_{1},{\theta }_{2},\dots ,{\theta }_{q}$.
Thus,
• if ip > 0${\mathbf{ip}}>0$, par((l1) × k × k + (i1) × k + j)${\mathbf{par}}\left(\left(\mathit{l}-1\right)×k×k+\left(\mathit{i}-1\right)×k+j\right)$ must be set equal to an estimate of the (i,j)$\left(\mathit{i},j\right)$th element of φl${\varphi }_{\mathit{l}}$, for l = 1,2,,p$\mathit{l}=1,2,\dots ,p$ and i = 1,2,,k$\mathit{i}=1,2,\dots ,k$;
• if iq0${\mathbf{iq}}\ge 0$, par(p × k × k + (l1) × k × k + (i1) × k + j)${\mathbf{par}}\left(p×k×k+\left(\mathit{l}-1\right)×k×k+\left(\mathit{i}-1\right)×k+j\right)$ must be set equal to an estimate of the (i,j)$\left(\mathit{i},j\right)$th element of θl${\theta }_{\mathit{l}}$, for l = 1,2,,q$\mathit{l}=1,2,\dots ,q$ and i = 1,2,,k$\mathit{i}=1,2,\dots ,k$.
The first p × k × k$p×k×k$ elements of par must satisfy the stationarity condition and the next q × k × k$q×k×k$ elements of par must satisfy the invertibility condition.
6:     parhld((ip + iq) × k × k$\left({\mathbf{ip}}+{\mathbf{iq}}\right)×{\mathbf{k}}×{\mathbf{k}}$) – logical array
parhld(i)${\mathbf{parhld}}\left(\mathit{i}\right)$ must be set to true if par(i)${\mathbf{par}}\left(\mathit{i}\right)$ has been held constant at a pre-specified value and false if par(i)${\mathbf{par}}\left(\mathit{i}\right)$ is a free parameter, for i = 1,2,,(p + q) × k × k$\mathit{i}=1,2,\dots ,\left(p+q\right)×k×k$.
7:     qq(kmax,k) – double array
kmax, the first dimension of the array, must satisfy the constraint kmaxk$\mathit{kmax}\ge {\mathbf{k}}$.
qq(i,j)${\mathbf{qq}}\left(i,j\right)$ is an efficient estimate of the (i,j)$\left(i,j\right)$th element of Σ$\Sigma$. The lower triangle only is needed.
Constraint: qq${\mathbf{qq}}$ must be positive definite.
8:     ishow – int64int32nag_int scalar
Must be nonzero if the residual cross-correlation matrices {ij(l)}$\left\{{\stackrel{^}{r}}_{ij}\left(l\right)\right\}$ and their standard errors {se(ij(l))}$\left\{\mathrm{se}\left({\stackrel{^}{r}}_{ij}\left(l\right)\right)\right\}$, 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%$5%$ level in either a positive or negative direction; i.e., if ij(l) > 1.96 × se(ij(l))${\stackrel{^}{r}}_{ij}\left(l\right)>1.96×\mathrm{se}\left({\stackrel{^}{r}}_{ij}\left(l\right)\right)$ then a ‘ + $+$’ is printed, if ij(l) < 1.96 × se(ij(l))${\stackrel{^}{r}}_{ij}\left(l\right)<-1.96×\mathrm{se}\left({\stackrel{^}{r}}_{ij}\left(l\right)\right)$ then a ‘$-$’ is printed, otherwise a fullstop (.) is printed. The summary table is only printed if k6$k\le 6$ 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$k$, the number of residual time series.
Constraint: k1${\mathbf{k}}\ge 1$.
2:     n – int64int32nag_int scalar
Default: The second dimension of the array v.
n$n$, the number of observations in each residual series.

### Input Parameters Omitted from the MATLAB Interface

kmax ldrcm iw liw work lwork

### Output Parameters

1:     qq(kmax,k) – double array
kmaxk$\mathit{kmax}\ge {\mathbf{k}}$.
If ${\mathbf{ifail}}\ne {\mathbf{1}}$, then the upper triangle is set equal to the lower triangle.
2:     r0(kmax,k) – double array
kmaxk$\mathit{kmax}\ge {\mathbf{k}}$.
If ij$i\ne j$, then r0(i,j)${\mathbf{r0}}\left(i,j\right)$ contains an estimate of the (i,j)$\left(i,j\right)$th element of the residual cross-correlation matrix at lag zero, 0${\stackrel{^}{R}}_{0}$. When i = j$i=j$, r0(i,j)${\mathbf{r0}}\left(i,j\right)$ contains the standard deviation of the i$i$th residual series. If ${\mathbf{ifail}}={\mathbf{3}}$ on exit then the first k rows and columns of r0 are set to zero.
3:     r(kmax,kmax,m) – double array
kmaxk$\mathit{kmax}\ge {\mathbf{k}}$.
r(l,i,j)${\mathbf{r}}\left(\mathit{l},\mathit{i},\mathit{j}\right)$ is an estimate of the (i,j)$\left(\mathit{i},\mathit{j}\right)$th element of the residual cross-correlation matrix at lag l$\mathit{l}$, for i = 1,2,,k$\mathit{i}=1,2,\dots ,k$, j = 1,2,,k$\mathit{j}=1,2,\dots ,k$ and l = 1,2,,m$\mathit{l}=1,2,\dots ,m$. If ${\mathbf{ifail}}={\mathbf{3}}$ on exit then all elements of r are set to zero.
4:     rcm(ldrcm,m × k × k${\mathbf{m}}×{\mathbf{k}}×{\mathbf{k}}$) – double array
ldrcmm × k × k$\mathit{ldrcm}\ge {\mathbf{m}}×{\mathbf{k}}×{\mathbf{k}}$.
The estimated standard errors and correlations of the elements in the array r. The correlation between r(l,i,j)${\mathbf{r}}\left(l,i,j\right)$ and r(l2,i2,j2)${\mathbf{r}}\left({l}_{2},{i}_{2},{j}_{2}\right)$ is returned as rcm(s,t)${\mathbf{rcm}}\left(s,t\right)$ where s = (l1) × k × k + (j1) × k + i$s=\left(l-1\right)×k×k+\left(j-1\right)×k+i$ and t = (l21) × k × k + (j21) × k + i2$t=\left({l}_{2}-1\right)×k×k+\left({j}_{2}-1\right)×k+{i}_{2}$ except that if s = t$s=t$, then rcm(s,t)${\mathbf{rcm}}\left(s,t\right)$ contains the standard error of r(l,i,j)${\mathbf{r}}\left(l,i,j\right)$. If on exit, ${\mathbf{ifail}}\ge {\mathbf{5}}$, then all off-diagonal elements of rcm are set to zero and all diagonal elements are set to 1 / sqrt(n)$1/\sqrt{n}$.
5:     chi – double scalar
The value of the modified portmanteau statistic, Q(m) * ${Q}_{\left(m\right)}^{*}$. If ${\mathbf{ifail}}={\mathbf{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 ${\mathbf{ifail}}={\mathbf{3}}$ on exit, siglev is returned as one.
8:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{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${\mathbf{ifail}}=1$
 On entry, k < 1${\mathbf{k}}<1$, or kmax < k$\mathit{kmax}<{\mathbf{k}}$, or ip < 0${\mathbf{ip}}<0$, or iq < 0${\mathbf{iq}}<0$, or ip = iq = 0${\mathbf{ip}}={\mathbf{iq}}=0$, or m ≤ ip + iq${\mathbf{m}}\le {\mathbf{ip}}+{\mathbf{iq}}$, or m ≥ n${\mathbf{m}}\ge {\mathbf{n}}$, or ldrcm < m × k × k$\mathit{ldrcm}<{\mathbf{m}}×{\mathbf{k}}×{\mathbf{k}}$, or liw is too small, or lwork is too small.
ifail = 2${\mathbf{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${\mathbf{ifail}}=3$
On entry, at least one of the k$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${\mathbf{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 det(A(φ))$\mathrm{det}\left(A\left(\varphi \right)\right)$ and det(B(θ))$\mathrm{det}\left(B\left(\theta \right)\right)$. All output parameters are undefined.
ifail = 5${\mathbf{ifail}}=5$
On entry, either the eigenvalues and eigenvectors of Δ$\Delta$ (the matrix qq in correlation form) could not be computed or the determinantal polynomials det(A(φ))$\mathrm{det}\left(A\left(\varphi \right)\right)$ and det(B(θ))$\mathrm{det}\left(B\left(\theta \right)\right)$ 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 / sqrt(n)$1/\sqrt{n}$. All other output quantities will be correct.
ifail = 6${\mathbf{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 / sqrt(n)$1/\sqrt{n}$.

## Accuracy

The computations are believed to be stable.

### Timing

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

### Choice of m

The number of residual cross-correlation matrices to be computed, m$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(Wt − j − μ) + εt j = 1
$Wt-μ=∑j=1∞πj(Wt-j-μ)+εt$
or as an infinite order moving average process, i.e.,
 ∞ Wt − μ = ∑ ψjεt − j + εt j = 1
$Wt-μ=∑j= 1∞ψjεt-j+εt$
then the two sequences of k$k$ by k$k$ matrices {π1,π2,}$\left\{{\pi }_{1},{\pi }_{2},\dots \right\}$ and {ψ1,ψ2,}$\left\{{\psi }_{1},{\psi }_{2},\dots \right\}$ are such that πj${\pi }_{j}$ and ψj${\psi }_{j}$ are approximately zero for j > m$j>m$. An overestimate of m$m$ is therefore preferable to an under-estimate of m$m$. In many instances the choice m = 10$m=10$ will suffice. In practice, to be on the safe side, you should try setting m = 20$m=20$.

### Checking a ‘White Noise’ Model

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

### Approximate Standard Errors

When ${\mathbf{ifail}}={\mathbf{5}}$ or 6${\mathbf{6}}$ all the standard errors in rcm are set to 1 / sqrt(n)$1/\sqrt{n}$. This is the asymptotic standard error of ij(l)${\stackrel{^}{r}}_{ij}\left(l\right)$ when all the autoregressive and moving average parameters are assumed to be known rather than estimated.

### Alternative Tests

0${\stackrel{^}{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 (0)$\left({\stackrel{^}{C}}_{0}\right)$ can be used. It can be recovered from 0${\stackrel{^}{R}}_{0}$ by setting
 Ĉ0(i,j) = R̂0(i,j) × R̂0(i,i) × R̂0(j,j), for ​i ≠ j = R̂0(i,j) × R̂0(i,j), for ​i = j
$C^0(i,j) =R^0(i,j)×R^0(i,i)×R^0(j,j), for ​i≠j =R^0(i,j)×R^0(i,j), for ​i=j$

## Example

```function nag_tsa_multi_varma_diag_example
v = [-3.326133715726029, -1.241508590516912, 5.746865699837245, 1.270368439927496, ...
0.3223077197693467, 0.112781765620811, -1.269713458557113, -0.7336470675276869, ...
-0.5810360328920845, -1.25824719747888, -0.673079208545849, -1.133223470827074, ...
-2.02032143339675, -0.572742526272592, 1.235974230307894, -0.1309001630044928, ...
-0.7727550109923405, -2.089421928018445, 1.337338340999243, 0.9464411511199494, ...
1.709504159208547, 0.2328949507059163, -0.009588098625822217, -0.5978622133565419, ...
-0.6825454370774304, -1.886726796800422, -0.7668901664948766, ...
2.051416165579926, 2.108859010344129, 0.9432308237617111, -3.324245626104025, ...
-2.50257816223142, 3.162556623476816, 0.4690152211351468, 0.05343371271906172, ...
2.767725632154585, -0.8170430505081534, 0.2497744022910866, 3.985096789984951, ...
0.1996377231860347, -0.6999084077936142, 1.072141758566346, 0.4391261753813116, ...
0.2782622637979761, 1.08929906068535, 0.5027884718514648, -0.103132986353569, 1.703128639510798;
-0.1864812965451277, -1.196262944870486, -0.01699715324845752, 1.212243116560191, ...
-1.61628208623052, -2.162251460054466, -1.633475140684418, -1.131968441208406, ...
-1.34147258850308, -1.296971631435079, 4.817278209053589, 0.4281805881174119, ...
2.538444465603437, 0.3526687842787246, -2.882811117293238, -0.7657479508051256, ...
1.016254601376212, -3.84552235603917, -1.918710306130392, 0.1295446387209505, ...
-1.195735189898436, 0.4080187978849044, 1.028495509230196, -0.4010277794245127, ...
-1.091768368255828, -1.069501938588466, 3.42825715355755, -0.07955936266856867, ...
9.168708343089461, -0.2321789961687832, -1.343358013625323, -2.063049472965885, ...
-3.15575433125847, -0.6117109441757265, -1.29522657628642, 0.4837753378495833, ...
0.7904980614115339, 2.868727484449496, 2.377182502253417, -4.312585522527284, ...
2.320510822318223, -1.0065395832632, 2.381734502948175, 1.292694306092105, ...
-1.144311436315907, 0.3579741347114898, 2.591470625462152, 2.644432980787418];
ip = int64(1);
iq = int64(0);
m = int64(10);
par = [0.8016071892386086;
0.0648134906597352;
0;
0.575015951133362];
parhld = [false;
false;
true;
false];
qq = [2.964154253391392, 0.6372583252520638;
0.6372583252520638, 5.379903126133676];
ishow = int64(1);
[qqOut, r0, r, rcm, chi, idf, siglev, ifail] = ...
nag_tsa_multi_varma_diag(v, ip, iq, m, par, parhld, qq, ishow);
qqOut, r0, chi, idf, siglev, ifail
```
```

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)

qqOut =

2.9642    0.6373
0.6373    5.3799

r0 =

1.7164    0.1491
0.1491    2.3143

chi =

49.2337

idf =

37

siglev =

0.0860

ifail =

0

```
```function g13ds_example
v = [-3.326133715726029, -1.241508590516912, 5.746865699837245, 1.270368439927496, ...
0.3223077197693467, 0.112781765620811, -1.269713458557113, -0.7336470675276869, ...
-0.5810360328920845, -1.25824719747888, -0.673079208545849, -1.133223470827074, ...
-2.02032143339675, -0.572742526272592, 1.235974230307894, -0.1309001630044928, ...
-0.7727550109923405, -2.089421928018445, 1.337338340999243, 0.9464411511199494, ...
1.709504159208547, 0.2328949507059163, -0.009588098625822217, -0.5978622133565419, ...
-0.6825454370774304, -1.886726796800422, -0.7668901664948766, ...
2.051416165579926, 2.108859010344129, 0.9432308237617111, -3.324245626104025, ...
-2.50257816223142, 3.162556623476816, 0.4690152211351468, 0.05343371271906172, ...
2.767725632154585, -0.8170430505081534, 0.2497744022910866, 3.985096789984951, ...
0.1996377231860347, -0.6999084077936142, 1.072141758566346, 0.4391261753813116, ...
0.2782622637979761, 1.08929906068535, 0.5027884718514648, -0.103132986353569, 1.703128639510798;
-0.1864812965451277, -1.196262944870486, -0.01699715324845752, 1.212243116560191, ...
-1.61628208623052, -2.162251460054466, -1.633475140684418, -1.131968441208406, ...
-1.34147258850308, -1.296971631435079, 4.817278209053589, 0.4281805881174119, ...
2.538444465603437, 0.3526687842787246, -2.882811117293238, -0.7657479508051256, ...
1.016254601376212, -3.84552235603917, -1.918710306130392, 0.1295446387209505, ...
-1.195735189898436, 0.4080187978849044, 1.028495509230196, -0.4010277794245127, ...
-1.091768368255828, -1.069501938588466, 3.42825715355755, -0.07955936266856867, ...
9.168708343089461, -0.2321789961687832, -1.343358013625323, -2.063049472965885, ...
-3.15575433125847, -0.6117109441757265, -1.29522657628642, 0.4837753378495833, ...
0.7904980614115339, 2.868727484449496, 2.377182502253417, -4.312585522527284, ...
2.320510822318223, -1.0065395832632, 2.381734502948175, 1.292694306092105, ...
-1.144311436315907, 0.3579741347114898, 2.591470625462152, 2.644432980787418];
ip = int64(1);
iq = int64(0);
m = int64(10);
par = [0.8016071892386086;
0.0648134906597352;
0;
0.575015951133362];
parhld = [false;
false;
true;
false];
qq = [2.964154253391392, 0.6372583252520638;
0.6372583252520638, 5.379903126133676];
ishow = int64(1);
[qqOut, r0, r, rcm, chi, idf, siglev, ifail] = ...
g13ds(v, ip, iq, m, par, parhld, qq, ishow);
qqOut, r0, chi, idf, siglev, ifail
```
```

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)

qqOut =

2.9642    0.6373
0.6373    5.3799

r0 =

1.7164    0.1491
0.1491    2.3143

chi =

49.2337

idf =

37

siglev =

0.0860

ifail =

0

```