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_estimate (g13dd)

## Purpose

nag_tsa_multi_varma_estimate (g13dd) fits a vector autoregressive moving average (VARMA) model to an observed vector of time series using the method of Maximum Likelihood (ML). Standard errors of parameter estimates are computed along with their appropriate correlation matrix. The function also calculates estimates of the residual series.

## Syntax

[par, qq, niter, rlogl, v, g, cm, ifail] = g13dd(ip, iq, mean, par, qq, w, parhld, exact, iprint, cgetol, ishow, 'k', k, 'n', n, 'npar', npar, 'maxcal', maxcal)
[par, qq, niter, rlogl, v, g, cm, ifail] = nag_tsa_multi_varma_estimate(ip, iq, mean, par, qq, w, parhld, exact, iprint, cgetol, ishow, 'k', k, 'n', n, 'npar', npar, 'maxcal', maxcal)

## 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. Similarly, the ARMA model (1) is said to be invertible if the eigenvalues of B(θ)$B\left(\theta \right)$ lie inside the unit circle.
The method of computing the exact likelihood function (using a Kalman filter algorithm) is discussed in Shea (1987). A quasi-Newton algorithm (see Gill and Murray (1972)) is then used to search for the maximum of the log-likelihood function. Stationarity and invertibility are enforced on the model using the reparameterisation discussed in Ansley and Kohn (1986). Conditional on the maximum likelihood estimates being equal to their true values the estimates of the residual series are uncorrelated with zero mean and constant variance Σ$\Sigma$.
You have the option of setting a parameter (exact to false) so that nag_tsa_multi_varma_estimate (g13dd) calculates conditional maximum likelihood estimates (conditional on W0 = W1 = = W1p = ε0 = ε1 = = ε1q = 0${W}_{0}={W}_{-1}=\cdots ={W}_{1-p}={\epsilon }_{0}={\epsilon }_{-1}=\cdots ={\epsilon }_{1-q}=0$). This may be useful if the exact maximum likelihood estimates are close to the boundary of the invertibility region.
You also have the option (see Section [Parameters]) of requesting nag_tsa_multi_varma_estimate (g13dd) to constrain elements of the φ$\varphi$ and θ$\theta$ matrices and μ$\mu$ vector to have pre-specified values.

## References

Ansley C F and Kohn R (1986) A note on reparameterising a vector autoregressive moving average model to enforce stationarity J. Statist. Comput. Simulation 24 99–106
Gill P E and Murray W (1972) Quasi-Newton methods for unconstrained optimization J. Inst. Math. Appl. 9 91–108
Shea B L (1987) Estimation of multivariate time series J. Time Ser. Anal. 8 95–110

## Parameters

### Compulsory Input Parameters

