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 method also calculates estimates of the residual series.

Syntax

C#
public static void g13dd(
	int k,
	int n,
	int ip,
	int iq,
	bool mean,
	double[] par,
	double[,] qq,
	double[,] w,
	bool[] parhld,
	bool exact,
	int iprint,
	double cgetol,
	int maxcal,
	int ishow,
	out int niter,
	out double rlogl,
	double[,] v,
	double[] g,
	double[,] cm,
	out int ifail
)
Visual Basic
Public Shared Sub g13dd ( _
	k As Integer, _
	n As Integer, _
	ip As Integer, _
	iq As Integer, _
	mean As Boolean, _
	par As Double(), _
	qq As Double(,), _
	w As Double(,), _
	parhld As Boolean(), _
	exact As Boolean, _
	iprint As Integer, _
	cgetol As Double, _
	maxcal As Integer, _
	ishow As Integer, _
	<OutAttribute> ByRef niter As Integer, _
	<OutAttribute> ByRef rlogl As Double, _
	v As Double(,), _
	g As Double(), _
	cm As Double(,), _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void g13dd(
	int k, 
	int n, 
	int ip, 
	int iq, 
	bool mean, 
	array<double>^ par, 
	array<double,2>^ qq, 
	array<double,2>^ w, 
	array<bool>^ parhld, 
	bool exact, 
	int iprint, 
	double cgetol, 
	int maxcal, 
	int ishow, 
	[OutAttribute] int% niter, 
	[OutAttribute] double% rlogl, 
	array<double,2>^ v, 
	array<double>^ g, 
	array<double,2>^ cm, 
	[OutAttribute] int% ifail
)
F#
static member g13dd : 
        k : int * 
        n : int * 
        ip : int * 
        iq : int * 
        mean : bool * 
        par : float[] * 
        qq : float[,] * 
        w : float[,] * 
        parhld : bool[] * 
        exact : bool * 
        iprint : int * 
        cgetol : float * 
        maxcal : int * 
        ishow : int * 
        niter : int byref * 
        rlogl : float byref * 
        v : float[,] * 
        g : float[] * 
        cm : float[,] * 
        ifail : int byref -> unit 

Parameters

k
Type: System..::..Int32
On entry: k, the number of observed time series.
Constraint: k1.
n
Type: System..::..Int32
On entry: n, the number of observations in each time series.
ip
Type: System..::..Int32
On entry: p, the number of AR parameter matrices.
Constraint: ip0.
iq
Type: System..::..Int32
On entry: q, the number of MA parameter matrices.
Constraint: iq0.
ip=iq=0 is not permitted.
mean
Type: System..::..Boolean
On entry: mean=true, if components of μ have been estimated and mean=false, if all elements of μ are to be taken as zero.
Constraint: mean=true or false.
par
Type: array<System..::..Double>[]()[][]
An array of size [npar]
On entry: initial parameter estimates read in row by row in the order ϕ1,ϕ2,,ϕp, θ1,θ2,,θq,μ.
Thus,
  • if ip>0, par[l-1×k×k+i-1×k+j-1] must be set equal to an initial estimate of the i,jth element of ϕl, for l=1,2,,p, i=1,2,,k and j=1,2,,k;
  • if iq>0, par[p×k×k+l-1×k×k+i-1×k+j-1] must be set equal to an initial estimate of the i,jth element of θl, l=1,2,,q and i,j=1,2,,k;
  • if mean=true, par[p+q×k×k+i-1] should be set equal to an initial estimate of the ith component of μ (μi). (If you set par[p+q×k×k+i-1] to 0.0 then g13dd will calculate the mean of the ith series and use this as an initial estimate of μi.)
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.
If in doubt set all elements of par to 0.0.
On exit: if ifail=0 or ifail4 then all the elements of par will be overwritten by the latest estimates of the corresponding ARMA parameters.
qq
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, k]
Note: dim1 must satisfy the constraint: dim1k
On entry: qq[i-1,j-1] must be set equal to an initial estimate of the i,jth element of Σ. 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-1,j-1]=0.0, for i=1,2,,k and j=1,2,,i, then g13dd will calculate the covariance matrix between the k time series and use this as an initial estimate of Σ.
On exit: if ifail=0 or ifail4 then qq[i-1,j-1] will contain the latest estimate of the i,jth element of Σ. The lower triangle only is returned.
w
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, n]
Note: dim1 must satisfy the constraint: dim1k
On entry: w[i-1,t-1] must be set equal to the ith component of Wt, for i=1,2,,k and t=1,2,,n.
parhld
Type: array<System..::..Boolean>[]()[][]
An array of size [npar]
On entry: parhld[i-1] must be set to true if par[i-1] is to be held constant at its input value and false if par[i-1] is a free parameter, for i=1,2,,npar.
If in doubt try setting all elements of parhld to false.
exact
Type: System..::..Boolean
On entry: must be set equal to true if you wish g13dd to compute exact maximum likelihood estimates. exact must be set equal to false if only conditional likelihood estimates are required.
iprint
Type: System..::..Int32
On entry: the frequency with which the automatic monitoring method is to be called.
iprint>0
The ML search procedure is monitored once every iprint iterations and just before exit from the search method.
iprint=0
The search method is monitored once at the final point.
iprint<0
The search method is not monitored at all.
cgetol
Type: System..::..Double
On entry: the accuracy to which the solution in par and qq is required.
If cgetol is set to 10-l and on exit ifail=0 or ifail6, then all the elements in par and qq should be accurate to approximately l decimal places. For most practical purposes the value 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, ε, then g13dd will use the value 10.0×ε instead.
maxcal
Type: System..::..Int32
On entry: the maximum number of likelihood evaluations to be permitted by the search procedure.
Suggested value: maxcal=40×npar×npar+5.
Constraint: maxcal1.
ishow
Type: System..::..Int32
On entry: 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
None of the above are printed.
ishow=1
(i) only is printed.
ishow=2
(i) and (ii) are printed.
Constraint: 0ishow2.
niter
Type: System..::..Int32%
On exit: if ifail=0 or ifail4 then niter contains the number of iterations performed by the search method.
rlogl
Type: System..::..Double%
On exit: if ifail=0 or ifail4 then rlogl contains the value of the log-likelihood function corresponding to the final point held in par and qq.
v
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, n]
Note: dim1 must satisfy the constraint: dim1k
On exit: if ifail=0 or ifail4 then v[i-1,t-1] will contain an estimate of the ith component of εt, for i=1,2,,k and t=1,2,,n, corresponding to the final point held in par and qq.
g
Type: array<System..::..Double>[]()[][]
An array of size [npar]
On exit: if ifail=0 or ifail4 then g[i-1] will contain the estimated first derivative of the log-likelihood function with respect to the ith element in the array par. If the gradient cannot be computed then all the elements of g are returned as zero.
cm
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, npar]
Note: dim1 must satisfy the constraint: dim1npar
On exit: if ifail=0 or ifail4 then cm[i-1,j-1] will contain an estimate of the correlation coefficient between the ith and jth elements in the par array for 1inpar, 1jnpar. If i=j, then cm[i-1,j-1] will contain the estimated standard error of par[i-1]. If the lth component of par has been held constant, i.e., parhld[l-1] was set to true, then the lth 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.
ifail
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

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ϕ=ϕ1I0...0ϕ20I0..0......ϕp-10...0Iϕp0...00pk×pk  and Bθ=θ1I0...0θ20I0..0......θq-10....Iθq0....0qk×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. Similarly, the ARMA model (1) is said to be invertible if the eigenvalues of Bθ 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 Σ.
You have the option of setting a parameter (exact to false) so that g13dd calculates conditional maximum likelihood estimates (conditional on W0=W-1==W1-p=ε0=ε-1==ε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 [Parameters]) of requesting g13dd to constrain elements of the ϕ and θ matrices and μ 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

