NAG FL Interface
g13ahf (uni_​arima_​forecast_​state)

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

Fortran Interface
Subroutine g13ahf ( st, nst, mr, par, npar, c, rms, nfv, fva, fsd, wa, nwa, ifail)
Integer, Intent (In) :: nst, mr(7), npar, nfv, nwa
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: st(nst), par(npar), c, rms
Real (Kind=nag_wp), Intent (Out) :: fva(nfv), fsd(nfv), wa(nwa)
C Header Interface
#include <nag.h>
void  g13ahf_ (const double st[], const Integer *nst, const Integer mr[], const double par[], const Integer *npar, const double *c, const double *rms, const Integer *nfv, double fva[], double fsd[], double wa[], const Integer *nwa, Integer *ifail)
The routine may be called by the names g13ahf or nagf_tsa_uni_arima_forecast_state.

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:
  1. (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;
  2. (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;
  3. (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;
  4. (iv)add the constant term c to give the differenced series dsDxt=wt+c, for t=N+1,,N+L;
  5. (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

None.

5 Arguments

1: stnst Real (Kind=nag_wp) array Input
On entry: the state set derived from g13aef or g13aff originally, or as modified using earlier calls of g13agf.
2: nst Integer Input
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: mr7 Integer array Input
On entry: the orders vector p,d,q,P,D,Q,s of the ARIMA model, in the usual notation.
Constraints:
  • 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: parnpar Real (Kind=nag_wp) array Input
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 Integer Input
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 Integer Input
On entry: L, the required number of forecasts.
Constraint: nfv>0.
9: fvanfv Real (Kind=nag_wp) array Output
On exit: nfv forecast values relating to the original undifferenced series.
10: fsdnfv Real (Kind=nag_wp) array Output
On exit: the standard errors associated with each of the nfv forecast values in fva.
11: wanwa Real (Kind=nag_wp) array Workspace
12: nwa Integer Input
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 Integer Input/Output
On entry: ifail must be set to 0, -1 or 1. 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 -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 argument, 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:
ifail=1
On entry, npar=value.
Constraint: npar=p+q+P+Q.
The orders vector mr is invalid.
ifail=2
On entry, nst=value.
Constraint: nst=P×s+D×s+d+q+maxQ×s,p.
ifail=3
On entry, nfv=value.
Constraint: nfv>0.
ifail=4
On entry, nwa=value and the minimum size required=value.
Constraint: nwa4×npar+3×nst.
ifail=5
On entry, rms=value.
Constraint: rms0.0.
ifail=-99
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.
ifail=-399
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.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

The computations are believed to be stable.

8 Parallelism and Performance

g13ahf is not threaded in any implementation.

9 Further Comments

The time taken by g13ahf is approximately proportional to nfv×npar.

10 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.

10.1 Program Text

Program Text (g13ahfe.f90)

10.2 Program Data

Program Data (g13ahfe.d)

10.3 Program Results

Program Results (g13ahfe.r)