NAG Library Routine Document

g13bhf (multi_inputmod_forecast_state)

1
Purpose

g13bhf produces forecasts of a time series (the output series) which depends on one or more other (input) series via a multi-input model which will usually have been fitted using g13bef. The future values of the input series must be supplied. The original observations are not required. g13bhf uses as input either the original state set obtained from g13bef, or the state set updated by a series of new observations from g13bgf. 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

Fortran Interface
Subroutine g13bhf ( sttf, nsttf, mr, nser, mt, para, npara, nfv, xxyn, ldxxyn, mrx, parx, ldparx, rmsxy, kzef, fva, fsd, wa, iwa, ifail)
Integer, Intent (In):: nsttf, nser, mt(4,nser), npara, nfv, ldxxyn, ldparx, kzef, iwa
Integer, Intent (Inout):: mr(7), mrx(7,nser), ifail
Real (Kind=nag_wp), Intent (In):: sttf(nsttf), para(npara), parx(ldparx,nser), rmsxy(nser)
Real (Kind=nag_wp), Intent (Inout):: xxyn(ldxxyn,nser)
Real (Kind=nag_wp), Intent (Out):: fva(nfv), fsd(nfv), wa(iwa)
C Header Interface
#include <nagmk26.h>
void  g13bhf_ (const double sttf[], const Integer *nsttf, Integer mr[], const Integer *nser, const Integer mt[], const double para[], const Integer *npara, const Integer *nfv, double xxyn[], const Integer *ldxxyn, Integer mrx[], const double parx[], const Integer *ldparx, const double rmsxy[], const Integer *kzef, double fva[], double fsd[], double wa[], const Integer *iwa, Integer *ifail)

3
Description

The forecasts of the output series yt are calculated, for t=n+1,,n+L, where n is the latest time point of the observations used to produce the state set and L is the maximum lead time of the forecasts.
First the new input series values xt are used to form the input components zt, for t=n+1,,n+L, using the transfer function models:
(a) zt=δ1zt-1+δ2zt-2++δpzt-p+ω0xt-b-ω1xt-b-1--ωqxt-b-q.
The output noise component nt is then forecast by setting at=0, for t=n+1,,n+L, and using the ARIMA model equations:
(b) et=ϕ1et-1+ϕ2et-2++ϕpet-p+at-θ1at-1-θ2at-2--θ1at-q
(c) wt=Φ1wt-s+Φ2wt-2×s++ΦPwt-P×s+et-Θ1et-s-Θ2et-2×s--ΘQet-Q×s
(d) nt=dsD -1wt+c.
This last step of ‘integration’ reverses the process of differencing. Finally the output forecasts are calculated as
yt=z1,t+z2,t++zm,t+nt.  
The forecast error variance of yt+l (i.e., at lead time l) is Sl2, which is the sum of parts which arise from the various input series, and the output noise component. That part due to the output noise is
snl2=Vn×ψ02+ψ12++ψl-12,  
where Vn is the estimated residual variance of the output noise ARIMA model, and ψ0,ψ1, are the ‘psi-weights’ of this model as defined in Box and Jenkins (1976). They are calculated by applying the equations (b), (c) and (d) above, for t=0,1,,L, but with artificial values for the various series and with the constant c set to 0. Thus all values of at, et, wt and nt are taken as zero, for t<0; at is taken to be 1, for t=0 and 0, for t>0. The resulting values of nt, for t=0,1,,L, are precisely ψ0,ψ1,,ψL as required.
Further contributions to Sl2 come only from those input series, for which future values are forecasts which have been obtained by applying input series ARIMA models. For such a series the contribution is
szl2=Vx×ν02+ν12++νl-12,  
where Vx is the estimated residual variance of the input series ARIMA model. The coefficients ν0,ν1, are calculated by applying the transfer function model equation (a) above, for t=0,1,,L, but again with artificial values of the series. Thus all values of zt and xt, for t<0, are taken to be zero, and x0,x1, are taken to be the psi-weight sequence ψ0,ψ1, for the input series ARIMA model. The resulting values of zt, for t=0,1,,L, are precisely ν0,ν1,,νL as required.
In adding such contributions szl2 to snl2 to make up the total forecast error variance Sl2, it is assumed that the various input series with which these contributions are associated are statistically independent of each other.
When using the routine in practice an ARIMA model is required for all the input series. In the case of those inputs for which no such ARIMA model is available (or its effects are to be excluded), the corresponding orders and parameters and the estimated residual variance should be set to zero.

4
References

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

5
Arguments

