NAG Library Routine Document

g13bgf (multi_inputmod_update)


    1  Purpose
    7  Accuracy


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.


Fortran Interface
Subroutine g13bgf ( sttf, nsttf, mr, nser, mt, para, npara, nnv, xxyn, ldxxyn, kzef, res, wa, iwa, ifail)
Integer, Intent (In):: nsttf, mr(7), nser, mt(4,nser), npara, nnv, ldxxyn, kzef, iwa
Integer, Intent (Inout):: ifail
Real (Kind=nag_wp), Intent (In):: para(npara)
Real (Kind=nag_wp), Intent (Inout):: sttf(nsttf), xxyn(ldxxyn,nser)
Real (Kind=nag_wp), Intent (Out):: res(nnv), wa(iwa)
C Header Interface
#include nagmk26.h
void  g13bgf_ (double sttf[], const Integer *nsttf, const Integer mr[], const Integer *nser, const Integer mt[], const double para[], const Integer *npara, const Integer *nnv, double xxyn[], const Integer *ldxxyn, const Integer *kzef, double res[], double wa[], const Integer *iwa, Integer *ifail)


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:
the transfer models which generate input component values zi,t from one or more inputs xi,t,
which generates the output noise component from the output yt and the input components, and
wt =dsDnt-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 at.
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 yt, x1,t,x2,t,,xm,t, for t=n+1,,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.


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


1:     sttfnsttf – 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:     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 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.
  • 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 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 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. 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 g13bgf.
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 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 ϕ, θ, Φ, Θ, ω, δ 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:     xxynldxxynnser – 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 i, for i=1,2,,nser-1. Column nser contains the values of the output series. Consecutive rows correspond to increasing time sequence.
On exit: if kzef=0, xxyn remains unchanged.
If kzef0, the columns of xxyn hold the corresponding values of the input component series zt and 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 g13bgf is called.
Constraint: ldxxynnnv.
11:   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.
12:   resnnv – Real (Kind=nag_wp) arrayOutput
On exit: the values of the residual series at corresponding to the new observations of the output series.
13:   waiwa – 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: iwannv+2×nsttf+maxnnv,nsttf+maxnnv,ncc, where ncc=4×p+q+P+Q.
15:   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).

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:
On entry,nsttf is not consistent with the orders in arrays mr and mt.
On entry,npara is not consistent with the orders in arrays mr and mt.
On entry,ldxxyn is too small.
On entry,iwa is too small.
On entry, one of the ri, stored in mt4i, for i=1,2,,nser-1 does not equal 1, 2 or 3.
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.
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.
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.


The computations are believed to be stable.

Parallelism and Performance

g13bgf is not threaded in any implementation.

Further Comments

The time taken by g13bgf is approximately proportional to nnv×npara.


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 ϕ1=0.5158, Θ1=0.9994, ω0=8.6343, δ1=0.6726, c=-0.3172.
The following are computed and printed out: the updated state set, the residuals at and the values of the components zt and the output noise component nt corresponding to the new observations.

Program Text

Program Text (g13bgfe.f90)

Program Data

Program Data (g13bgfe.d)

Program Results

Program Results (g13bgfe.r)

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