NAG Library Routine Document
g13bjf (multi_inputmod_forecast)
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 multiinput 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
Fortran Interface
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, Intent (In)  ::  nser, mt(4,nser), npara, kfc, nev, nfv, ldxxy, kzef, ldparx, isttf, iwa, imwa  Integer, Intent (Inout)  ::  mr(7), mrx(7,nser), ifail  Integer, Intent (Out)  ::  nsttf, mwa(imwa)  Real (Kind=nag_wp), Intent (In)  ::  parx(ldparx,nser)  Real (Kind=nag_wp), Intent (Inout)  ::  para(npara), xxy(ldxxy,nser), rmsxy(nser)  Real (Kind=nag_wp), Intent (Out)  ::  fva(nfv), fsd(nfv), sttf(isttf), wa(iwa) 

C Header Interface
#include <nagmk26.h>
void 
g13bjf_ (Integer mr[], const Integer *nser, const Integer mt[], double para[], const Integer *npara, const Integer *kfc, const Integer *nev, const Integer *nfv, double xxy[], const Integer *ldxxy, const Integer *kzef, double rmsxy[], Integer mrx[], const double parx[], const Integer *ldparx, double fva[], double fsd[], double sttf[], const Integer *isttf, Integer *nsttf, double wa[], const Integer *iwa, Integer mwa[], const Integer *imwa, Integer *ifail) 

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 preobservation period effects of the input series are estimated where requested, and so are any backforecasts of the output noise series. The output components
${z}_{t}$ and
${n}_{t}$, and residuals
${a}_{t}$ 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
Arguments
 1: $\mathbf{mr}\left(7\right)$ – 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$ refer respectively to 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$;
 $d+s\times \left(P+D\right)\le n$;
 $p+dq+s\times \left(P+DQ\right)\le n$.
 2: $\mathbf{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: $\mathbf{mt}\left(4,{\mathbf{nser}}\right)$ – 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
${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, and ${r}_{i}=2\text{or}3$ for a transfer function input.
The choice ${r}_{i}=3$ leads to estimation of the preperiod input effects as nuisance parameters, and ${r}_{i}=2$ suppresses this estimation. This choice may affect the returned forecasts and the state set.
When ${r}_{i}=1$, any nonzero contents of rows 1, 2 and 3 of column $i$ are ignored.
Constraint:
${\mathbf{mt}}\left(4,\mathit{i}\right)=1$, $2$ or $3$, for $\mathit{i}=1,2,\dots ,{\mathbf{nser}}1$.
 4: $\mathbf{para}\left({\mathbf{npara}}\right)$ – Real (Kind=nag_wp) arrayInput/Output

On entry: estimates of the multiinput model parameters. These are in order, firstly the ARIMA model parameters:
$p$ values of
$\varphi $ parameters,
$q$ values of
$\theta $ parameters,
$P$ values of
$\Phi $ parameters,
$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},\dots ,{\delta}_{{p}_{1}}$ 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: $\mathbf{npara}$ – IntegerInput

On entry: the exact number of $\varphi $, $\theta $, $\Phi $, $\Theta $, $\omega $, $\delta $, $c$ parameters, so that ${\mathbf{npara}}=p+q+P+Q+{\mathbf{nser}}+\sum \left(p+q\right)$, the summation being over all the input series. ($c$ must be included whether its value was previously estimated or was set fixed.)
 6: $\mathbf{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:
${\mathbf{kfc}}=0$ or $1$.
 7: $\mathbf{nev}$ – IntegerInput

On entry: the number of original (undifferenced) values in each of the input and output time series.
 8: $\mathbf{nfv}$ – IntegerInput

On entry: the number of forecast values of the output series required.
Constraint:
${\mathbf{nfv}}>0$.
 9: $\mathbf{xxy}\left({\mathbf{ldxxy}},{\mathbf{nser}}\right)$ – 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
${\mathbf{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
${\mathbf{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
${\mathbf{kzef}}\ne 0$ then the columns of
xxy contain the corresponding values of the input component series
${z}_{t}$ and the values of the output noise component
${n}_{t}$, in that order.
 10: $\mathbf{ldxxy}$ – IntegerInput

On entry: the first dimension of the array
xxy as declared in the (sub)program from which
g13bjf is called.
Constraint:
${\mathbf{ldxxy}}\ge \left({\mathbf{nev}}+{\mathbf{nfv}}\right)$.
 11: $\mathbf{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
${z}_{t}$ and the values of the output noise component
${n}_{t}$ are to overwrite the contents of
xxy on exit.
 12: $\mathbf{rmsxy}\left({\mathbf{nser}}\right)$ – Real (Kind=nag_wp) arrayInput/Output

On entry: the first
$\left({\mathbf{nser}}1\right)$ 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:
${\mathbf{rmsxy}}\left({\mathbf{nser}}\right)$ contains the estimated residual variance of the output noise ARIMA model which is calculated from the supplied series. Otherwise
rmsxy is unchanged.
 13: $\mathbf{mrx}\left(7,{\mathbf{nser}}\right)$ – 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: $\mathbf{parx}\left({\mathbf{ldparx}},{\mathbf{nser}}\right)$ – 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 $, ${\mathbf{mrx}}\left(3,i\right)$ values of $\theta $, ${\mathbf{mrx}}\left(4,i\right)$ values of $\Phi $ and ${\mathbf{mrx}}\left(6,i\right)$ values of $\Theta $, in that order.
Values in the columns relating to those input series for which no ARIMA model is available are ignored.
 15: $\mathbf{ldparx}$ – IntegerInput

On entry: the first dimension of the array
parx as declared in the (sub)program from which
g13bjf is called.
Constraint:
${\mathbf{ldparx}}\ge \mathit{nce}$, where $\mathit{nce}$ is the maximum number of parameters in any of the input series ARIMA models. If there are no input series, then ${\mathbf{ldparx}}\ge 1$.
 16: $\mathbf{fva}\left({\mathbf{nfv}}\right)$ – 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
${\mathbf{kzef}}=0$.)
 17: $\mathbf{fsd}\left({\mathbf{nfv}}\right)$ – Real (Kind=nag_wp) arrayOutput

On exit: the standard errors for each of the forecast values.
 18: $\mathbf{sttf}\left({\mathbf{isttf}}\right)$ – 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: $\mathbf{isttf}$ – IntegerInput

On entry: the dimension of the array
sttf as declared in the (sub)program from which
g13bjf is called.
Constraint:
${\mathbf{isttf}}\ge \left(P\times s\right)+d+\left(D\times s\right)+q+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(p,Q\times s\right)+\mathit{ncf}$, where $\mathit{ncf}=\sum \left({b}_{i}+{q}_{i}+{p}_{i}\right)$ and the summation is over all input series for which ${r}_{i}>1$.
 20: $\mathbf{nsttf}$ – IntegerOutput

On exit: the number of values in the state set array
sttf.
 21: $\mathbf{wa}\left({\mathbf{iwa}}\right)$ – Real (Kind=nag_wp) arrayOutput
 22: $\mathbf{iwa}$ – IntegerInput
 23: $\mathbf{mwa}\left({\mathbf{imwa}}\right)$ – Integer arrayOutput
 24: $\mathbf{imwa}$ – IntegerInput

These arguments are no longer accessed by g13bjf. Workspace is provided internally by dynamic allocation instead.
 25: $\mathbf{ifail}$ – IntegerInput/Output

On entry:
ifail must be set to
$0$,
$1\text{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\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 argument, 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}}=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:
 ${\mathbf{ifail}}=1$

On entry, ${\mathbf{kfc}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{kfc}}=0$ or $1$.
On entry, ${\mathbf{ldxxy}}=\u2329\mathit{\text{value}}\u232a$, ${\mathbf{nev}}=\u2329\mathit{\text{value}}\u232a$ and ${\mathbf{nfv}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{ldxxy}}\ge {\mathbf{nev}}+{\mathbf{nfv}}$.
On entry, ${\mathbf{nfv}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{nfv}}>0$.
 ${\mathbf{ifail}}=2$

Insufficient degrees of freedom to solve the problem.
npara is inconsistent with
mr and
mt.
On entry, $i=\u2329\mathit{\text{value}}\u232a$ and ${\mathbf{mt}}\left(4,i\right)=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{mt}}\left(4,i\right)=1$, $2$ or $3$.
On entry, ${\mathbf{ldparx}}=\u2329\mathit{\text{value}}\u232a$ and the minimum size $\text{required}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{ldparx}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\text{max. number of parameters in any input series}\right)$.
On entry,
${\mathbf{npara}}=\u2329\mathit{\text{value}}\u232a$ and the expected
$\text{value}=\u2329\mathit{\text{value}}\u232a$.
Constraint:
npara,
mr and
mt must be consistent.
The orders vector
mr is invalid.
 ${\mathbf{ifail}}=3$

One or more sets of delta parameters do not satisfy the stationarity or invertibility conditions.
 ${\mathbf{ifail}}=8$

Unable to calculate the latest parameter estimates.
 ${\mathbf{ifail}}=9$

Failure in inversion of second derivative matrix.
 ${\mathbf{ifail}}=10$

One or more sets of ARIMA parameters do not satisfy the stationarity or invertibility conditions.
 ${\mathbf{ifail}}=11$

On entry, ${\mathbf{isttf}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{isttf}}\ge \left(P\times s\right)+d+\left(D\times s\right)+q+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(p,Q\times s\right)+\mathrm{ncf}$.
 ${\mathbf{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.
 ${\mathbf{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.
 ${\mathbf{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
g13bjf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g13bjf 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 implementationspecific information.
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 multiinput model.
10
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
$\left(\varphi \right)$ parameter and one seasonal moving average
$\left(\Theta \right)$ parameter, with initial values
$\varphi =0.495$,
$\Theta =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
${b}_{5}=1$,
${q}_{5}=0$,
${p}_{5}=1$,
${r}_{5}=3$, which allows for preobservation period effects. The initial values for the transfer model are:

${\omega}_{1}=0.367\text{, \hspace{1em}}{\omega}_{2}=3.876\text{, \hspace{1em}}{\omega}_{3}=4.516\text{, \hspace{1em}}{\omega}_{4}=2.474\text{\hspace{1em}}{\omega}_{5}=8.629\text{,\hspace{1em}}{\delta}_{1}=0.688\text{.}$
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 $\begin{array}{ccccccc}2& 0& 2& 0& 1& 1& 4\end{array}\text{,}$ in which ${\varphi}_{1}=1.6743$, ${\varphi}_{2}=0.9505$, ${\theta}_{1}=1.4605$, ${\theta}_{2}=0.4862$ and ${\Theta}_{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 ${z}_{t}$ and the output noise component ${n}_{t}$.
10.1
Program Text
Program Text (g13bjfe.f90)
10.2
Program Data
Program Data (g13bjfe.d)
10.3
Program Results
Program Results (g13bjfe.r)