1:     ip – int64int32nag_int scalar
p$p$, the number of AR parameter matrices.
Constraint: ip0${\mathbf{ip}}\ge 0$.
2:     iq – int64int32nag_int scalar
q$q$, the number of MA parameter matrices.
Constraint: iq0${\mathbf{iq}}\ge 0$.
ip = iq = 0${\mathbf{ip}}={\mathbf{iq}}=0$ is not permitted.
3:     mean – logical scalar
mean = true${\mathbf{mean}}=\mathbf{true}$, if components of μ$\mu$ have been estimated and mean = false${\mathbf{mean}}=\mathbf{false}$, if all elements of μ$\mu$ are to be taken as zero.
Constraint: mean = true${\mathbf{mean}}=\mathbf{true}$ or false$\mathbf{false}$.
4:     par(npar) – double array
npar, the dimension of the array, must satisfy the constraint
• if mean = false${\mathbf{mean}}=\mathbf{false}$, npar must be set equal to (p + q) × k × k$\left(p+q\right)×k×k$;
• if mean = true${\mathbf{mean}}=\mathbf{true}$, npar must be set equal to (p + q) × k × k + k$\left(p+q\right)×k×k+k$.
The total number of observations (n × k)$\left(n×k\right)$ must exceed the total number of parameters in the model (npar + k(k + 1) / 2${\mathbf{npar}}+k\left(k+1\right)/2$).
Initial 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},\mu$.
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+\mathit{j}\right)$ must be set equal to an initial estimate of the (i,j)$\left(\mathit{i},\mathit{j}\right)$th element of φl${\varphi }_{\mathit{l}}$, for l = 1,2,,p$\mathit{l}=1,2,\dots ,p$, i = 1,2,,k$\mathit{i}=1,2,\dots ,k$ and j = 1,2,,k$\mathit{j}=1,2,\dots ,k$;
• if iq > 0${\mathbf{iq}}>0$, par(p × k × k + (l1) × k × k + (i1) × k + j)${\mathbf{par}}\left(p×k×k+\left(l-1\right)×k×k+\left(i-1\right)×k+j\right)$ must be set equal to an initial estimate of the (i,j)$\left(i,j\right)$th element of θl${\theta }_{l}$, l = 1,2,,q$l=1,2,\dots ,q$ and i,j = 1,2,,k$i,j=1,2,\dots ,k$;
• if mean = true${\mathbf{mean}}=\mathbf{true}$, par((p + q) × k × k + i)${\mathbf{par}}\left(\left(p+q\right)×k×k+i\right)$ should be set equal to an initial estimate of the i$i$th component of μ$\mu$ (μ(i)$\mu \left(i\right)$). (If you set par((p + q) × k × k + i)${\mathbf{par}}\left(\left(p+q\right)×k×k+i\right)$ to 0.0$0.0$ then nag_tsa_multi_varma_estimate (g13dd) will calculate the mean of the i$i$th series and use this as an initial estimate of μ(i)$\mu \left(i\right)$.)
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.
If in doubt set all elements of par to 0.0$0.0$.
5:     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(\mathit{i},\mathit{j}\right)$ must be set equal to an initial estimate of the (i,j)$\left(\mathit{i},\mathit{j}\right)$th element of Σ$\Sigma$. The lower triangle only is needed. qq must be positive definite. It is strongly recommended that on entry the elements of qq are of the same order of magnitude as at the solution point. If you set qq(i,j) = 0.0${\mathbf{qq}}\left(\mathit{i},\mathit{j}\right)=0.0$, for i = 1,2,,k$\mathit{i}=1,2,\dots ,k$ and j = 1,2,,i$\mathit{j}=1,2,\dots ,i$, then nag_tsa_multi_varma_estimate (g13dd) will calculate the covariance matrix between the k$k$ time series and use this as an initial estimate of Σ$\Sigma$.
6:     w(kmax,n) – double array
kmax, the first dimension of the array, must satisfy the constraint kmaxk$\mathit{kmax}\ge {\mathbf{k}}$.
w(i,t)${\mathbf{w}}\left(\mathit{i},\mathit{t}\right)$ must be set equal to the i$\mathit{i}$th component of Wt${W}_{\mathit{t}}$, for i = 1,2,,k$\mathit{i}=1,2,\dots ,k$ and t = 1,2,,n$\mathit{t}=1,2,\dots ,n$.
7:     parhld(npar) – logical array
npar, the dimension of the array, must satisfy the constraint
• if mean = false${\mathbf{mean}}=\mathbf{false}$, npar must be set equal to (p + q) × k × k$\left(p+q\right)×k×k$;
• if mean = true${\mathbf{mean}}=\mathbf{true}$, npar must be set equal to (p + q) × k × k + k$\left(p+q\right)×k×k+k$.
The total number of observations (n × k)$\left(n×k\right)$ must exceed the total number of parameters in the model (npar + k(k + 1) / 2${\mathbf{npar}}+k\left(k+1\right)/2$).
parhld(i)${\mathbf{parhld}}\left(\mathit{i}\right)$ must be set to true if par(i)${\mathbf{par}}\left(\mathit{i}\right)$ is to be held constant at its input value and false if par(i)${\mathbf{par}}\left(\mathit{i}\right)$ is a free parameter, for i = 1,2,,npar$\mathit{i}=1,2,\dots ,{\mathbf{npar}}$.
If in doubt try setting all elements of parhld to false.
8:     exact – logical scalar
Must be set equal to true if you wish nag_tsa_multi_varma_estimate (g13dd) to compute exact maximum likelihood estimates. exact must be set equal to false if only conditional likelihood estimates are required.
9:     iprint – int64int32nag_int scalar
The frequency with which the automatic monitoring function is to be called.
iprint > 0${\mathbf{iprint}}>0$
The ML search procedure is monitored once every iprint iterations and just before exit from the search function.
iprint = 0${\mathbf{iprint}}=0$
The search function is monitored once at the final point.
iprint < 0${\mathbf{iprint}}<0$
The search function is not monitored at all.
10:   cgetol – double scalar
The accuracy to which the solution in par and qq is required.
If cgetol is set to 10l${10}^{-l}$ and on exit ${\mathbf{ifail}}={\mathbf{0}}$ or ${\mathbf{ifail}}\ge {\mathbf{6}}$, then all the elements in par and qq should be accurate to approximately l$l$ decimal places. For most practical purposes the value 104${10}^{-4}$ should suffice. You should be wary of setting cgetol too small since the convergence criteria may then have become too strict for the machine to handle.
If cgetol has been set to a value which is less than the machine precision, ε$\epsilon$, then nag_tsa_multi_varma_estimate (g13dd) will use the value 10.0 × sqrt(ε)$10.0×\sqrt{\epsilon }$ instead.
11:   ishow – int64int32nag_int scalar
Specifies which of the following two quantities are to be printed.
 (i) table of maximum likelihood estimates and their standard errors (as returned in the output arrays par, qq and cm); (ii) table of residual series (as returned in the output array v).
