PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_tsa_multi_varma_update (g13dk)
Purpose
nag_tsa_multi_varma_update (g13dk) accepts a sequence of new observations in a multivariate time series and updates both the forecasts and the standard deviations of the forecast errors. A call to
nag_tsa_multi_varma_forecast (g13dj) must be made prior to calling this function in order to calculate the elements of a reference vector together with a set of forecasts and their standard errors. On a successful exit from
nag_tsa_multi_varma_update (g13dk) the reference vector is updated so that should future series values become available these forecasts may be updated by recalling
nag_tsa_multi_varma_update (g13dk).
Syntax
[
mlast,
ref,
v,
predz,
sefz,
ifail] = g13dk(
k,
mlast,
z,
ref,
predz,
sefz, 'lmax',
lmax, 'm',
m, 'lref',
lref)
[
mlast,
ref,
v,
predz,
sefz,
ifail] = nag_tsa_multi_varma_update(
k,
mlast,
z,
ref,
predz,
sefz, 'lmax',
lmax, 'm',
m, 'lref',
lref)
Description
Let
, for
, denote a
-dimensional time series for which forecasts of
have been computed using
nag_tsa_multi_varma_forecast (g13dj). Given
further observations
, where
,
nag_tsa_multi_varma_update (g13dk) updates the forecasts of
and their corresponding standard errors.
nag_tsa_multi_varma_update (g13dk) uses a multivariate version of the procedure described in
Box and Jenkins (1976). The forecasts are updated using the
weights, computed in
nag_tsa_multi_varma_forecast (g13dj). If
denotes the transformed value of
and
denotes the forecast of
from time
with a lead of
(that is the forecast of
given observations
), then
and
where
is a constant vector of length
involving the differencing parameters and the mean vector
. By subtraction we obtain
Estimates of the residuals corresponding to the new observations are also computed as
, for
. These may be of use in checking that the new observations conform to the previously fitted model.
On a successful exit, the reference array is updated so that
nag_tsa_multi_varma_update (g13dk) may be called again should future series values become available, see
Further Comments.
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,
lmax,
kmax,
ref and
lref from
nag_tsa_multi_varma_forecast (g13dj)
are suitable for input to
nag_tsa_multi_varma_update (g13dk).
Compulsory Input Parameters
- 1:
– int64int32nag_int scalar
-
, the dimension of the multivariate time series.
Constraint:
.
- 2:
– int64int32nag_int scalar
-
On the first call to
nag_tsa_multi_varma_update (g13dk), since calling
nag_tsa_multi_varma_forecast (g13dj),
mlast must be set to
to indicate that no new observations have yet been used to update the forecasts; on subsequent calls
mlast must contain the value of
mlast as output on the previous call to
nag_tsa_multi_varma_update (g13dk).
Constraint:
.
- 3:
– double array
-
kmax, the first dimension of the array, must satisfy the constraint
.
must contain the value of
, for
and
, and where
is the number of observations in the time series in the last call made to
nag_tsa_multi_varma_forecast (g13dj).
Constraint:
if the transformation defined in
tr in
nag_tsa_multi_varma_forecast (g13dj) for the
th series is the log transformation, then
, and if it is the square-root transformation, then
, for
and
.
- 4:
– double array
-
Must contain the first
elements of the reference vector as returned on a successful exit from
nag_tsa_multi_varma_forecast (g13dj) (or a previous call to
nag_tsa_multi_varma_update (g13dk)).
- 5:
– double array
-
kmax, the first dimension of the array, must satisfy the constraint
.
Nonupdated values are kept intact.
- 6:
– double array
-
kmax, the first dimension of the array, must satisfy the constraint
.
Nonupdated values are kept intact.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the second dimension of the arrays
predz,
sefz. (An error is raised if these dimensions are not equal.)
The number,
, of forecasts requested in the call to
nag_tsa_multi_varma_forecast (g13dj).
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the second dimension of the array
z.
, the number of new observations available since the last call to either
nag_tsa_multi_varma_forecast (g13dj) or
nag_tsa_multi_varma_update (g13dk). The number of new observations since the last call to
nag_tsa_multi_varma_forecast (g13dj) is then
.
Constraint:
.
- 3:
– int64int32nag_int scalar
-
Default:
the dimension of the array
ref.
The dimension of the array
ref.
Constraint:
.
Output Parameters
- 1:
– int64int32nag_int scalar
-
Is incremented by
to indicate that
observations have now been used to update the forecasts since the last call to
nag_tsa_multi_varma_forecast (g13dj).
mlast must not be changed between calls to
nag_tsa_multi_varma_update (g13dk), unless a call to
nag_tsa_multi_varma_forecast (g13dj) has been made between the calls in which case
mlast should be reset to
.
- 2:
– double array
-
The elements of
ref are updated. The first
elements store the
weights
. The next
elements contain the forecasts of the transformed series and the next
elements contain the variances of the forecasts of the transformed variables; see
nag_tsa_multi_varma_forecast (g13dj). The last
k elements are not updated.
- 3:
– double array
-
contains an estimate of the th component of , for and .
- 4:
– double array
-
contains the updated forecast of
, for
and
.
The columns of
predz corresponding to the new observations since the last call to either
nag_tsa_multi_varma_forecast (g13dj) or
nag_tsa_multi_varma_update (g13dk) are set equal to the corresponding columns of
z.
- 5:
– double array
-
contains an estimate of the standard error of the corresponding element of
predz, for
and
.
The columns of
sefz corresponding to the new observations since the last call to either
nag_tsa_multi_varma_forecast (g13dj) or
nag_tsa_multi_varma_update (g13dk) are set equal to zero.
- 6:
– 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 | , |
or | , |
or | , |
or | . |
-
-
On entry, some of the elements of the reference vector,
ref, have been corrupted since the most recent call to
nag_tsa_multi_varma_forecast (g13dj) (or
nag_tsa_multi_varma_update (g13dk)).
-
-
On entry, one or more of the elements of
z is invalid, for the transformation being used; that is you may be trying to log or square root a series, some of whose values are negative.
-
-
This is an unlikely exit. For one of the series, overflow will occur if the forecasts are updated. You should check whether the elements of
ref have been corrupted.
-
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
If a further
observations,
, become available, then forecasts of
may be updated by recalling
nag_tsa_multi_varma_update (g13dk) with
. Note that
m and the contents of the array
z are the only quantities which need updating;
mlast is updated on exit from the previous call. On a successful exit,
v contains estimates of
; columns
of
predz contain the new observed values
and columns
of
sefz are set to zero.
Example
This example shows how to update the forecasts of two series each of length
. No transformation has been used and no differencing applied to either of the series.
nag_tsa_multi_varma_estimate (g13dd)
is first called to fit an AR(1) model to the series.
is to be estimated and
constrained to be zero. A call to
nag_tsa_multi_varma_forecast (g13dj) is then made in order to compute forecasts of the next five series values. After one new observation becomes available the four forecasts are updated. A further observation becomes available and the three forecasts are updated.
Open in the MATLAB editor:
g13dk_example
function g13dk_example
fprintf('g13dk 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);
g13dk_print(k,n,lmax,predz,sefz);
m = int64([1; 1]);
z = [ 8.1 8.5;
10.2 10.0];
mlast = int64(0);
for j = 1:numel(m)
[mlast, ref, ~, predz, sefz, ifail] = ...
g13dk( ...
int64(k), mlast, z(:,j), ref, predz, sefz);
g13dk_print(k,n+mlast,lmax,predz,sefz);
end
function g13dk_print(k,n,lmax,predz,sefz)
fprintf('\n 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
g13dk 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
Forecast Summary Table
----------------------
Forecast origin is set at t = 49
Lead Time 1 2 3 4 5
Series 1 : Forecast 8.10 7.49 6.94 6.46 6.06
: Standard Error 0.00 1.72 2.23 2.51 2.68
Series 2 : Forecast 10.20 9.19 8.61 8.28 8.08
: Standard Error 0.00 2.32 2.68 2.78 2.82
Forecast Summary Table
----------------------
Forecast origin is set at t = 50
Lead Time 1 2 3 4 5
Series 1 : Forecast 8.10 8.50 7.80 7.18 6.65
: Standard Error 0.00 0.00 1.72 2.23 2.51
Series 2 : Forecast 10.20 10.00 9.08 8.54 8.24
: Standard Error 0.00 0.00 2.32 2.68 2.78
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015