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

NAG Library Routine Document

G13BJF

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

G13BJF produces forecasts of a time series (the output series) which depends on one or more other (input) series via a previously estimated multi-input model for which the state set information is not available. The future values of the input series must be supplied. In contrast with G13BHF the original past values of the input and output series are required. Standard errors of the forecasts are produced. If future values of some of the input series have been obtained as forecasts using ARIMA models for those series, this may be allowed for in the calculation of the standard errors.

2  Specification

SUBROUTINE G13BJF ( MR, NSER, MT, PARA, NPARA, KFC, NEV, NFV, XXY, LDXXY, KZEF, RMSXY, MRX, PARX, LDPARX, FVA, FSD, STTF, ISTTF, NSTTF, WA, IWA, MWA, IMWA, IFAIL)
INTEGER  MR(7), NSER, MT(4,NSER), NPARA, KFC, NEV, NFV, LDXXY, KZEF, MRX(7,NSER), LDPARX, ISTTF, NSTTF, IWA, MWA(IMWA), IMWA, IFAIL
REAL (KIND=nag_wp)  PARA(NPARA), XXY(LDXXY,NSER), RMSXY(NSER), PARX(LDPARX,NSER), FVA(NFV), FSD(NFV), STTF(ISTTF), WA(IWA)

3  Description