ishow = 0${\mathbf{ishow}}=0$
None of the above are printed.
ishow = 1${\mathbf{ishow}}=1$
(i) only is printed.
ishow = 2${\mathbf{ishow}}=2$
(i) and (ii) are printed.
Constraint: 0ishow2$0\le {\mathbf{ishow}}\le 2$.

### Optional Input Parameters

1:     k – int64int32nag_int scalar
Default: The first dimension of the arrays qq, w and the second dimension of the array qq. (An error is raised if these dimensions are not equal.)
k$k$, the number of observed time series.
Constraint: k1${\mathbf{k}}\ge 1$.
2:     n – int64int32nag_int scalar
Default: The second dimension of the array w.
n$n$, the number of observations in each time series.
3:     npar – int64int32nag_int scalar
Default: The dimension of the arrays par, parhld. (An error is raised if these dimensions are not equal.)
The dimension of the arrays par, parhld and g and the second dimension of the array cm as declared in the (sub)program from which nag_tsa_multi_varma_estimate (g13dd) is called.npar is the number of initial parameter estimates.
Constraints:
• if mean = false${\mathbf{mean}}=\mathbf{false}$, npar must be set equal to (p + q) × k × k$\left(p+q\right)×k×k$;
• if mean = true${\mathbf{mean}}=\mathbf{true}$, npar must be set equal to (p + q) × k × k + k$\left(p+q\right)×k×k+k$.
The total number of observations (n × k)$\left(n×k\right)$ must exceed the total number of parameters in the model (npar + k(k + 1) / 2${\mathbf{npar}}+k\left(k+1\right)/2$).
4:     maxcal – int64int32nag_int scalar
The maximum number of likelihood evaluations to be permitted by the search procedure.
Default: 40 × npar × (npar + 5)$40×{\mathbf{npar}}×\left({\mathbf{npar}}+5\right)$
Constraint: maxcal1${\mathbf{maxcal}}\ge 1$.

kmax ldcm

### Output Parameters

