G13AHF (PDF version)
G13 Chapter Contents
G13 Chapter Introduction
NAG Library Manual

NAG Library Routine Document


Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

G13AHF produces forecasts of a time series, given a time series model which has already been fitted to the time series using G13AEF or G13AFF. The original observations are not required, since G13AHF uses as input either the original state set produced by G13AEF or G13AFF or the state set updated by a series of new observations using G13AGF. Standard errors of the forecasts are also provided.

2  Specification


3  Description

The original time series is xt, for t=1,2,,n and parameters have been fitted to the model of this time series using G13AEF or G13AFF.
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.

4  References


5  Parameters

1:     ST(NST) – REAL (KIND=nag_wp) arrayInput
On entry: the state set derived from G13AEF or G13AFF originally, or as modified using earlier calls of G13AGF.
2:     NST – INTEGERInput
On entry: the number of values in the state set array ST.
Constraint: NST=P×s+D×s+d+q+maxp,Q×s. (As returned by G13AEF or G13AFF).
3:     MR(7) – INTEGER arrayInput
On entry: 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.
4:     PAR(NPAR) – REAL (KIND=nag_wp) arrayInput
On entry: 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 G13AEF or G13AFF.
5:     NPAR – INTEGERInput
On entry: the number of ϕ, θ, Φ and Θ parameters in the model.
Constraint: NPAR=p+q+P+Q.
6:     C – REAL (KIND=nag_wp)Input
On entry: c, the value of the model constant. This will have been output by G13AEF or G13AFF.
7:     RMS – REAL (KIND=nag_wp)Input
On entry: V, the residual variance associated with the model.
If G13AFF was used to estimate the model, RMS should be set to S/NDF, where S and NDF were output by G13AFF.
If G13AEF was used to estimate the model, RMS should be set to S/ICOUNT5, where S and ICOUNT5 were output by G13AEF.
Constraint: RMS0.0.
8:     NFV – INTEGERInput
On entry: L, the required number of forecasts.
Constraint: NFV>0.
9:     FVA(NFV) – REAL (KIND=nag_wp) arrayOutput
On exit: NFV forecast values relating to the original undifferenced series.
10:   FSD(NFV) – REAL (KIND=nag_wp) arrayOutput
On exit: the standard errors associated with each of the NFV forecast values in FVA.
11:   WA(NWA) – REAL (KIND=nag_wp) arrayWorkspace
12:   NWA – INTEGERInput
On entry: the dimension of the array WA as declared in the (sub)program from which G13AHF is called.
Constraint: NWA4×NPAR+3×NST.
13:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
On entry,NPARp+q+P+Q,
orthe orders vector MR is invalid (check the constraints given in Section 5).
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.

7  Accuracy

The computations are believed to be stable.

8  Further Comments

The time taken by G13AHF is approximately proportional to NFV×NPAR.

9  Example

The following program is based on the data derived in the example used to illustrate G13AGF.
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.

9.1  Program Text

Program Text (g13ahfe.f90)

9.2  Program Data

Program Data (g13ahfe.d)

9.3  Program Results

Program Results (g13ahfe.r)

G13AHF (PDF version)
G13 Chapter Contents
G13 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012