G13BJF has two stages. The first stage is essentially the same as a call to the model estimation routine G13BEF, with zero iterations. In particular, all the parameters remain unchanged in the supplied input series transfer function models and output noise series ARIMA model. The internal nuisance parameters associated with the pre-observation period effects of the input series are estimated where requested, and so are any backforecasts of the output noise series. The output components zt and nt, and residuals at are calculated exactly as in Section 3 in G13BEF, and the state set for forecasting is constituted.
The second stage is essentially the same as a call to the forecasting routine G13BHF. The same information is required, and the same information is returned.
Use of G13BJF should be confined to situations in which the state set for forecasting is unknown. Forecasting from the original data is relatively expensive because it requires recalculation of the state set. G13BJF returns the state set for use in producing further forecasts using G13BHF, or for updating the state set using G13BGF.

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 for the output noise component.
p, q, P and Q refer respectively to the number of autoregressive ϕ, moving average θ, seasonal autoregressive Φ and seasonal moving average Θ parameters.
d, D and s refer respectively to the order of non-seasonal differencing, the order of seasonal differencing and the seasonal period.
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:     NSER – INTEGERInput
On entry: the number of input and output series. There may be any number of input series (including none), but only one output series.
3:     MT(4,NSER) – INTEGER arrayInput
On entry: the transfer function model orders b, p and q of each of the input series. The data for input series i is held in column i. Row 1 holds the value bi, row 2 holds the value qi and row 3 holds the value pi.
For a simple input, bi=qi=pi=0.
Row 4 holds the value ri, where ri=1 for a simple input, and ri=2​ or ​3 for a transfer function input.
The choice ri=3 leads to estimation of the pre-period input effects as nuisance parameters, and ri=2 suppresses this estimation. This choice may affect the returned forecasts and the state set.
When ri=1, any nonzero contents of rows 1, 2 and 3 of column i are ignored.
Constraint: MT4i=1, 2 or 3, for i=1,2,,NSER-1.
4:     PARA(NPARA) – REAL (KIND=nag_wp) arrayInput/Output
On entry: estimates of the multi-input model parameters. These are in order, firstly the ARIMA model parameters: p values of ϕ parameters, q values of θ parameters, P values of Φ parameters, Q values of Θ parameters.
These are followed by the transfer function model parameter values ω0,ω1,,ωq1, δ1,,δp1 for the first of any input series and similarly for each subsequent input series. The final component of PARA is the value of the constant c.
On exit: the parameter values may be updated using an additional iteration in the estimation process.
5:     NPARA – INTEGERInput
On entry: the exact number of ϕ, θ, Φ, Θ, ω, δ, c parameters, so that NPARA=p+q+P+Q+NSER+p+q, the summation being over all the input series. (c must be included whether its value was previously estimated or was set fixed.)
6:     KFC – INTEGERInput
On entry: must be set to 1 if the constant was estimated when the model was fitted, and 0 if it was held at a fixed value. This only affects the degrees of freedom used in calculating the estimated residual variance.
Constraint: KFC=0 or 1.
7:     NEV – INTEGERInput
On entry: the number of original (undifferenced) values in each of the input and output time series.
8:     NFV – INTEGERInput
On entry: the number of forecast values of the output series required.
Constraint: NFV>0.
9:     XXY(LDXXY,NSER) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the columns of XXY must contain in the first NEV places, the past values of each of the input and output series, in that order. In the next NFV places, the columns relating to the input series (i.e., columns 1 to NSER-1) contain the future values of the input series which are necessary for construction of the forecasts of the output series y.
On exit: if KZEF=0 then XXY is unchanged except that the relevant NFV values in the column relating to the output series (column NSER) contain the forecast values (FVA), but if KZEF0 then the columns of XXY contain the corresponding values of the input component series zt and the values of the output noise component nt, in that order.
10:   LDXXY – INTEGERInput
On entry: the first dimension of the array XXY as declared in the (sub)program from which G13BJF is called.
Constraint: LDXXYNEV+NFV.
11:   KZEF – INTEGERInput
On entry: must be set to 0 if the relevant NFV values of the forecasts (FVA) are to be held in the output series column (NSER) of XXY (which is otherwise unchanged) on exit, and must not be set to 0 if the values of the input component series zt and the values of the output noise component nt are to overwrite the contents of XXY on exit.
12:   RMSXY(NSER) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the first NSER-1 elements of RMSXY must contain the estimated residual variance of the input series ARIMA models. In the case of those inputs for which no ARIMA model is available or its effects are to be excluded in the calculation of forecast standard errors, the corresponding entry of RMSXY should be set to 0.
On exit: RMSXYNSER contains the estimated residual variance of the output noise ARIMA model which is calculated from the supplied series. Otherwise RMSXY is unchanged.
13:   MRX(7,NSER) – INTEGER arrayInput/Output
On entry: the orders array for each of the input series ARIMA models. Thus, column i contains values of p, d, q, P, D, Q, s for input series i. In the case of those inputs for which no ARIMA model is available, the corresponding orders should be set to 0.
On exit: unchanged, except for column NSER which is used as workspace.
14:   PARX(LDPARX,NSER) – REAL (KIND=nag_wp) arrayInput
On entry: values of the parameters (ϕ, θ, Φ, and Θ) for each of the input series ARIMA models.
Thus column i contains MRX1i values of ϕ, MRX3i values of θ, MRX4i values of Φ and MRX6i values of Θ, in that order.
Values in the columns relating to those input series for which no ARIMA model is available are ignored.
15:   LDPARX – INTEGERInput
On entry: the first dimension of the array PARX as declared in the (sub)program from which G13BJF is called.
Constraint: LDPARXnce, where nce is the maximum number of parameters in any of the input series ARIMA models. If there are no input series, then LDPARX1.
16:   FVA(NFV) – REAL (KIND=nag_wp) arrayOutput
On exit: the required forecast values for the output series. (Note that these are also output in column NSER of XXY if KZEF=0.)
17:   FSD(NFV) – REAL (KIND=nag_wp) arrayOutput
On exit: the standard errors for each of the forecast values.
18:   STTF(ISTTF) – REAL (KIND=nag_wp) arrayOutput
On exit: the NSTTF values of the state set based on the first NEV sets of (past) values of the input and output series.
19:   ISTTF – INTEGERInput
On entry: the dimension of the array STTF as declared in the (sub)program from which G13BJF is called.
Constraint: ISTTFP×s+d+D×s+q+maxp,Q×s+ncf, where ncf=bi+qi+pi and the summation is over all input series for which ri>1.
20:   NSTTF – INTEGEROutput
On exit: the number of values in the state set array STTF.
21:   WA(IWA) – REAL (KIND=nag_wp) arrayWorkspace
22:   IWA – INTEGERInput
On entry: the dimension of the array WA as declared in the (sub)program from which G13BJF is called.
It is not practical to outline a method for deriving the exact minimum permissible value of IWA, but the following gives a reasonably good approximation which tends to be on the conservative side.
Note:  there are three error indicators associated with IWA. These are IFAIL=4, 5 or 6. The first of these probably indicates an abnormal entry value of NFV, while the second indicates that IWA is much too small and needs to be increased by a substantial amount. The last of these indicates that IWA is too small but returns the necessary minimum value in MWA1.
Let q=q+Q×s and d=d+D×s, where the output noise ARIMA model orders are p, d, q, P, D, Q, s.
Let there be l input series, where l=NSER-1.
Let mxi=maxbi+qi,pi, if ri=3, for i=1,2,,l, if l>0
  mxi=0, if ri3, for i=1,2,,l, if l>0