1:     par(npar) – double array
If ${\mathbf{ifail}}={\mathbf{0}}$ or ${\mathbf{ifail}}\ge {\mathbf{4}}$ then all the elements of par will be stores the latest estimates of the corresponding ARMA parameters.
2:     qq(kmax,k) – double array
kmaxk$\mathit{kmax}\ge {\mathbf{k}}$.
If ${\mathbf{ifail}}={\mathbf{0}}$ or ${\mathbf{ifail}}\ge {\mathbf{4}}$ then qq(i,j)${\mathbf{qq}}\left(i,j\right)$ will contain the latest estimate of the (i,j)$\left(i,j\right)$th element of Σ$\Sigma$. The lower triangle only is returned.
3:     niter – int64int32nag_int scalar
If ${\mathbf{ifail}}={\mathbf{0}}$ or ${\mathbf{ifail}}\ge {\mathbf{4}}$ then niter contains the number of iterations performed by the search function.
4:     rlogl – double scalar
If ${\mathbf{ifail}}={\mathbf{0}}$ or ${\mathbf{ifail}}\ge {\mathbf{4}}$ then rlogl contains the value of the log-likelihood function corresponding to the final point held in par and qq.
5:     v(kmax,n) – double array
kmaxk$\mathit{kmax}\ge {\mathbf{k}}$.
If ${\mathbf{ifail}}={\mathbf{0}}$ or ${\mathbf{ifail}}\ge {\mathbf{4}}$ then v(i,t)${\mathbf{v}}\left(\mathit{i},\mathit{t}\right)$ will 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$, corresponding to the final point held in par and qq.
6:     g(npar) – double array
If ${\mathbf{ifail}}={\mathbf{0}}$ or ${\mathbf{ifail}}\ge {\mathbf{4}}$ then g(i)${\mathbf{g}}\left(i\right)$ will contain the estimated first derivative of the log-likelihood function with respect to the i$i$th element in the array par. If the gradient cannot be computed then all the elements of g are returned as zero.
7:     cm(ldcm,npar) – double array
ldcmnpar$\mathit{ldcm}\ge {\mathbf{npar}}$.
If ${\mathbf{ifail}}={\mathbf{0}}$ or ${\mathbf{ifail}}\ge {\mathbf{4}}$ then cm(i,j)${\mathbf{cm}}\left(i,j\right)$ will contain an estimate of the correlation coefficient between the i$i$th and j$j$th elements in the par array for 1inpar$1\le i\le {\mathbf{npar}}$, 1jnpar$1\le j\le {\mathbf{npar}}$. If i = j$i=j$, then cm(i,j)${\mathbf{cm}}\left(i,j\right)$ will contain the estimated standard error of par(i)${\mathbf{par}}\left(i\right)$. If the l$l$th component of par has been held constant, i.e., parhld(l)${\mathbf{parhld}}\left(l\right)$ was set to true, then the l$l$th row and column of cm will be set to zero. If the second derivative matrix cannot be computed then all the elements of cm are returned as zero.
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_estimate (g13dd) 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 ip < 0${\mathbf{ip}}<0$, or iq < 0${\mathbf{iq}}<0$, or ip = iq = 0${\mathbf{ip}}={\mathbf{iq}}=0$, or npar ≠ (ip + iq) × k × k + Δ × k${\mathbf{npar}}\ne \left({\mathbf{ip}}+{\mathbf{iq}}\right)×{\mathbf{k}}×{\mathbf{k}}+\Delta ×{\mathbf{k}}$, where Δ = 1$\Delta =1$ if mean = true${\mathbf{mean}}=\mathbf{true}$ or Δ = 0$\Delta =0$ if mean = false${\mathbf{mean}}=\mathbf{false}$, or n × k ≤ npar + k × (k + 1) / 2${\mathbf{n}}×{\mathbf{k}}\le {\mathbf{npar}}+{\mathbf{k}}×\left({\mathbf{k}}+1\right)/2$, or kmax < k$\mathit{kmax}<{\mathbf{k}}$, or maxcal < 1${\mathbf{maxcal}}<1$, or ishow < 0${\mathbf{ishow}}<0$, or ishow > 2${\mathbf{ishow}}>2$, or ldcm < npar$\mathit{ldcm}<{\mathbf{npar}}$,
ifail = 2${\mathbf{ifail}}=2$
On entry, either the initial estimate of Σ$\Sigma$ is not positive definite, or the initial estimates of the AR parameters are such that the model is non-stationary, or the initial estimates of the MA parameters are such that the model is non-invertible. To proceed, you must try a different starting point.
ifail = 3${\mathbf{ifail}}=3$
The function cannot compute a sufficiently accurate estimate of the gradient vector at the user-supplied starting point. This usually occurs if either the initial parameter estimates are very close to the ML parameter estimates, or you have supplied a very poor estimate of Σ$\Sigma$ or the starting point is very close to the boundary of the stationarity or invertibility region. To proceed, you must try a different starting point.
ifail = 4${\mathbf{ifail}}=4$
There have been maxcal log-likelihood evaluations made in the function. If steady increases in the log-likelihood function were monitored up to the point where this exit occurred, then the exit probably simply occurred because maxcal was set too small, so the calculations should be restarted from the final point held in par and qq. This type of exit may also indicate that there is no maximum to the likelihood surface. Output quantities (as described in Section [Parameters]) are computed at the final point held in par and qq, except that if g or cm cannot be computed, in which case they are set to zero.
W ifail = 5${\mathbf{ifail}}=5$
The conditions for a solution have not all been met, but a point at which the log-likelihood took a larger value could not be found.
Provided that the estimated first derivatives are sufficiently small, and that the estimated condition number of the second derivative (Hessian) matrix, as printed when iprint0${\mathbf{iprint}}\ge 0$, is not too large, this error exit may simply mean that, although it has not been possible to satisfy the specified requirements, the algorithm has in fact found the solution as far as the accuracy of the machine permits.
Such a condition can arise, for instance, if cgetol has been set so small that rounding error in evaluating the likelihood function makes attainment of the convergence conditions impossible.
If the estimated condition number at the final point is large, it could be that the final point is a solution but that the smallest eigenvalue of the Hessian matrix is so close to zero at the solution that it is not possible to recognize it as a solution. Output quantities (as described in Section [Parameters]) are computed at the final point held in par and qq, except that if g or cm cannot be computed, in which case they are set to zero.
W ifail = 6${\mathbf{ifail}}=6$
The ML solution is so close to the boundary of either the stationarity region or the invertibility region that nag_tsa_multi_varma_estimate (g13dd) cannot evaluate the Hessian matrix. The elements of cm will then be set to zero on exit. The elements of g will also be set to zero. All other output quantities will be correct.
W ifail = 7${\mathbf{ifail}}=7$
This is an unlikely exit, which could occur in (e04xa), which computes an estimate of the second derivative matrix and the gradient vector at the solution point. Either the Hessian matrix was found to be too ill-conditioned to be evaluated accurately or the gradient vector could not be computed to an acceptable degree of accuracy. In this case the elements of cm will be set to zero on exit as will the elements of g. All other output quantities will be correct.
W ifail = 8${\mathbf{ifail}}=8$
The second derivative matrix at the solution point is not positive definite. In this case the elements of cm will be set to zero on exit. All other output quantities will be correct.
ifail = 999${\mathbf{ifail}}=-999$
Internal memory allocation failed.

