NAG FL Interface
g13djf (multi_varma_forecast)
1
Purpose
g13djf 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
g13ddf.
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
g13dkf.
2
Specification
Fortran Interface
Subroutine g13djf ( |
k, n, z, kmax, tr, id, delta, ip, iq, mean, par, lpar, qq, v, lmax, predz, sefz, ref, lref, work, lwork, iwork, liwork, ifail) |
Integer, Intent (In) |
:: |
k, n, kmax, id(k), ip, iq, lpar, lmax, lref, lwork, liwork |
Integer, Intent (Inout) |
:: |
ifail |
Integer, Intent (Out) |
:: |
iwork(liwork) |
Real (Kind=nag_wp), Intent (In) |
:: |
z(kmax,n), delta(kmax,*), par(lpar), v(kmax,*) |
Real (Kind=nag_wp), Intent (Inout) |
:: |
qq(kmax,k), predz(kmax,lmax), sefz(kmax,lmax) |
Real (Kind=nag_wp), Intent (Out) |
:: |
ref(lref), work(lwork) |
Character (1), Intent (In) |
:: |
tr(k), mean |
|
C Header Interface
#include <nag.h>
void |
g13djf_ (const Integer *k, const Integer *n, const double z[], const Integer *kmax, const char tr[], const Integer id[], const double delta[], const Integer *ip, const Integer *iq, const char *mean, const double par[], const Integer *lpar, double qq[], const double v[], const Integer *lmax, double predz[], double sefz[], double ref[], const Integer *lref, double work[], const Integer *lwork, Integer iwork[], const Integer *liwork, Integer *ifail, const Charlen length_tr, const Charlen length_mean) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
g13djf_ (const Integer &k, const Integer &n, const double z[], const Integer &kmax, const char tr[], const Integer id[], const double delta[], const Integer &ip, const Integer &iq, const char *mean, const double par[], const Integer &lpar, double qq[], const double v[], const Integer &lmax, double predz[], double sefz[], double ref[], const Integer &lref, double work[], const Integer &lwork, Integer iwork[], const Integer &liwork, Integer &ifail, const Charlen length_tr, const Charlen length_mean) |
}
|
The routine may be called by the names g13djf or nagf_tsa_multi_varma_forecast.
3
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
g13dxf 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 routine requires estimates of
, for
, which are obtainable from
g13ddf.
The terms
are assumed to be zero, for
. You may use
g13dkf to update these
forecasts should further observations,
, become available. Note that when
or more further observations are available then
g13djf 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).
4
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
5
Arguments
The quantities
k,
n,
kmax,
ip,
iq,
par,
npar,
qq and
v from
g13ddf
are suitable for input to
g13djf.
-
1:
– Integer
Input
-
On entry: , the dimension of the multivariate time series.
Constraint:
.
-
2:
– Integer
Input
-
On entry: , 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).
-
3:
– Real (Kind=nag_wp) array
Input
-
On entry: must contain, , the th component of , for and .
Constraints:
- if , ;
- if ,
, for and .
-
4:
– Integer
Input
-
On entry: the first dimension of the arrays
z,
delta,
qq,
v,
predz and
sefz as declared in the (sub)program from which
g13djf is called.
Constraint:
.
-
5:
– Character(1) array
Input
-
On entry:
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 .
-
6:
– Integer array
Input
-
On entry: must specify, , the order of differencing required for the th series.
Constraint:
, for .
-
7:
– Real (Kind=nag_wp) array
Input
-
Note: the second dimension of the array
delta
must be at least
, where
.
On entry: if
, then
must be set equal to
, for
and
.
If
,
delta is not referenced.
-
8:
– Integer
Input
-
On entry: , the number of AR parameter matrices.
Constraint:
.
-
9:
– Integer
Input
-
On entry: , the number of MA parameter matrices.
Constraint:
.
-
10:
– Character(1)
Input
-
On entry: , if components of have been estimated and , if all elements of are to be taken as zero.
Constraint:
or .
-
11:
– Real (Kind=nag_wp) array
Input
-
On entry: 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.
-
12:
– Integer
Input
-
On entry: the dimension of the array
par as declared in the (sub)program from which
g13djf is called.
Constraints:
- if , ;
- if , .
-
13:
– Real (Kind=nag_wp) array
Input/Output
-
On entry: must contain an estimate of the th element of . The lower triangle only is needed.
Constraint:
must be positive definite.
On exit: if , then the upper triangle is set equal to the lower triangle.
-
14:
– Real (Kind=nag_wp) array
Input
-
Note: the second dimension of the array
v
must be at least
, where
.
On entry:
must contain an estimate of the
th component of
, for
and
.
-
15:
– Integer
Input
-
On entry: the number, , of forecasts required.
Constraint:
.
-
16:
– Real (Kind=nag_wp) array
Output
-
On exit: contains the forecast of , for and .
-
17:
– Real (Kind=nag_wp) array
Output
-
On exit: contains an estimate of the standard error of the forecast of , for and .
-
18:
– Real (Kind=nag_wp) array
Output
-
On exit: the reference vector which may be used to update forecasts using
g13dkf. 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.
-
19:
– Integer
Input
-
On entry: the dimension of the array
ref as declared in the (sub)program from which
g13djf is called.
Constraint:
.
-
20:
– Real (Kind=nag_wp) array
Workspace
-
21:
– Integer
Input
-
On entry: the dimension of the array
work as declared in the (sub)program from which
g13djf is called.
Constraint:
if and , for , .
-
22:
– Integer array
Workspace
-
23:
– Integer
Input
-
On entry: the dimension of the array
iwork as declared in the (sub)program from which
g13djf is called.
Constraint:
.
-
24:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 4 in the Introduction to the NAG Library FL Interface for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this argument, the recommended value is
.
When the value is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On entry, , and .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, and .
Constraint: .
On entry, and the minimum size .
Constraint: .
On entry, .
Constraint: .
On entry,
lpar is too small:
and the minimum size
.
On entry, and the minimum size .
Constraint: .
On entry,
lwork is too small:
and the minimum size
.
On entry,
mean is an invalid character.
Constraint:
or
.
On entry, .
Constraint: .
On entry, number of observations and number of parameters .
Constraint: number of of parameters.
-
On entry, and is invalid.
Constraint: , or .
-
On entry, one (or more) of the transformations requested is invalid. Check that you are not trying to log or square-root a series, some of whose values are negative.
-
On entry, the AR parameter matrices are outside the stationarity region. To proceed you must supply different parameter estimates in the arrays
par and
qq.
On entry, the covariance matrix
qq is not positive definite. To proceed you must supply different parameter estimates in the arrays
par and
qq.
On entry, the MA parameter matrices are outside the invertibility region. To proceed you must supply different parameter estimates in the arrays
par and
qq.
-
An excessive number of iterations were needed to evaluate the eigenvalues of the matrices used to test for stationarity and invertibility.
-
The covariance matrix may be 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.
-
The forecasts will overflow if computed. You should check whether the transformations requested in the array
tr are sensible.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See
Section 9 in the Introduction to the NAG Library FL Interface for further information.
7
Accuracy
The matrix computations are believed to be stable.
8
Parallelism and Performance
g13djf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g13djf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
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 routine to produce the forecasts.
g13djf should not be used when the moving average parameters lie close to the boundary of the invertibility region. The routine does test for both invertibility and stationarity but if in doubt, you may use
g13dxf, before calling this routine, 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
g13dkf.
10
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.
g13ddf
is first called to fit an AR(1) model to the series. The mean vector
is to be estimated and
constrained to be zero.
10.1
Program Text
10.2
Program Data
10.3
Program Results