Error Indicators and Warnings

Note: g13dd may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (KMAX, LDCM) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
ifail=1
On entry,k<1,
orip<0,
oriq<0,
orip=iq=0,
ornparip+iq×k×k+Δ×k, where Δ=1 if mean=true or Δ=0 if mean=false,
orn×knpar+k×k+1/2,
ormaxcal<1,
orishow<0,
orishow>2,
ifail=2
On entry, either the initial estimate of Σ 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
The method 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 Σ 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
There have been maxcal log-likelihood evaluations made in the method. 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 [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.
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, 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 [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.
ifail=6
The ML solution is so close to the boundary of either the stationarity region or the invertibility region that 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.
ifail=7
This is an unlikely exit, which could occur in e04xaa, 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.
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
Internal memory allocation failed.
ifail=-9000
An error occured, see message report.
ifail=-1000
The array lengths are not the same for arrays
ifail=-6000
Invalid Parameters value
ifail=-4000
Invalid dimension for array value
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value

Accuracy

On exit from g13dd, if ifail=0 or ifail6 and cgetol has been set to 10-l, then all the parameters should be accurate to approximately l decimal places. If cgetol was set equal to a value less than the machine precision, ε, then all the parameters should be accurate to approximately 10.0×ε.
If ifail=4 on exit (i.e., maxcal likelihood evaluations have been made but the convergence conditions of the search method 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.

Parallelism and Performance

None.

Further Comments

Memory Usage

Let r=maxip,iq and s=npar+k×k+1/2. Local workspace arrays of fixed lengths are allocated internally by g13dd. The total size of these arrays amounts to s+k×r+52 integer elements and 2×s2+s×s-1/2+15×s+k2×2×ip+iq+r+32+k×2×r2+2×r+3×n+4+10 real 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 g13dd may get into difficulty and exit with ifail=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 (denoted by e^t) can easily be calculated by forming the Cholesky decomposition of Σ, e.g., GGT and setting e^t=G-1ε^t. (F07FDF not in this release) may be used to calculate the array g. The components of 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 (G13DSF not in this release) to provide information for diagnostic checking. (G13DSF not in this release) returns the residual cross-correlation matrices along with their asymptotic standard errors. (G13DSF not in this release) also computes a portmanteau statistic and its asymptotic significance level for testing model adequacy. If ifail=0 or 5ifail8 on exit from g13dd then the quantities output k, n, v, kmax, ip, iq, par, parhld, and qq will be suitable for input to (G13DSF not in this release).

Example

This example shows how to fit a bivariate AR(1) model to two series each of length 48. μ will be estimated and ϕ12,1 will be constrained to be zero.

Example program (C#): g13dde.cs

Example program data: g13dde.d

Example program results: g13dde.r

See Also