## Accuracy

On exit from nag_tsa_multi_varma_estimate (g13dd), if ${\mathbf{ifail}}={\mathbf{0}}$ or ${\mathbf{ifail}}\ge {\mathbf{6}}$ and cgetol has been set to 10l${10}^{-l}$, then all the parameters should be accurate to approximately l$l$ decimal places. If cgetol was set equal to a value less than the machine precision, ε$\epsilon$, then all the parameters should be accurate to approximately 10.0 × sqrt(ε)$10.0×\sqrt{\epsilon }$.
If ${\mathbf{ifail}}={\mathbf{4}}$ on exit (i.e., maxcal likelihood evaluations have been made but the convergence conditions of the search function have not been satisfied), then the elements in par and qq may still be good approximations to the ML estimates. Inspection of the elements of g may help you determine whether this is likely.

## Further Comments

### Memory Usage

Let r = max (ip,iq) $r=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{ip}},{\mathbf{iq}}\right)$ and s = npar + k × (k + 1) / 2 $s={\mathbf{npar}}+{\mathbf{k}}×\left({\mathbf{k}}+1\right)/2$. Local workspace arrays of fixed lengths are allocated internally by nag_tsa_multi_varma_estimate (g13dd). The total size of these arrays amounts to s + k × r + 52 $s+{\mathbf{k}}×r+52$ integer elements and 2 × s2 + s × (s1) / 2 + 15 × s + k2 × (2 × ip + iq + (r + 3)2) + k × (2 × r2 + 2 × r + 3 × n + 4) + 10 $2×{s}^{2}+s×\left(s-1\right)/2+15×s+{{\mathbf{k}}}^{2}×\left(2×{\mathbf{ip}}+{\mathbf{iq}}+{\left(r+3\right)}^{2}\right)+{\mathbf{k}}×\left(2×{r}^{2}+2×r+3×{\mathbf{n}}+4\right)+10$ double elements.