1:     sttfnsttf – Real (Kind=nag_wp) arrayInput
On entry: the nsttf values in the state set as returned by g13bef or g13bgf.
2:     nsttf – IntegerInput
On entry: the exact number of values in the state set array sttf as returned by g13bef or g13bgf.
3:     mr7 – 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 give respectively 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.
4:     nser – IntegerInput
On entry: the total number of input and output series. There may be any number of input series (including none), but only one output series.
5:     mt4nser – Integer arrayInput
On entry: the transfer function orders b, p and q of each of the input series. The data for input series i are 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, ri=2 or 3 for a transfer function input. When ri=1, any nonzero contents of rows 1, 2 and 3 of column i are ignored. The choice of ri=2 or ri=3 is an option for use in model estimation and does not affect the operation of g13bhf.
Constraint: mt4i=1, 2 or 3, for i=1,2,,nser-1.
6:     paranpara – Real (Kind=nag_wp) arrayInput
On entry: estimates of the multi-input model parameters as returned by g13bef. These are in order, firstly the ARIMA model parameters: p values of ϕ parameters, q values of θ parameters, P values of Φ parameters and Q values of Θ parameters. These are followed by the transfer function model parameter values ω0,ω1,,ωq1, δ1,δ2,,δp1 for the first of any input series and similar sets of values for any subsequent input series. The final component of para is the constant c.
7:     npara – IntegerInput
On entry: the exact number of ϕ, θ, Φ, Θ, ω, δ and c parameters. (c must be included, whether its value was previously estimated or was set fixed).
8:     nfv – IntegerInput
On entry: the number of forecast values required.
9:     xxynldxxynnser – Real (Kind=nag_wp) arrayInput/Output
On entry: the supplied nfv values for each of the input series required to produce the nfv output series forecasts. Column i contains the values for input series i. Column nser need not be supplied.
On exit: if kzef=0, then column nser of xxyn contains the output series forecast values (as does fva), but xxyn is otherwise unchanged.
If kzef0, then the columns of xxyn hold the corresponding values of the forecast components zt for each of the input series and the values of the output noise component nt in that order.
10:   ldxxyn – IntegerInput
On entry: the first dimension of the array xxyn as declared in the (sub)program from which g13bhf is called.
Constraint: ldxxynnfv.
11:   mrx7nser – 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. (The model for any input series only affects the standard errors of the forecast values.)
On exit: unchanged, apart from column nser which is used for workspace.
12:   parxldparxnser – 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 ϕ parameters, mrx3i values of θ parameters, mrx4i values of Φ parameters and mrx6i values of Θ parameters – in that order.
Values in the columns relating to those input series for which no ARIMA model is available are ignored. (The model for any input series only affects the standard errors of the forecast values.)
13:   ldparx – IntegerInput
On entry: the first dimension of the array parx as declared in the (sub)program from which g13bhf is called.
Constraint: ldparxncd, where ncd is the maximum number of parameters in any of the input series ARIMA models. If there are no input series, ldparx1.
14:   rmsxynser – Real (Kind=nag_wp) arrayInput
On entry: the estimated residual variances for each input series ARIMA model followed by that for the output noise ARIMA model. In the case of those inputs for which no ARIMA model is available, or when its effects are to be excluded in the calculation of forecast standard errors, the corresponding entry of rmsxy should be set to 0.
15:   kzef – IntegerInput
On entry: 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 xxyn on exit, and must be set to 0 if xxyn is to remain unchanged on exit, apart from the appearance of the forecast values in column nser.
16:   fvanfv – Real (Kind=nag_wp) arrayOutput
On exit: the required forecast values for the output series.
17:   fsdnfv – Real (Kind=nag_wp) arrayOutput
On exit: the standard errors for each of the forecast values.
18:   waiwa – Real (Kind=nag_wp) arrayOutput
19:   iwa – IntegerInput
These arguments are no longer accessed by g13bhf. Workspace is provided internally by dynamic allocation instead.
20:   ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation 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, nsttf=value and the expected value=value.
Constraint: nsttf, mr and mt must be consistent.
ifail=2
On entry, npara=value and the expected value=value.
Constraint: npara, mr and mt must be consistent.
ifail=3
On entry, ldxxyn=value and nfv=value.
Constraint: ldxxynnfv.
ifail=5
On entry, ldparx=value and the minimum size required=value.
Constraint: ldparxmax1,max. number of parameters in any input series.
ifail=6
On entry, i=value and mt4i=value.
Constraint: mt4i=1, 2 or 3.
The orders vector mr is invalid.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

The computations are believed to be stable.

8
Parallelism and Performance

g13bhf is not threaded in any implementation.

9
Further Comments

The time taken by g13bhf is approximately proportional to nfv×npara.

10
Example

This example follows up that described in g13bgf and makes use of its data. These consist of output series orders and parameter values, input series transfer function orders and the updated state set.
Four new values of the input series are supplied, as are the orders and parameter values for the single input series ARIMA model (which has 2 values of ϕ, 2 values of θ, 1 value of Θ, single seasonal differencing and a seasonal period of 4), and the estimated residual variances for the input series ARIMA model and the output noise ARIMA model.
Four forecast values and their standard errors are computed and printed; also the values of the components zt and the output noise component nt corresponding to the forecasts.

10.1
Program Text

Program Text (g13bhfe.f90)

10.2
Program Data

Program Data (g13bhfe.d)

10.3
Program Results

Program Results (g13bhfe.r)