where the transfer function model orders of input series i are given by bi, qi, pi, ri.
Let qx=maxq,mx1,mx2,,mxl
Let ncg=NPARA+qx+i=1 lmxi and nch=N+d+6×qx.
Finally, let nci=NSER, and then increment nci by 1 every time any of the following conditions are satisfied. (The last two conditions should be applied separately to each input series, so that for example if we have two input series and p1>0 and p2>0, then nci is incremented by 2 in respect of these.)
The conditions are:
  • p>0
  • q>0
  • P>0
  • Q>0
  • qx>0
  • mxi>0, separately, for i=1,2,,l, if l>0
  • pi>0, separately, for i=1,2,,l, if l>0,
then IWA>2× ncg 2+nch×nci+4.
23:   MWA(IMWA) – INTEGER arrayWorkspace
24:   IMWA – INTEGERInput
On entry: the dimension of the array MWA as declared in the (sub)program from which G13BJF is called.
Constraint: IMWA16×NSER+7×ncg+3×NPARA+27.
The derivation of ncg is described under IWA.
When IMWA is too small, as indicated by IFAIL=7, the requisite minimum value of IMWA is returned in MWA1.
25:   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,KFC<0,
orKFC>1,
orLDXXY<NEV+NFV,
orNFV0.
IFAIL=2
On entry, LDPARX is too small or NPARA is inconsistent with the orders specified in arrays MR and MT; or one of the ri, stored in MT4i, does not equal 1, 2 or 3.
IFAIL=3
On entry or during execution, one or more sets of δ parameters do not satisfy the stationarity or invertibility test conditions.
IFAIL=4
On entry, IWA is too small for the final forecasting calculations. This is a highly unlikely error, and would probably indicate that NFV was abnormally large.
IFAIL=5
On entry, IWA is too small by a very considerable margin. No information is supplied about the requisite minimum size.
IFAIL=6
On entry,IWA is too small, but the requisite minimum size is returned in MWA1.
IFAIL=7
On entry,IMWA is too small, but the requisite minimum size is returned in MWA1.
IFAIL=8
This indicates a failure in F04ASF which is used to solve the equations giving the latest estimates of the parameters.
IFAIL=9
This indicates a failure in the inversion of the second derivative matrix associated with parameter estimation.
IFAIL=10
On entry or during execution, one or more sets of the ARIMA (ϕ, θ, Φ or Θ) parameters do not satisfy the stationarity or invertibility test conditions.
IFAIL=11
On entry,ISTTF is too small.

7  Accuracy

The computations are believed to be stable.

8  Further Comments

The time taken by G13BJF is approximately proportional to the product of the length of each series and the square of the number of parameters in the multi-input model.

9  Example

The data in this example relates to 40 observations of an output time series and 5 input time series. The output series has one autoregressive ϕ parameter and one seasonal moving average Θ parameter, with initial values ϕ=0.495, Θ=0.238 and c=-82.858. The seasonal period is 4. This example differs from the example in G13BEF in that four of the input series are simple series and the fifth is defined by a transfer function with orders b5=1, q5=0, p5=1, r5=3, which allows for pre-observation period effects. The initial values for the transfer model are:
A further 8 values of the input series are supplied, and it is assumed that the values for the fifth series have themselves been forecast from an ARIMA model with orders 2 0 2 0 1 1 4 ,  in which ϕ1=1.6743, ϕ2=-0.9505, θ1=1.4605, θ2=-0.4862 and Θ1=0.8993, and for which the residual mean square is 0.1720.
The following are computed and printed out: the state set after initial processing of the original 40 sets of values, the estimated residual variance for the output noise series, the 8 forecast values and their standard errors, and the values of the components zt and the output noise component nt.

9.1  Program Text

Program Text (g13bjfe.f90)

9.2  Program Data

Program Data (g13bjfe.d)

9.3  Program Results

Program Results (g13bjfe.r)


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

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