NAG FL Interface
g13ajf (uni_​arima_​forcecast)

Settings help

FL Name Style:

FL Specification Language:

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

Fortran Interface
Subroutine g13ajf ( mr, par, npar, c, kfc, x, nx, rms, st, ist, nst, nfv, fva, fsd, ifv, isf, w, iw, ifail)
Integer, Intent (In) :: mr(7), npar, kfc, nx, ist, nfv, ifv, iw
Integer, Intent (Inout) :: ifail
Integer, Intent (Out) :: nst, isf(4)
Real (Kind=nag_wp), Intent (In) :: par(npar), c, x(nx)
Real (Kind=nag_wp), Intent (Out) :: rms, st(ist), fva(ifv), fsd(ifv), w(iw)
C Header Interface
#include <nag.h>
void  g13ajf_ (const Integer mr[], const double par[], const Integer *npar, const double *c, const Integer *kfc, const double x[], const Integer *nx, double *rms, double st[], const Integer *ist, Integer *nst, const Integer *nfv, double fva[], double fsd[], const Integer *ifv, Integer isf[], double w[], const Integer *iw, Integer *ifail)
The routine may be called by the names g13ajf or nagf_tsa_uni_arima_forcecast.

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.
  1. (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.
  2. (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.
  3. (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.
  1. (a)The state set required for forecasting. This contains the minimum amount of information required for forecasting and comprises:
    1. (i)the differenced series wt, for (N-s×P)tN;
    2. (ii)the (d+D×s) values required to reconstitute the original series xt from the differenced series wt;
    3. (iii)the intermediate series et, for N-max(p,Q×s)<tN;
    4. (iv)the residual series at, for (N-q)<tN, where N=n-(d+D×s).
  2. (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 Arguments

1: mr(7) Integer array Input
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;
  • d+s×(P+D)n;
  • p+d-q+s×(P+D-Q)n.
2: par(npar) Real (Kind=nag_wp) array Input
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 Integer Input
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 Integer Input
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) array Input
On entry: the n values of the original undifferenced time series.
7: nx Integer Input
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) array Output
On exit: the nst values of the state set.
10: ist Integer Input
On entry: the dimension of the array st as declared in the (sub)program from which g13ajf is called.
Constraint: ist(P×s)+d+(D×s)+q+max(p,Q×s). The expression on the right-hand side of the inequality is returned in nst.
11: nst Integer Output
On exit: the number of values in the state set array st.
12: nfv Integer Input
On entry: the required number of forecasts. If nfv0, no forecasts will be computed.
13: fva(ifv) Real (Kind=nag_wp) array Output
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) array Output
On exit: if nfv>0, fsd contains the estimated standard errors of the nfv forecast values.
15: ifv Integer Input
On entry: the dimension of the arrays fva and fsd as declared in the (sub)program from which g13ajf is called.
Constraint: ifvmax(1,nfv).
16: isf(4) Integer array Output
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) array Workspace
18: iw Integer Input
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 Integer Input/Output
On entry: ifail must be set to 0, −1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of −1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value −1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. 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, kfc=value.
Constraint: kfc=0 or 1.
On entry, npar=value.
Constraint: npar=p+q+P+Q.
The orders vector mr is invalid.
The model is over-parameterised. The number of parameters in the model is greater than the number of terms in the differenced series, i.e., npar+kfcnx-d-D×s.
On entry, iw=value and the minimum size required=value.
Constraint: iw6×n+5×(p+q+P+Q)+Q2+11×Q+3×P+7, where Q=Q×s+q and P=P×s+p.
On entry, ist=value and the minimum size required=value (the minimum size required is returned in nst).
Constraint: ist(P×s)+d+(D×s)+q+max(p,Q×s).
Unable to calculate the latest estimates of the backforecasts.
Satisfactory parameter estimates could not be obtained for all parameter types in the model. Inspect array isf for futher information on the parameter type(s) in error.
On entry, ifv=value and nfv=value.
Constraint: ifvmax(1,nfv).
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.
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.
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

Background information to multithreading can be found in the Multithreading documentation.
g13ajf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g13ajf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9 Further Comments

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

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

10.1 Program Text

Program Text (g13ajfe.f90)

10.2 Program Data

Program Data (g13ajfe.d)

10.3 Program Results

Program Results (g13ajfe.r)