g13dj computes forecasts of a multivariate time series. It is assumed that a vector ARMA model has already been fitted to the appropriately differenced/transformed time series using g13dd. The standard deviations of the forecast errors are also returned. A reference vector is set up so that, should future series values become available, the forecasts and their standard errors may be updated by calling g13dk.

Syntax

C#
public static void g13dj(
	int k,
	int n,
	double[,] z,
	string[] tr,
	int[] id,
	double[,] delta,
	int ip,
	int iq,
	string mean,
	double[] par,
	double[,] qq,
	double[,] v,
	int lmax,
	double[,] predz,
	double[,] sefz,
	double[] dnref,
	out int ifail
)
Visual Basic
Public Shared Sub g13dj ( _
	k As Integer, _
	n As Integer, _
	z As Double(,), _
	tr As String(), _
	id As Integer(), _
	delta As Double(,), _
	ip As Integer, _
	iq As Integer, _
	mean As String, _
	par As Double(), _
	qq As Double(,), _
	v As Double(,), _
	lmax As Integer, _
	predz As Double(,), _
	sefz As Double(,), _
	dnref As Double(), _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void g13dj(
	int k, 
	int n, 
	array<double,2>^ z, 
	array<String^>^ tr, 
	array<int>^ id, 
	array<double,2>^ delta, 
	int ip, 
	int iq, 
	String^ mean, 
	array<double>^ par, 
	array<double,2>^ qq, 
	array<double,2>^ v, 
	int lmax, 
	array<double,2>^ predz, 
	array<double,2>^ sefz, 
	array<double>^ dnref, 
	[OutAttribute] int% ifail
)
F#
static member g13dj : 
        k : int * 
        n : int * 
        z : float[,] * 
        tr : string[] * 
        id : int[] * 
        delta : float[,] * 
        ip : int * 
        iq : int * 
        mean : string * 
        par : float[] * 
        qq : float[,] * 
        v : float[,] * 
        lmax : int * 
        predz : float[,] * 
        sefz : float[,] * 
        dnref : float[] * 
        ifail : int byref -> unit 

Parameters

k
Type: System..::..Int32
On entry: k, the dimension of the multivariate time series.
Constraint: k1.
n
Type: System..::..Int32
On entry: n, the number of observations in the series, Zt, prior to differencing.
Constraint: n3.
The total number of observations must exceed the total number of parameters in the model; that is
  • if mean="Z", n×k>ip+iq×k×k+k×k+1/2;
  • if mean="M", n×k>ip+iq×k×k+k+k×k+1/2,
(see the parameters ip, iq and mean).
z
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, n]
Note: dim1 must satisfy the constraint: dim1k
On entry: z[i,t] must contain, zit, the ith component of Zt, for i=1,2,,k and t=1,2,,n.
Constraints:
  • if tr[i-1]="L", z[i,t]>0.0;
  • if tr[i-1]="S", z[i,t]0.0, for i=0,1,,k-1 and t=0,1,,n-1.
tr
Type: array<System..::..String>[]()[][]
An array of size [k]
On entry: tr[i-1] indicates whether the ith time series is to be transformed, for i=1,2,,k.
tr[i-1]="N"
No transformation is used.
tr[i-1]="L"
A log transformation is used.
tr[i-1]="S"
A square root transformation is used.
Constraint: tr[i-1]="N", "L" or "S", for i=1,2,,k.
id
Type: array<System..::..Int32>[]()[][]
An array of size [k]
On entry: id[i-1] must specify, di, the order of differencing required for the ith series.
Constraint: 0id[i-1]<n-maxip,iq, for i=1,2,,k.
delta
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, dim2]
Note: dim1 must satisfy the constraint: dim1k
Note: the second dimension of the array delta must be at least max1,d, where d=maxid[i-1].
On entry: if id[i-1]>0, then delta[i-1,j-1] must be set equal to δij, for j=1,2,,di and i=1,2,,k.
If d=0, delta is not referenced.
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.
mean
Type: System..::..String
On entry: mean="M", if components of μ have been estimated and mean="Z", if all elements of μ are to be taken as zero.
Constraint: mean="M" or "Z".
par
Type: array<System..::..Double>[]()[][]
An array of size [lpar]
On entry: must contain the 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 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 estimate of the i,jth element of θl, for l=1,2,,q, i=1,2,,k and j=1,2,,k;
  • if mean="M", par[p+q×k×k+i-1] must be set equal to an estimate of the ith component of μ, for i=1,2,,k.
