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_uni_arima_forecast_state (g13ah)


    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example


nag_tsa_uni_arima_forecast_state (g13ah) produces forecasts of a time series, given a time series model which has already been fitted to the time series using nag_tsa_uni_arima_estim (g13ae) or nag_tsa_uni_arima_estim_easy (g13af). The original observations are not required, since nag_tsa_uni_arima_forecast_state (g13ah) uses as input either the original state set produced by nag_tsa_uni_arima_estim (g13ae) or nag_tsa_uni_arima_estim_easy (g13af) or the state set updated by a series of new observations using nag_tsa_uni_arima_update (g13ag). Standard errors of the forecasts are also provided.


[fva, fsd, ifail] = g13ah(st, mr, par, c, rms, nfv, 'nst', nst, 'npar', npar)
[fva, fsd, ifail] = nag_tsa_uni_arima_forecast_state(st, mr, par, c, rms, nfv, 'nst', nst, 'npar', npar)


The original time series is xt, for t=1,2,,n and parameters have been fitted to the model of this time series using nag_tsa_uni_arima_estim (g13ae) or nag_tsa_uni_arima_estim_easy (g13af).
Forecasts of xt, for t=n+1,,n+L, are calculated in five stages, as follows:
(i) set at=0 for t=N+1,N+2,,N+L, where N=n-d-D×s is the number of differenced values in the series;
(ii) calculate the values of et, for t=N+1,,N+L, and et=ϕ1×et-1++ ϕp×et-p+at-θ1×at-1--θq×at-q;
(iii) calculate the values of wt, for t=N+1,,N+L, where wt=Φ1×wt-s++ ΦP×wt-s×P+et-Θ1×et-s--ΘQ×et-s×Q and wt for tN are the first s×P values in the state set, corrected for the constant;
(iv) add the constant term c to give the differenced series dsDxt=wt+c, for t=N+1,,N+L;
(v) the differencing operations are reversed to reconstitute xt, for t=n+1,,n+L.
The standard errors of these forecasts are given by st = V× ψ02 + ψ12 ++ ψt-n-12 1/2 , for t=n+1,,n+L, where ψ0=1, V is the residual variance of at, and ψj is the coefficient expressing the dependence of xt on at-j.
To calculate ψj, for j=1,2,,L-1, the following device is used.
A copy of the state set is initialized to zero throughout and the calculations outlined above for the construction of forecasts are carried out with the settings aN+1=1, and at=0, for t=N+2,,N+L.
The resulting quantities corresponding to the sequence xN+1,xN+2,,xN+L are precisely 1, ψ1,ψ2,,ψL-1.
The supplied time series model is used throughout these calculations, with the exception that the constant term c is taken to be zero.




Compulsory Input Parameters

1:     stnst – double array
The state set derived from nag_tsa_uni_arima_estim (g13ae) or nag_tsa_uni_arima_estim_easy (g13af) originally, or as modified using earlier calls of nag_tsa_uni_arima_update (g13ag).
2:     mr7 int64int32nag_int array
The orders vector p,d,q,P,D,Q,s of the ARIMA model, in the usual notation.
  • p,d,q,P,D,Q,s0;
  • p+q+P+Q>0;
  • s1;
  • if s=0, P+D+Q=0;
  • if s>1, P+D+Q>0.
3:     parnpar – double array
The estimates of the p values of the ϕ parameters, the q values of the θ parameters, the P values of the Φ parameters and the Q values of the Θ parameters which specify the model and which were output originally by nag_tsa_uni_arima_estim (g13ae) or nag_tsa_uni_arima_estim_easy (g13af).
4:     c – double scalar
c, the value of the model constant. This will have been output by nag_tsa_uni_arima_estim (g13ae) or nag_tsa_uni_arima_estim_easy (g13af).
5:     rms – double scalar
V, the residual variance associated with the model.
If nag_tsa_uni_arima_estim_easy (g13af) was used to estimate the model, rms should be set to s/ndf, where s and ndf were output by nag_tsa_uni_arima_estim_easy (g13af).
If nag_tsa_uni_arima_estim (g13ae) was used to estimate the model, rms should be set to s/icount5, where s and icount5 were output by nag_tsa_uni_arima_estim (g13ae).
Constraint: rms0.0.
6:     nfv int64int32nag_int scalar
L, the required number of forecasts.
Constraint: nfv>0.

Optional Input Parameters

1:     nst int64int32nag_int scalar
Default: the dimension of the array st.
The number of values in the state set array st.
Constraint: nst=P×s+D×s+d+q+maxp,Q×s. (As returned by nag_tsa_uni_arima_estim (g13ae) or nag_tsa_uni_arima_estim_easy (g13af)).
2:     npar int64int32nag_int scalar
Default: the dimension of the array par.
The number of ϕ, θ, Φ and Θ parameters in the model.
Constraint: npar=p+q+P+Q.

Output Parameters

1:     fvanfv – double array
nfv forecast values relating to the original undifferenced series.
2:     fsdnfv – double array
The standard errors associated with each of the nfv forecast values in fva.
3:     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:
On entry,nparp+q+P+Q,
orthe orders vector mr is invalid (check the constraints given in Arguments).
On entry,nstP×s+D×s+d+q+maxQ×s,p.
On entry,nfv0.
On entry,nwa<4×npar+3×nst.
On entry,rms<0.0.
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.


The computations are believed to be stable.

Further Comments

The time taken by nag_tsa_uni_arima_forecast_state (g13ah) is approximately proportional to nfv×npar.


The following program is based on the data derived in the example used to illustrate nag_tsa_uni_arima_update (g13ag).
These consist of a set of orders indicating that there are two moving average parameters (one non-seasonal, and one seasonal with periodicity 12).
The model constant is zero.
The state set contains 26 values.
In addition the residual mean-square derived when the model was originally fitted is given.
Twelve forecasts and their associated errors are obtained.
function g13ah_example

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

% state set from g13ae, g13af or g13ag
st = [0.0660;    -0.0513;     0.1715;    -0.0249;     0.0588;
      0.1167;     0.1493;     0.0199;    -0.1884;    -0.1289;
     -0.1172;     0.1122;     6.0039;     0.0443;    -0.0070;
      0.0252;     0.0020;     0.0353;    -0.0460;     0.0374;
      0.0151;    -0.0237;     0.0031;     0.0188;     0.0066;

% Orders
mr = [int64(0);1;1;0;1;1;12];

% Parameter estimates
par = [0.327; 0.6262];

% residual variance
rms = 0.0014;

c = 0;
nfv = int64(12);

% Produce forecasts
[fva, fsd, ifail] = g13ah( ...
                           st, mr, par, c, rms, nfv);

fprintf('The required %4d forecast values are as follows\n', nfv);
for j = 1:8:nfv
  fprintf('%8.4f', fva(j:min(j+7,nfv)));
fprintf('\nThe standard deviations corresponding to the forecasts are\n');
for j = 1:8:nfv
  fprintf('%8.4f', fsd(j:min(j+7,nfv)));

g13ah example results

The required   12 forecast values are as follows
  6.0381  5.9912  6.1469  6.1207  6.1574  6.3029  6.4288  6.4392
  6.2657  6.1348  6.0059  6.1139

The standard deviations corresponding to the forecasts are
  0.0374  0.0451  0.0517  0.0575  0.0627  0.0676  0.0721  0.0764
  0.0805  0.0843  0.0880  0.0915

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