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

NAG Library Routine Document

G13AJF

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

G13AJF applies a fully specified seasonal ARIMA model to an observed time series, generates the state set for forecasting and (optionally) derives a specified number of forecasts together with their standard deviations.

2  Specification

SUBROUTINE G13AJF ( MR, PAR, NPAR, C, KFC, X, NX, RMS, ST, IST, NST, NFV, FVA, FSD, IFV, ISF, W, IW, IFAIL)
INTEGER  MR(7), NPAR, KFC, NX, IST, NST, NFV, IFV, ISF(4), IW, IFAIL
REAL (KIND=nag_wp)  PAR(NPAR), C, X(NX), RMS, ST(IST), FVA(IFV), FSD(IFV), W(IW)

3  Description

The time series x1,x2,,xn supplied to the routine is assumed to follow a seasonal autoregressive integrated moving average (ARIMA) model with known parameters.
The model is defined by the following relations.
(a) dsDxt-c=wt where dsDxt is the result of applying non-seasonal differencing of order d and seasonal differencing of seasonality s and order D to the series xt, and c is a constant.
(b) wt=Φ1wt-s+Φ2wt-2×s++ΦPwt-P×s+et-Θ1et-s-Θ2et-2×s--ΘQet-Q×s. 
This equation describes the seasonal structure with seasonal period s; in the absence of seasonality it reduces to wt=et.
(c) et=ϕ1et-1+ϕ2et-2++ϕpet-p+at-θ1at-1-θ2at-2--θqat-q. 
This equation describes the non-seasonal structure.
Given the series, the constant c, and the model parameters Φ, Θ, ϕ, θ, the routine computes the following.
(a) The state set required for forecasting. This contains the minimum amount of information required for forecasting and comprises:
(i) the differenced series wt, for N-s×PtN;
(ii) the d+D×s values required to reconstitute the original series xt from the differenced series wt;
(iii) the intermediate series et, for N-maxp,Q×s<tN;
(iv) the residual series at, for N-q<tN, where N=n-d+D×s.
(b) A set of L forecasts of xt and their estimated standard errors, st, for t=n+1,,n+L (L may be zero).
The forecasts and estimated standard errors are generated from the state set, and are identical to those that would be produced from the same state set by G13AHF.
Use of G13AJF should be confined to situations in which the state set for forecasting is unknown. Forecasting from the series requires recalculation of the state set and this is relatively expensive.

4  References

Box G E P and Jenkins G M (1976) Time Series Analysis: Forecasting and Control (Revised Edition) Holden–Day

5  Parameters

1:     MR(7) – INTEGER arrayInput
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;
  • d+s×P+Dn;
  • p+d-q+s×P+D-Qn.
2:     PAR(NPAR) – REAL (KIND=nag_wp) arrayInput
On entry: 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, in that order.
3:     NPAR – INTEGERInput
On entry: the exact number of ϕ, θ, Φ and Θ parameters.
Constraint: NPAR=p+q+P+Q.
4:     C – REAL (KIND=nag_wp)Input
On entry: c, the expected value of the differenced series (i.e., c is the constant correction). Where there is no constant term, C must be set to 0.0.
5:     KFC – INTEGERInput
On entry: must be set to 0 if C was not estimated, and 1 if C was estimated. This is irrespective of whether or not C=0.0. The only effect is that the residual degrees of freedom are one greater when KFC=0. Assuming the supplied time series to be the same as that to which the model was originally fitted, this ensures an unbiased estimate of the residual mean-square.
Constraint: KFC=0 or 1.
6:     X(NX) – REAL (KIND=nag_wp) arrayInput
On entry: the n values of the original undifferenced time series.
7:     NX – INTEGERInput
On entry: n, the length of the original undifferenced time series.
8:     RMS – REAL (KIND=nag_wp)Output
On exit: the residual variance (mean square) associated with the model.
9:     ST(IST) – REAL (KIND=nag_wp) arrayOutput
On exit: the NST values of the state set.
10:   IST – INTEGERInput
On entry: the dimension of the array ST as declared in the (sub)program from which G13AJF is called.
Constraint: ISTP×s+d+D×s+q+maxp,Q×s. The expression on the right-hand side of the inequality is returned in NST.
11:   NST – INTEGEROutput
On exit: the number of values in the state set array ST.
12:   NFV – INTEGERInput
On entry: the required number of forecasts. If NFV0, no forecasts will be computed.
13:   FVA(IFV) – REAL (KIND=nag_wp) arrayOutput
On exit: if NFV>0, FVA contains the NFV forecast values relating to the original undifferenced time series.
14:   FSD(IFV) – REAL (KIND=nag_wp) arrayOutput
On exit: if NFV>0, FSD contains the estimated standard errors of the NFV forecast values.
15:   IFV – INTEGERInput
On entry: the dimension of the arrays FVA and FSD as declared in the (sub)program from which G13AJF is called.
Constraint: IFVmax1,NFV.
16:   ISF(4) – INTEGER arrayOutput
On exit: contains validity indicators, one for each of the four possible parameter types in the model (autoregressive, moving average, seasonal autoregressive, seasonal moving average), in that order.
Each indicator has the interpretation:
-1 On entry the set of parameter values of this type does not satisfy the stationarity or invertibility test conditions.
-0 No parameter of this type is in the model.
-1 Valid parameter values of this type have been supplied.
17:   W(IW) – REAL (KIND=nag_wp) arrayWorkspace
18:   IW – INTEGERInput
On entry: the dimension of the array W as declared in the (sub)program from which G13AJF is called.
Constraint: IW6×n+5×p+q+P+Q+Q2+11×Q+3×P+7,
where Q=Q×s+q and P=P×s+p.
19:   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:
IFAIL=1
On entry,NPARp+q+P+Q,
orthe orders vector MR is invalid (check the constraints in Section 5),
orKFC0 or 1.
IFAIL=2
On entry, NX-d-D×sNPAR+KFC, i.e., the number of terms in the differenced series is not greater than the number of parameters in the model. The model is over-parameterised.
IFAIL=3
On entry, the workspace array W is too small.
IFAIL=4
On entry, the state set array ST is too small. It must be at least as large as the exit value of NST.
IFAIL=5
This indicates a failure in F04ASF which is used to solve the equations giving estimates of the backforecasts.
IFAIL=6
On entry, valid values were not supplied for all parameter types in the model. Inspect array ISF for further information on the parameter type(s) in error.
IFAIL=7
On entry,IFV<max1,NFV.

7  Accuracy

The computations are believed to be stable.

8  Further Comments

The time taken by G13AJF is approximately proportional to n and the square of the number of backforecasts derived.

9  Example

The data is that used in the example program for G13AFF. Five forecast values and their standard errors, together with the state set, are computed and printed.

9.1  Program Text

Program Text (g13ajfe.f90)

9.2  Program Data

Program Data (g13ajfe.d)

9.3  Program Results

Program Results (g13ajfe.r)


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

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