G13 Chapter Contents
G13 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG13BGF

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.

## 1  Purpose

G13BGF accepts a series of new observations of an output time series and any associated input time series, for which a multi-input model is already fully specified, and updates the ‘state set’ information for use in constructing further forecasts.
The previous specification of the multi-input model will normally have been obtained by using G13BEF to estimate the relevant transfer function and ARIMA parameters. The supplied state set will originally have been produced by G13BEF (or possibly G13BJF), but may since have been updated by G13BGF.

## 2  Specification

 SUBROUTINE G13BGF ( STTF, NSTTF, MR, NSER, MT, PARA, NPARA, NNV, XXYN, LDXXYN, KZEF, RES, WA, IWA, IFAIL)
 INTEGER NSTTF, MR(7), NSER, MT(4,NSER), NPARA, NNV, LDXXYN, KZEF, IWA, IFAIL REAL (KIND=nag_wp) STTF(NSTTF), PARA(NPARA), XXYN(LDXXYN,NSER), RES(NNV), WA(IWA)

## 3  Description

The multi-input model is specified in Section 3 in G13BEF. The form of these equations required to update the state set is as follows:
 $zt=δ1zt-1+δ2zt-2+⋯+δpzt-p+ω0xt-b-ω1xt-b-1-⋯-ωqxt-b-q$
the transfer models which generate input component values ${z}_{i,t}$ from one or more inputs ${x}_{i,t}$,
 $nt=yt-z1,t-z2,t-⋯-zm,t$
which generates the output noise component from the output ${y}_{t}$ and the input components, and
 $wt =∇d∇sDnt-c et =wt-Φ1wt-s-Φ2wt-2×s-⋯-ΦPwt-P×s+Θ1et-s+Θ2et-2×s+⋯+ΘQet-Q×s at =et-ϕ1et-1-ϕ2et-2-⋯-ϕpet-p+θ1at-1+θ2at-2+⋯+θqat-q$
the ARIMA model for the output noise which generates the residuals ${a}_{t}$.
The state set (as also given in Section 3 in G13BEF) is the collection of terms
 $zn+1-k,xn+1-k,nn+1-k,wn+1-k,en+1-k and an+1-k$
for $k=1$ up to the maximum lag associated with each of these series respectively, in the above model equations. $n$ is the latest time point of the series from which the state set has been generated.
The routine accepts further values of the series ${y}_{\mathit{t}}$, ${x}_{1,\mathit{t}},{x}_{2,\mathit{t}},\dots ,{x}_{m,\mathit{t}}$, for $\mathit{t}=n+1,\dots ,n+l$, and applies the above model equations over this time range, to generate new values of the various model components, noise series and residuals. The state set is reconstructed, corresponding to the latest time point $n+l$, the earlier values being discarded.
The set of residuals corresponding to the new observations may be of use in checking that the new observations conform to the previously fitted model. The components of the new observations of the output series which are due to the various inputs, and the noise component, are also optionally returned.
The parameters of the model are not changed in this routine.

## 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/Output
On entry: the NSTTF values in the state set before updating as returned by G13BEF or G13BJF, or a previous call to G13BGF.
On exit: the state set values after updating.
2:     NSTTF – INTEGERInput
On entry: the exact number of values in the state set array STTF as returned by G13BEF or G13BJF.
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$ 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 non-seasonal 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 model 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 and ${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 G13BGF.
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 multi-input 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 similarly for each subsequent input series. The final component of PARA is the value of 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:     NNV – INTEGERInput
On entry: the number of new observation sets being used to update the state set, each observation set consisting of a value of the output series and the associated values of each of the input series at a particular time point.
9:     XXYN(LDXXYN,NSER) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the NNV new observation sets being used to update the state set. Column $i$ contains the values of input series $\mathit{i}$, for $\mathit{i}=1,2,\dots ,{\mathbf{NSER}}-1$. Column ${\mathbf{NSER}}$ contains the values of the output series. Consecutive rows correspond to increasing time sequence.
On exit: if ${\mathbf{KZEF}}=0$, XXYN remains unchanged.
If ${\mathbf{KZEF}}\ne 0$, the columns of XXYN hold the corresponding values of the input component series ${z}_{t}$ and 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 G13BGF is called.
Constraint: ${\mathbf{LDXXYN}}\ge {\mathbf{NNV}}$.
11:   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.
12:   RES(NNV) – REAL (KIND=nag_wp) arrayOutput
On exit: the values of the residual series ${a}_{t}$ corresponding to the new observations of the output series.
13:   WA(IWA) – REAL (KIND=nag_wp) arrayWorkspace
14:   IWA – INTEGERInput
On entry: the dimension of the array WA as declared in the (sub)program from which G13BGF is called.
Constraint: ${\mathbf{IWA}}\ge {\mathbf{NNV}}+2×{\mathbf{NSTTF}}+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{NNV}},{\mathbf{NSTTF}}\right)+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{NNV}},\mathit{ncc}\right)$, where $\mathit{ncc}=4×\left(p+q+P+Q\right)$.
15:   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$
 On entry, LDXXYN is too small.
${\mathbf{IFAIL}}=4$
 On entry, IWA is too small.
${\mathbf{IFAIL}}=5$
On entry, one of the ${r}_{\mathit{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 G13BGF is approximately proportional to ${\mathbf{NNV}}×{\mathbf{NPARA}}$.

## 9  Example

This example uses the data described in G13BEF in which $40$ observations of an output time series and a single input series were processed. In this example a model which included seasonal differencing of order $1$ was used. The $10$ values of the state set and the $5$ final values of PARA then obtained are used as input to this program, together with the values of $4$ new observations and the transfer function orders of the input series. The model used is ${\varphi }_{1}=0.5158$, ${\Theta }_{1}=0.9994$, ${\omega }_{0}=8.6343$, ${\delta }_{1}=0.6726$, $c=-0.3172$.
The following are computed and printed out: the updated state set, the residuals ${a}_{t}$ and the values of the components ${z}_{t}$ and the output noise component ${n}_{t}$ corresponding to the new observations.

### 9.1  Program Text

Program Text (g13bgfe.f90)

### 9.2  Program Data

Program Data (g13bgfe.d)

### 9.3  Program Results

Program Results (g13bgfe.r)