PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_tsa_multi_varma_forecast (g13dj)
Purpose
nag_tsa_multi_varma_forecast (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
nag_tsa_multi_varma_estimate (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
nag_tsa_multi_varma_update (g13dk).
Syntax
[
qq,
predz,
sefz,
ref,
ifail] = g13dj(
z,
tr,
id,
delta,
ip,
iq,
mean_p,
par,
qq,
v,
lmax,
lref, 'k',
k, 'n',
n, 'lpar',
lpar)
[
qq,
predz,
sefz,
ref,
ifail] = nag_tsa_multi_varma_forecast(
z,
tr,
id,
delta,
ip,
iq,
mean_p,
par,
qq,
v,
lmax,
lref, 'k',
k, 'n',
n, 'lpar',
lpar)
Description
Let the vector
, for
, denote a
-dimensional time series for which forecasts of
are required. Let
be defined as follows:
where
is the differencing operator applied to the
th series and where
is equal to either
,
or
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 th series is , then the differencing operator for the th series is defined by where is the backward shift operator; that is, . The differencing parameters , for and , must be supplied by you. If the th series does not require differencing, then .
is assumed to follow a multivariate ARMA model of the form:
where
, for
, is a vector of
residual series assumed to be Normally distributed with zero mean and positive definite covariance matrix
. The components of
are assumed to be uncorrelated at non-simultaneous lags. The
and
are
by
matrices of parameters. The matrices
, for
, are the autoregressive (AR) parameter matrices, and the matrices
, for
, the moving average (MA) parameter matrices. The parameters in the model are thus the
(
by
)
-matrices, the
(
by
)
-matrices, the mean vector
and the residual error covariance matrix
. The ARMA model
(1) must be both stationary and invertible; see
nag_tsa_uni_arma_roots (g13dx) for a method of checking these conditions.
The ARMA model
(1) may be rewritten as
where
and
are the autoregressive and moving average polynomials and
denotes the
by
diagonal matrix whose
th diagonal elements is
and
.
This may be rewritten as
or
where
and
is a vector of length
.
Forecasts are computed using a multivariate version of the procedure described in
Box and Jenkins (1976). If
denotes the forecast of
, then
is taken to be that linear function of
which minimizes the elements of
where
is the forecast error.
is referred to as the linear minimum mean square error forecast of
.
The linear predictor which minimizes the mean square error may be expressed as
The forecast error at
for lead
is then
Let
, for
. Unless
the function requires estimates of
, for
, which are obtainable from
nag_tsa_multi_varma_estimate (g13dd).
The terms
are assumed to be zero, for
. You may use
nag_tsa_multi_varma_update (g13dk) to update these
forecasts should further observations,
, become available. Note that when
or more further observations are available then
nag_tsa_multi_varma_forecast (g13dj) must be used to produce new forecasts for
, 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,
; 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
Parameters
The quantities
k,
n,
kmax,
ip,
iq,
par,
npar,
qq and
v from
nag_tsa_multi_varma_estimate (g13dd)
are suitable for input to
nag_tsa_multi_varma_forecast (g13dj).
Compulsory Input Parameters
- 1:
– double array
-
kmax, the first dimension of the array, must satisfy the constraint
.
must contain, , the th component of , for and .
Constraints:
- if , ;
- if , , for and .
- 2:
– cell array of strings
-
indicates whether the
th time series is to be transformed, for
.
- No transformation is used.
- A log transformation is used.
- A square root transformation is used.
Constraint:
, or , for .
- 3:
– int64int32nag_int array
-
must specify, , the order of differencing required for the th series.
Constraint:
, for .
- 4:
– double array
-
The first dimension of the array
delta must be at least
.
The second dimension of the array
delta must be at least
, where
.
If
, then
must be set equal to
, for
and
.
If
,
delta is not referenced.
- 5:
– int64int32nag_int scalar
-
, the number of AR parameter matrices.
Constraint:
.
- 6:
– int64int32nag_int scalar
-
, the number of MA parameter matrices.
Constraint:
.
- 7:
– string (length ≥ 1)
-
, if components of have been estimated and , if all elements of are to be taken as zero.
Constraint:
or .
- 8:
– double array
-
Must contain the parameter estimates read in row by row in the order
,
,
.
Thus,
- if ,
must be set equal to an estimate of the th element of , for , and ;
- if ,
must be set equal to an estimate of the th element of , for , and ;
- if ,
must be set equal to an estimate of the th component of , for .
Constraint:
the first
elements of
par must satisfy the stationarity condition and the next
elements of
par must satisfy the invertibility condition.
- 9:
– double array
-
kmax, the first dimension of the array, must satisfy the constraint
.
must contain an estimate of the th element of . The lower triangle only is needed.
Constraint:
must be positive definite.
- 10:
– double array
-
The first dimension of the array
v must be at least
.
The second dimension of the array
v must be at least
, where
.
must contain an estimate of the
th component of
, for
and
.
- 11:
– int64int32nag_int scalar
-
The number, , of forecasts required.
Constraint:
.
- 12:
– int64int32nag_int scalar
-
The dimension of the array
ref.
Constraint:
.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the arrays
tr,
id and the first dimension of the arrays
z,
delta,
qq,
v and the second dimension of the array
qq. (An error is raised if these dimensions are not equal.)
, the dimension of the multivariate time series.
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the second dimension of the array
z.
, the number of observations in the series, , prior to differencing.
Constraint:
.
The total number of observations must exceed the total number of parameters in the model; that is
- if , ;
- if , ,
(see the arguments
ip,
iq and
mean_p).
- 3:
– int64int32nag_int scalar
-
Default:
the dimension of the array
par.
The dimension of the array
par.
Constraints:
- if , ;
- if , .
Output Parameters
- 1:
– double array
-
If , then the upper triangle is set equal to the lower triangle.
- 2:
– double array
-
contains the forecast of , for and .
- 3:
– double array
-
contains an estimate of the standard error of the forecast of , for and .
- 4:
– double array
-
The reference vector which may be used to update forecasts using
nag_tsa_multi_varma_update (g13dk). The first
elements contain the
weight matrices,
. The next
elements contain the forecasts of the transformed series
and the next
contain the variances of the forecasts of the transformed variables. The last
k elements are used to store the transformations for the series.
- 5:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
On entry, | , |
or | , |
or | , |
or | for some , |
or | for some , |
or | , |
or | , |
or | or , |
or | , and , |
or | and , |
or | , and , |
or | and , |
or | , |
or | , |
or | lwork is too small, |
or | liwork is too small. |
-
-
On entry, | at least one of the first elements of tr is not equal to 'N', 'L' or 'S'. |
-
-
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.
-
-
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.
-
-
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
nag_tsa_uni_arma_roots (g13dx). All output arguments are undefined.
-
-
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.
-
-
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 arguments are undefined.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
The matrix computations are believed to be stable.
Further Comments
The same differencing operator does not have to be applied to all the series. For example, suppose we have
, and wish to apply the second order differencing operator
to the first series and the first-order differencing operator
to the second series:
Then
,
, and
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 function to produce the forecasts.
nag_tsa_multi_varma_forecast (g13dj) should not be used when the moving average parameters lie close to the boundary of the invertibility region. The function does test for both invertibility and stationarity but if in doubt, you may use
nag_tsa_uni_arma_roots (g13dx), before calling this function, 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
nag_tsa_multi_varma_update (g13dk).
Example
This example computes forecasts of the next five values in two series each of length
. No transformation is to be used and no differencing is to be applied to either of the series.
nag_tsa_multi_varma_estimate (g13dd)
is first called to fit an AR(1) model to the series. The mean vector
is to be estimated and
constrained to be zero.
Open in the MATLAB editor:
g13dj_example
function g13dj_example
fprintf('g13dj example results\n\n');
z = [-1.490 -1.620 5.200 6.230 6.210 5.860 4.090 3.180 ...
2.620 1.490 1.170 0.850 -0.350 0.240 2.440 2.580 ...
2.040 0.400 2.260 3.340 5.090 5.000 4.780 4.110 ...
3.450 1.650 1.290 4.090 6.320 7.500 3.890 1.580 ...
5.210 5.250 4.930 7.380 5.870 5.810 9.680 9.070 ...
7.290 7.840 7.550 7.320 7.970 7.760 7.000 8.350;
7.340 6.350 6.960 8.540 6.620 4.970 4.550 4.810 ...
4.750 4.760 10.880 10.010 11.620 10.360 6.400 6.240 ...
7.930 4.040 3.730 5.600 5.350 6.810 8.270 7.680 ...
6.650 6.080 10.250 9.140 17.750 13.300 9.630 6.800 ...
4.080 5.060 4.940 6.650 7.940 10.760 11.890 5.850 ...
9.010 7.500 10.020 10.380 8.150 8.370 10.730 12.140];
[k,n] = size(z);
tr = {'N'; 'N'};
id = [int64(0);0];
delta = [0; 0];
[w, nd, ifail] = g13dl( ...
z, tr, id, delta);
ip = int64(1);
iq = int64(0);
mean_p = true;
par = zeros(6, 1);
parhld = [false; false; true; false; false; false];
exact = true;
iprint = int64(-1);
cgetol = 0.0001;
ishow = int64(0);
qq = [0, 0; 0, 0];
[par, qq, ~, ~, v, ~, ~, ifail] = ...
g13dd( ...
ip, iq, mean_p, par, qq, w, parhld, exact, iprint, cgetol, ...
ishow, 'n', nd);
lmax = int64(5);
lref = int64(150);
mean_p = 'M';
[qq, predz, sefz, ref, ifail] = ...
g13dj( ...
z, tr, id, delta, ip, iq, mean_p, par, qq, v, lmax, lref);
fprintf(' Forecast Summary Table\n');
fprintf(' ----------------------\n\n');
fprintf(' Forecast origin is set at t = %4d\n\n', n);
loop = lmax/5;
if mod(lmax,5)~=0
loop = loop + 1;
end
for j = 1:loop
i2 = (j-1)*5;
l2 = min(i2+5,lmax);
fprintf('Lead Time %14s',' ');
fprintf('%7d', [i2+1:l2]);
fprintf('\n\n');
for i = 1:k
fprintf('Series %d : Forecast ', i);
fprintf('%7.2f',predz(i,i2+1:l2));
fprintf('\n%8s : Standard Error ', ' ');
fprintf('%7.2f',sefz(i,i2+1:l2));
fprintf('\n');
end
end
g13dj example results
Forecast Summary Table
----------------------
Forecast origin is set at t = 48
Lead Time 1 2 3 4 5
Series 1 : Forecast 7.82 7.28 6.77 6.33 5.95
: Standard Error 1.72 2.23 2.51 2.68 2.79
Series 2 : Forecast 10.31 9.25 8.65 8.30 8.10
: Standard Error 2.32 2.68 2.78 2.82 2.83
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015