NAG Library Routine Document
G13BHF
1 Purpose
G13BHF produces forecasts of a time series (the output series) which depends on one or more other (input) series via a multiinput 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
SUBROUTINE G13BHF ( 
STTF, NSTTF, MR, NSER, MT, PARA, NPARA, NFV, XXYN, LDXXYN, MRX, PARX, LDPARX, RMSXY, KZEF, FVA, FSD, WA, IWA, IFAIL) 
INTEGER 
NSTTF, MR(7), NSER, MT(4,NSER), NPARA, NFV, LDXXYN, MRX(7,NSER), LDPARX, KZEF, IWA, IFAIL 
REAL (KIND=nag_wp) 
STTF(NSTTF), PARA(NPARA), XXYN(LDXXYN,NSER), PARX(LDPARX,NSER), RMSXY(NSER), FVA(NFV), FSD(NFV), WA(IWA) 

3 Description
The forecasts of the output series ${y}_{\mathit{t}}$ are calculated, for $\mathit{t}=n+1,\dots ,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
${x}_{t}$ are used to form the input components
${z}_{\mathit{t}}$, for
$\mathit{t}=n+1,\dots ,n+L$, using the transfer function models:
(a) 
${z}_{t}={\delta}_{1}{z}_{t1}+{\delta}_{2}{z}_{t2}+\cdots +{\delta}_{p}{z}_{tp}+{\omega}_{0}{x}_{tb}{\omega}_{1}{x}_{tb1}\cdots {\omega}_{q}{x}_{tbq}$. 
The output noise component
${n}_{\mathit{t}}$ is then forecast by setting
${a}_{\mathit{t}}=0$, for
$\mathit{t}=n+1,\dots ,n+L$, and using the ARIMA model equations:
(b) 
${e}_{t}={\varphi}_{1}{e}_{t1}+{\varphi}_{2}{e}_{t2}+\cdots +{\varphi}_{p}{e}_{tp}+{a}_{t}{\theta}_{1}{a}_{t1}{\theta}_{2}{a}_{t2}\cdots {\theta}_{1}{a}_{tq}$ 
(c) 
${w}_{t}={\Phi}_{1}{w}_{ts}+{\Phi}_{2}{w}_{t2\times s}+\cdots +{\Phi}_{P}{w}_{tP\times s}+{e}_{t}{\Theta}_{1}{e}_{ts}{\Theta}_{2}{e}_{t2\times s}\cdots {\Theta}_{Q}{e}_{tQ\times s}$ 
(d) 
${n}_{t}={\left({\nabla}^{d}{\nabla}_{s}^{D}\right)}^{1}\left({w}_{t}+c\right)$. 
This last step of ‘integration’ reverses the process of differencing. Finally the output forecasts are calculated as
The forecast error variance of
${y}_{t+l}$ (i.e., at lead time
$l$) is
${S}_{l}^{2}$, 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
where
${V}_{n}$ is the estimated residual variance of the output noise ARIMA model, and
${\psi}_{0},{\psi}_{1},\dots \text{}$ are the ‘psiweights’ 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,\dots ,L$, but with artificial values for the various series and with the constant
$c$ set to
$0$. Thus all values of
${a}_{t}$,
${e}_{t}$,
${w}_{t}$ and
${n}_{t}$ are taken as zero, for
$t<0$;
${a}_{t}$ is taken to be
$1$, for
$t=0$ and
$0$, for
$t>0$. The resulting values of
${n}_{\mathit{t}}$, for
$\mathit{t}=0,1,\dots ,L$, are precisely
${\psi}_{0},{\psi}_{1},\dots ,{\psi}_{L}$ as required.
Further contributions to
${S}_{l}^{2}$ 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
where
${V}_{x}$ is the estimated residual variance of the input series ARIMA model. The coefficients
${\nu}_{0},{\nu}_{1},\dots \text{}$ are calculated by applying the transfer function model equation
(a) above, for
$t=0,1,\dots ,L$, but again with artificial values of the series. Thus all values of
${z}_{t}$ and
${x}_{t}$, for
$t<0$, are taken to be zero, and
${x}_{0},{x}_{1},\dots \text{}$ are taken to be the psiweight sequence
${\psi}_{0},{\psi}_{1},\dots \text{}$ for the
input
series ARIMA model. The resulting values of
${z}_{\mathit{t}}$, for
$\mathit{t}=0,1,\dots ,L$, are precisely
${\nu}_{0},{\nu}_{1},\dots ,{\nu}_{L}$ as required.
In adding such contributions $s{z}_{l}^{2}$ to $s{n}_{l}^{2}$ to make up the total forecast error variance ${S}_{l}^{2}$, 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 Parameters
 1: STTF(NSTTF) – 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: MR($7$) – INTEGER arrayInput