Constraint: the first ip×k×k elements of par must satisfy the stationarity condition and the next iq×k×k elements of par must satisfy the invertibility condition.
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 contain an estimate of the i,jth element of Σ. The lower triangle only is needed.
Constraint: qq must be positive definite.
On exit: if ifail1, then the upper triangle is set equal to the lower triangle.
v
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, dim2]
Note: dim1 must satisfy the constraint: dim1k
Note: the second dimension of the array v must be at least max1,n-d, where d=maxid[i-1].
On entry: v[i-1,t-1] must contain an estimate of the ith component of εt+d, for i=1,2,,k and t=1,2,,n-d.
If q=0, v is not used.
lmax
Type: System..::..Int32
On entry: the number, lmax, of forecasts required.
Constraint: lmax1.
predz
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, lmax]
Note: dim1 must satisfy the constraint: dim1k
On exit: predz[i-1,l-1] contains the forecast of zi,n+l, for i=1,2,,k and l=1,2,,lmax.
sefz
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, lmax]
Note: dim1 must satisfy the constraint: dim1k
On exit: sefz[i-1,l-1] contains an estimate of the standard error of the forecast of zi,n+l, for i=1,2,,k and l=1,2,,lmax.
dnref
Type: array<System..::..Double>[]()[][]
An array of size [lref]
On exit: the reference vector which may be used to update forecasts using g13dk. The first lmax-1×k×k elements contain the ψ weight matrices, ψ1,ψ2,,ψlmax-1. The next k×lmax elements contain the forecasts of the transformed series Z^n+1*,Z^n+2*,,Z^n+lmax* and the next k×lmax contain the variances of the forecasts of the transformed variables. The last k elements are used to store the transformations for the series.
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 the vector Zt=z1t,z2t,,zktT, for t=1,2,,n, denote a k-dimensional time series for which forecasts of Zn+1,Zn+2,,Zn+lmax are required. Let Wt=w1t,w2t,,wktT be defined as follows:
wit=δiBzit*,  i=1,2,,k,
where δiB is the differencing operator applied to the ith series and where zit* is equal to either zit, zit or logezit depending on whether or not a transformation was required to stabilize the variance before fitting the model.
If the order of differencing required for the ith series is di, then the differencing operator for the ith series is defined by δiB=1-δi1B-δi2B2--δidiBdi where B is the backward shift operator; that is, BZt=Zt-1. The differencing parameters δij, for i=1,2,,k and j=1,2,,di, must be supplied by you. If the ith series does not require differencing, then di=0.
Wt is assumed to follow a multivariate ARMA model of the form:
Wt-μ=ϕ1Wt-1-μ+ϕ2Wt-2-μ++ϕpWt-p-μ+εt-θ1εt-1--θ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. The matrices ϕi, for i=1,2,,p, are the autoregressive (AR) parameter matrices, and the matrices θ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 Σ. The ARMA model (1) must be both stationary and invertible; see g13dx for a method of checking these conditions.
The ARMA model (1) may be rewritten as
ϕBδBZt*-μ=θBεt,
where ϕB and θB are the autoregressive and moving average polynomials and δB denotes the k by k diagonal matrix whose ith diagonal elements is δiB and Zt*=z1t*,z2t*zkt*T.
This may be rewritten as
ϕBδBZt*=ϕBμ+θBεt
or
Zt*=τ+ψBεt=τ+εt+ψ1εt-1+ψ2εt-2+
where ψB=δ-1Bϕ-1BθB and τ=δ-1Bμ is a vector of length k.
Forecasts are computed using a multivariate version of the procedure described in Box and Jenkins (1976). If Z^n*l denotes the forecast of Zn+l*, then Z^n*l is taken to be that linear function of Zn*,Zn-1*, which minimizes the elements of Eenlenl where enl=Zn+l*-Z^n*l is the forecast error. Z^n*l is referred to as the linear minimum mean square error forecast of Zn+l*.
The linear predictor which minimizes the mean square error may be expressed as
Z^n*l=τ+ψlεn+ψl+1εn-1+ψl+2εn-2+.
The forecast error at t for lead l is then
enl=Zn+l*-Z^n*l=εn+l+ψ1εn+l-1+ψ2εn+l-2++ψl-1εn+1.
Let d=maxdi, for i=1,2,,k. Unless q=0 the method requires estimates of εt, for t=d+1,,n, which are obtainable from g13dd. The terms εt are assumed to be zero, for t=n+1,,n+lmax. You may use g13dk to update these lmax forecasts should further observations, Zn+1,Zn+2,, become available. Note that when lmax or more further observations are available then g13dj must be used to produce new forecasts for Zn+lmax+1,Zn+lmax+2,, should they be required.
When a transformation has been used the forecasts and their standard errors are suitably modified to give results in terms of the original series, Zt; see Granger and Newbold (1976).