### Timing

The number of iterations required depends upon the number of parameters in the model and the distance of the user-supplied starting point from the solution.

### Constraining for Stationarity and Invertibility

If the solution lies on the boundary of the admissibility region (stationarity and invertibility region) then nag_tsa_multi_varma_estimate (g13dd) may get into difficulty and exit with ${\mathbf{ifail}}={\mathbf{5}}$. If this exit occurs you are advised to either try a different starting point or a different setting for exact. If this still continues to occur then you are urged to try fitting a more parsimonious model.

### Over-parameterisation

You are advised to try and avoid fitting models with an excessive number of parameters since over-parameterisation can cause the maximization problem to become ill-conditioned.

### Standardizing the Residual Series

The standardized estimates of the residual series εt${\epsilon }_{t}$ (denoted by t${\stackrel{^}{e}}_{t}$) can easily be calculated by forming the Cholesky decomposition of Σ$\Sigma$, e.g., GGT$G{G}^{\mathrm{T}}$ and setting t = G1ε̂t${\stackrel{^}{e}}_{t}={G}^{-1}{\stackrel{^}{\epsilon }}_{t}$. nag_lapack_dpotrf (f07fd) may be used to calculate the array g. The components of t${\stackrel{^}{e}}_{t}$ which are now uncorrelated at all lags can sometimes be more easily interpreted.

### Assessing the Fit of the Model

If your time series model provides a good fit to the data then the residual series should be approximately white noise, i.e., exhibit no serial cross-correlation. An examination of the residual cross-correlation matrices should confirm whether this is likely to be so. You are advised to call nag_tsa_multi_varma_diag (g13ds) to provide information for diagnostic checking. nag_tsa_multi_varma_diag (g13ds) returns the residual cross-correlation matrices along with their asymptotic standard errors. nag_tsa_multi_varma_diag (g13ds) also computes a portmanteau statistic and its asymptotic significance level for testing model adequacy. If ${\mathbf{ifail}}={\mathbf{0}}$ or 5ifail8$5\le {\mathbf{ifail}}\le 8$ on exit from nag_tsa_multi_varma_estimate (g13dd) then the quantities output k, n, v, kmax, ip, iq, par, parhld, and qq will be suitable for input to nag_tsa_multi_varma_diag (g13ds).

## Example