On entry: the orders vector
$\left(p,d,q,P,D,Q,s\right)$ of the ARIMA model for the output noise component.
$p$, $q$, $P$ and $Q$ give respectively the number of autoregressive $\left(\varphi \right)$, moving average $\left(\theta \right)$, seasonal autoregressive $\left(\Phi \right)$ and seasonal moving average $\left(\Theta \right)$ parameters.
$d$, $D$ and $s$ refer respectively to the order of nonseasonal differencing, the order of seasonal differencing, and the seasonal period.
Constraints:
 $p$, $d$, $q$, $P$, $D$, $Q$, $s\ge 0$;
 $p+q+P+Q>0$;
 $s\ne 1$;
 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: MT($4$,NSER) – 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
${b}_{i}$, row 2 holds the value
${q}_{i}$ and row 3 holds the value
${p}_{i}$. For a simple input,
${b}_{i}={q}_{i}={p}_{i}=0$.
Row 4 holds the value ${r}_{i}$, where ${r}_{i}=1$ for a simple input, ${r}_{i}=2\text{ or}3$ for a transfer function input. When ${r}_{i}=1$, any nonzero contents of rows 1, 2 and 3 of column $i$ are ignored. The choice of ${r}_{i}=2$ or ${r}_{i}=3$ is an option for use in model estimation and does not affect the operation of G13BHF.
Constraint:
${\mathbf{MT}}\left(4,\mathit{i}\right)=1$, $2$ or $3$, for $\mathit{i}=1,2,\dots ,{\mathbf{NSER}}1$.
 6: PARA(NPARA) – REAL (KIND=nag_wp) arrayInput