References

Box G E P and Jenkins G M (1976) Time Series Analysis: Forecasting and Control (Revised Edition) Holden–Day
Granger C W J and Newbold P (1976) Forecasting transformed series J. Roy. Statist. Soc. Ser. B 38 189–203
Wei W W S (1990) Time Series Analysis: Univariate and Multivariate Methods Addison–Wesley

Error Indicators and Warnings

Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (KMAX) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
ifail=1
On entry,k<1,
orn<3,
orid[i-1]<0 for some i=1,2,,k,
orid[i-1]n-maxip,iq for some i=1,2,,k,
orip<0,
oriq<0,
ormean"M" or "Z",
orlpar<ip+iq×k×k+k, and mean="M",
orlpar<ip+iq×k×k and mean="Z",
orn×kip+iq×k×k+k+k[k]/2, and mean="M",
orn×kip+iq×k×k+k[k]/2 and mean="Z",
orlmax<1,
orlref<lmax-1×k×k+2×k×lmax+k,
orlwork is too small,
orliwork is too small.
ifail=2
On entry,at least one of the first k elements of tr is not equal to "N", "L" or "S".
ifail=3
On entry, one or more of the transformations requested cannot be computed; that is, you may be trying to log or square-root a series, some of whose values are negative.
ifail=4
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.
ifail=5
This is an unlikely exit brought about by an excessive number of iterations being needed to evaluate the eigenvalues of the matrices required to check for stationarity and invertibility; see g13dx. All output parameters are undefined.
ifail=6
This is an unlikely exit which could occur if qq is nearly non positive definite. In this case the standard deviations of the forecast errors may be non-positive. To proceed, you must supply different parameter estimates in the array qq.
ifail=7
This is an unlikely exit. For one of the series, overflow will occur if the forecasts are computed. You should check whether the transformations requested in the array tr are sensible. All output parameters are undefined.
ifail=-9000
An error occured, see message report.
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

The matrix computations are believed to be stable.

Parallelism and Performance

None.

Further Comments

The same differencing operator does not have to be applied to all the series. For example, suppose we have k=2, and wish to apply the second order differencing operator 2 to the first series and the first-order differencing operator  to the second series:
w1t=2z1t=1-B2z1t=1-2B+B2Z1t,   andw2t=z2t=1-Bz2t.
Then d1=2,d2=1, d=maxd1,d2=2, and
delta=δ11δ12δ21=2-11.
Note:  although differencing may already have been applied prior to the model fitting stage, the differencing parameters supplied in delta are part of the model definition and are still required by this method to produce the forecasts.
g13dj should not be used when the moving average parameters lie close to the boundary of the invertibility region. The method does test for both invertibility and stationarity but if in doubt, you may use g13dx, before calling this method, to check that the VARMA model being used is invertible.
On a successful exit, the quantities k, lmax, kmax, ref and lref will be suitable for input to g13dk.

Example

See Also