```function nag_tsa_multi_varma_estimate_example
ip = int64(1);
iq = int64(0);
mean_p = true;
par = zeros(6, 1);
% Set all elements of Q to zero to use the covariance matrix
% between the K time series as the initial estimate of the
% covariance matrix
qq = [0, 0; 0, 0];
w = [-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];
parhld = [false;
false;
true;
false;
false;
false];
exact = true;
iprint = int64(-1);
cgetol = 0.0001;
ishow = int64(2);
[parOut, qqOut, niter, rlogl, v, g, cm, ifail] = ...
nag_tsa_multi_varma_estimate(ip, iq, mean_p, par, qq, w, parhld, exact, iprint, cgetol, ishow)
```
```

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

parOut =

0.8016
0.0648
0
0.5750
4.2711
7.8253

qqOut =

2.9642    0.6373
0.6373    5.3799

niter =

0

rlogl =

-202.8027

v =

Columns 1 through 9

-3.3261   -1.2415    5.7469    1.2704    0.3223    0.1128   -1.2697   -0.7336   -0.5810
-0.1865   -1.1963   -0.0170    1.2122   -1.6163   -2.1623   -1.6335   -1.1320   -1.3415

Columns 10 through 18

-1.2582   -0.6731   -1.1332   -2.0203   -0.5727    1.2360   -0.1309   -0.7728   -2.0894
-1.2970    4.8173    0.4282    2.5384    0.3527   -2.8828   -0.7657    1.0163   -3.8455

Columns 19 through 27

1.3373    0.9464    1.7095    0.2329   -0.0096   -0.5979   -0.6825   -1.8867   -0.7669
-1.9187    0.1295   -1.1957    0.4080    1.0285   -0.4010   -1.0918   -1.0695    3.4283

Columns 28 through 36

2.0514    2.1089    0.9432   -3.3242   -2.5026    3.1626    0.4690    0.0534    2.7677
-0.0796    9.1687   -0.2322   -1.3434   -2.0630   -3.1558   -0.6117   -1.2952    0.4838

Columns 37 through 45

-0.8170    0.2498    3.9851    0.1996   -0.6999    1.0721    0.4391    0.2783    1.0893
0.7905    2.8687    2.3772   -4.3126    2.3205   -1.0065    2.3817    1.2927   -1.1443

Columns 46 through 48

0.5028   -0.1031    1.7031
0.3580    2.5915    2.6444

g =

1.0e-03 *

0.0231
-0.1487
0
-0.0547
0.0002
-0.0030

cm =

0.0906   -0.0814         0   -0.0054   -0.0150    0.0021
-0.0814    0.1018         0    0.0650    0.0177   -0.0544
0         0         0         0         0         0
-0.0054    0.0650         0    0.1206    0.0047   -0.0094
-0.0150    0.0177         0    0.0047    1.2191    0.3480
0.0021   -0.0544         0   -0.0094    0.3480    0.7755

ifail =

0

```
```function g13dd_example
ip = int64(1);
iq = int64(0);
mean_p = true;
par = zeros(6, 1);
% Set all elements of Q to zero to use the covariance matrix
% between the K time series as the initial estimate of the
% covariance matrix
qq = [0, 0; 0, 0];
w = [-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];
parhld = [false;
false;
true;
false;
false;
false];
exact = true;
iprint = int64(-1);
cgetol = 0.0001;
ishow = int64(2);
[parOut, qqOut, niter, rlogl, v, g, cm, ifail] = ...
g13dd(ip, iq, mean_p, par, qq, w, parhld, exact, iprint, cgetol, ishow)
```
```

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

parOut =

0.8016
0.0648
0
0.5750
4.2711
7.8253

qqOut =

2.9642    0.6373
0.6373    5.3799

niter =

0

rlogl =

-202.8027

v =

Columns 1 through 9

-3.3261   -1.2415    5.7469    1.2704    0.3223    0.1128   -1.2697   -0.7336   -0.5810
-0.1865   -1.1963   -0.0170    1.2122   -1.6163   -2.1623   -1.6335   -1.1320   -1.3415

Columns 10 through 18

-1.2582   -0.6731   -1.1332   -2.0203   -0.5727    1.2360   -0.1309   -0.7728   -2.0894
-1.2970    4.8173    0.4282    2.5384    0.3527   -2.8828   -0.7657    1.0163   -3.8455

Columns 19 through 27

1.3373    0.9464    1.7095    0.2329   -0.0096   -0.5979   -0.6825   -1.8867   -0.7669
-1.9187    0.1295   -1.1957    0.4080    1.0285   -0.4010   -1.0918   -1.0695    3.4283

Columns 28 through 36

2.0514    2.1089    0.9432   -3.3242   -2.5026    3.1626    0.4690    0.0534    2.7677
-0.0796    9.1687   -0.2322   -1.3434   -2.0630   -3.1558   -0.6117   -1.2952    0.4838

Columns 37 through 45

-0.8170    0.2498    3.9851    0.1996   -0.6999    1.0721    0.4391    0.2783    1.0893
0.7905    2.8687    2.3772   -4.3126    2.3205   -1.0065    2.3817    1.2927   -1.1443

Columns 46 through 48

0.5028   -0.1031    1.7031
0.3580    2.5915    2.6444

g =

1.0e-03 *

0.0231
-0.1487
0
-0.0547
0.0002
-0.0030

cm =

0.0906   -0.0814         0   -0.0054   -0.0150    0.0021
-0.0814    0.1018         0    0.0650    0.0177   -0.0544
0         0         0         0         0         0
-0.0054    0.0650         0    0.1206    0.0047   -0.0094
-0.0150    0.0177         0    0.0047    1.2191    0.3480
0.0021   -0.0544         0   -0.0094    0.3480    0.7755

ifail =

0

```

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–2013