On entry: estimates of the multiinput model parameters as returned by
G13BEF. These are in order, firstly the ARIMA model parameters:
$p$ values of
$\varphi $ parameters,
$q$ values of
$\theta $ parameters,
$P$ values of
$\Phi $ parameters and
$Q$ values of
$\Theta $ parameters. These are followed by the transfer function model parameter values
${\omega}_{0},{\omega}_{1},\dots ,{\omega}_{{q}_{1}}$,
${\delta}_{1},{\delta}_{2},\dots ,{\delta}_{{p}_{1}}$ 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 $\varphi $, $\theta $, $\Phi $, $\Theta $, $\omega $, $\delta $ 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: XXYN(LDXXYN,NSER) – 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
${\mathbf{KZEF}}=0$, then column
NSER of
XXYN contains the output series forecast values (as does
FVA), but
XXYN is otherwise unchanged.
If
${\mathbf{KZEF}}\ne 0$, then the columns of
XXYN hold the corresponding values of the forecast components
${z}_{t}$ for each of the input series and the values of the output noise component
${n}_{t}$ 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:
${\mathbf{LDXXYN}}\ge {\mathbf{NFV}}$.
 11: 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$. (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: PARX(LDPARX,NSER) – REAL (KIND=nag_wp) arrayInput
On entry: values of the parameters (
$\varphi $,
$\theta $,
$\Phi $ and
$\Theta $) for each of the input series ARIMA models. Thus column
$i$ contains
${\mathbf{MRX}}\left(1,i\right)$ values of
$\varphi $ parameters,
${\mathbf{MRX}}\left(3,i\right)$ values of
$\theta $ parameters,
${\mathbf{MRX}}\left(4,i\right)$ values of
$\Phi $ parameters and
${\mathbf{MRX}}\left(6,i\right)$ values of
$\Theta $ 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:
${\mathbf{LDPARX}}\ge \mathit{ncd}$, where $\mathit{ncd}$ is the maximum number of parameters in any of the input series ARIMA models. If there are no input series, ${\mathbf{LDPARX}}\ge 1$.
 14: RMSXY(NSER) – 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
${z}_{t}$ and the values of the output noise component
${n}_{t}$ 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: FVA(NFV) – REAL (KIND=nag_wp) arrayOutput
On exit: the required forecast values for the output series.
 17: FSD(NFV) – REAL (KIND=nag_wp) arrayOutput
On exit: the standard errors for each of the forecast values.
 18: WA(IWA) – REAL (KIND=nag_wp) arrayWorkspace
 19: IWA – INTEGERInput
On entry: the dimension of the array
WA as declared in the (sub)program from which G13BHF is called.
A good, slightly conservative approximation to the required size of
IWA is given by
where
$\mathit{ncf}$ is the largest number of ARIMA parameters in any one of the input or output series.
An exact value for the required size of
IWA can be calculated as follows:
Let 
$\mathit{ncg}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({p}_{i}\right)$, 

$\mathit{nch}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({b}_{i}+{q}_{i}\right)$, 

$\mathit{nci}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({b}_{i}+{q}_{i}+{p}_{i}\right)$, 
over each of the transfer function input series for which
${r}_{i}>1$, where
${b}_{i}$,
${q}_{i}$,
${p}_{i}$ are the orders held in rows
$1$ to
$3$ of array
MT.
Let 
$\mathit{ncj}=1+\mathit{nci}$, 

$\mathit{nck}={\mathbf{NFV}}+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(\mathit{ncg},\mathit{nch}\right)$, 

$\mathit{ncl}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{NSTTF}},\mathit{ncf},\mathit{ncj},\mathit{nck}\right)$, 

$\mathit{ncm}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{NSTTF}}+4\times \mathit{ncf},\mathit{ncl}\right)$, 
then
${\mathbf{IWA}}\ge \mathit{ncm}+3\times \mathit{ncl}+{\mathbf{NFV}}$.
 20: IFAIL – INTEGERInput/Output

On entry:
IFAIL must be set to
$0$,
$1\text{ 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\text{ 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 $\mathbf{1}\text{ or}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit:
${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see
Section 6).
6 Error Indicators and Warnings
If on entry
${\mathbf{IFAIL}}={\mathbf{0}}$ or
${{\mathbf{1}}}$, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
 ${\mathbf{IFAIL}}=1$

On entry,  NSTTF is not consistent with the orders in arrays MR and MT. 
 ${\mathbf{IFAIL}}=2$

On entry,  NPARA is not consistent with the orders in arrays MR and MT. 
 ${\mathbf{IFAIL}}=3$

 ${\mathbf{IFAIL}}=4$

On entry,  IWA is too small. 
 ${\mathbf{IFAIL}}=5$
 ${\mathbf{IFAIL}}=6$
On entry, one of the ${r}_{i}$, stored in ${\mathbf{MT}}\left(4,\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{NSER}}1$, does not equal $1$, $2$ or $3$.
7 Accuracy
The computations are believed to be stable.
The time taken by G13BHF is approximately proportional to ${\mathbf{NFV}}\times {\mathbf{NPARA}}$.
9 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 $\varphi $, $2$ values of $\theta $, $1$ value of $\Theta $, 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 ${z}_{t}$ and the output noise component ${n}_{t}$ corresponding to the forecasts.
9.1 Program Text
Program Text (g13bhfe.f90)
9.2 Program Data
Program Data (g13bhfe.d)
9.3 Program Results
Program Results (g13bhfe.r)