hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_tsa_multi_varma_update (g13dk)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

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 Zt = z1t,z2t,,zktT , for t=1,2,,n, denote a k-dimensional time series for which forecasts of Z^n+1,Z^n+2,, Z^n+lmax have been computed using nag_tsa_multi_varma_forecast (g13dj). Given m further observations Zn+1,Zn+2,,Zn+m, where m<lmax, nag_tsa_multi_varma_update (g13dk) updates the forecasts of Zn+m+1,Zn+m+2,,Zn+lmax 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 Zt* denotes the transformed value of Zt and Z^t*l denotes the forecast of Zt+l* from time t with a lead of l (that is the forecast of Zt+l* given observations Zt*,Zt-1*,), then
Z^t+1*l=τ+ψlεt+1+ψl+1εt+ψl+2εt-1+  
and
Z^t*l+ 1=τ+ψl+ 1εt+ψl+ 2εt- 1+  
where τ is a constant vector of length k involving the differencing parameters and the mean vector μ. By subtraction we obtain
Z^t+1*l=Z^t*l+1+ψlεt+1.  
Estimates of the residuals corresponding to the new observations are also computed as εn+l=Zn+l*-Z^n*l, for l=1,2,,m. 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 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

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:     k int64int32nag_int scalar
k, the dimension of the multivariate time series.
Constraint: k1.
2:     mlast 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 0 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: 0mlast<lmax-m.
3:     zkmaxm – double array
kmax, the first dimension of the array, must satisfy the constraint kmaxk.
zij must contain the value of zi,n+mlast+j, for i=1,2,,k and j=1,2,,m, and where n 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 ith series is the log transformation, then zij>0.0, and if it is the square-root transformation, then zij0.0, for j=1,2,,m and i=1,2,,k.
4:     reflref – double array
Must contain the first lmax-1×k×k+2×k×lmax+k 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:     predzkmaxlmax – double array
kmax, the first dimension of the array, must satisfy the constraint kmaxk.
Nonupdated values are kept intact.
6:     sefzkmaxlmax – double array
kmax, the first dimension of the array, must satisfy the constraint kmaxk.
Nonupdated values are kept intact.

Optional Input Parameters

1:     lmax int64int32nag_int scalar
Default: the second dimension of the arrays predz, sefz. (An error is raised if these dimensions are not equal.)
The number, lmax, of forecasts requested in the call to nag_tsa_multi_varma_forecast (g13dj).
Constraint: lmax2.
2:     m int64int32nag_int scalar
Default: the second dimension of the array z.
m, 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 m+mlast.
Constraint: 0<m<lmax-mlast.
3:     lref int64int32nag_int scalar
Default: the dimension of the array ref.
The dimension of the array ref.
Constraint: lreflmax-1×k×k+2×k×lmax+k.

Output Parameters

1:     mlast int64int32nag_int scalar
Is incremented by m to indicate that mlast+m 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 0.
2:     reflref – double array
The elements of ref are updated. The first lmax-1×k×k elements store the ψ weights ψ1,ψ2,,ψlmax-1. The next k×lmax elements contain the forecasts of the transformed series and the next k×lmax 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:     vkmaxm – double array
vij contains an estimate of the ith component of εn+mlast+j, for i=1,2,,k and j=1,2,,m.
4:     predzkmaxlmax – double array
predzij contains the updated forecast of zi,n+j, for i=1,2,,k and j=mlast+m+1,,lmax.
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:     sefzkmaxlmax – double array
sefzij contains an estimate of the standard error of the corresponding element of predz, for i=1,2,,k and j=mlast+m+1,,lmax.
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:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
On entry,k<1,
orlmax<2,
orm0,
ormlast+mlmax,
ormlast<0,
orkmax<k,
orlref<lmax-1×k×k+2×k×lmax+k.
   ifail=2
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)).
   ifail=3
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.
   ifail=4
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.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

The matrix computations are believed to be stable.

Further Comments

If a further m* observations, Zn+mlast+1,Zn+mlast+2,, Zn+mlast+m*, become available, then forecasts of Zn+mlast+m*+1,Zn+mlast+m*+2,, Zn+lmax may be updated by recalling nag_tsa_multi_varma_update (g13dk) with m=m*. 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 εn+mlast+1,εn+mlast+2,, εn+mlast+m*; columns mlast+1,mlast+2,,mlast+m* of predz contain the new observed values Zn+mlast+1,Zn+mlast+2,, Zn+mlast+m* and columns mlast+1,mlast+2,,mlast+m* of sefz are set to zero.

Example

This example shows how to update the forecasts of two series each of length 48. 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 ϕ12,1 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.
function g13dk_example


fprintf('g13dk example results\n\n');

% Series
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);

% Difference /transform series
tr    = {'N'; 'N'};
id    = [int64(0);0];
delta = [0;  0];
[w, nd, ifail] = g13dl( ...
			z, tr, id, delta);

% VARMA info
ip    = int64(1);
iq    = int64(0);
mean_p = true;

% Initial parameter estimates and free parameter flags
par    = zeros(6, 1);
parhld = [false;  false;  true;  false;  false;  false];

% Exact likelihood
exact  = true;
% control parameters
iprint = int64(-1);
cgetol = 0.0001;
ishow  = int64(0);

qq = [0, 0; 0, 0];

% Fit VARMA
[par, qq, ~, ~, v, ~, ~, ifail] = ...
  g13dd( ...
	 ip, iq, mean_p, par, qq, w, parhld, exact, iprint, cgetol, ...
	 ishow, 'n', nd);

% Perform forecast
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);

% Display results
g13dk_print(k,n,lmax,predz,sefz);

% Update forecasts
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);
  % Display results
  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)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015