NAG Library Routine Document

g13agf (uni_arima_update)


g13agf accepts a series of new observations of a time series, the model of which is already fully specified, and updates the ‘state set’ information for use in constructing further forecasts. The previous specifications of the time series model should have been obtained by using g13aef or g13aff to estimate the relevant parameters. The supplied state set will originally have been produced by g13aef or g13aff, but may since have been updated by earlier calls to g13agf.
A set of residuals corresponding to the new observations is returned. These may be of use in checking that the new observations conform to the previously fitted model.


Fortran Interface
Subroutine g13agf ( st, nst, mr, par, npar, c, anx, nuv, anexr, wa, nwa, ifail)
Integer, Intent (In):: nst, mr(7), npar, nuv, nwa
Integer, Intent (Inout):: ifail
Real (Kind=nag_wp), Intent (In):: par(npar), c, anx(nuv)
Real (Kind=nag_wp), Intent (Inout):: st(nst)
Real (Kind=nag_wp), Intent (Out):: anexr(nuv), wa(nwa)
C Header Interface
#include <nagmk26.h>
void  g13agf_ (double st[], const Integer *nst, const Integer mr[], const double par[], const Integer *npar, const double *c, const double anx[], const Integer *nuv, double anexr[], double wa[], const Integer *nwa, Integer *ifail)


The time series model is specified as outlined in Section 3 in g13aef or g13aff. This also describes how the state set, which contains the minimum amount of time series information needed to construct forecasts, is made up of
(i) the differenced series wt (uncorrected for the constant c), for N-P×s<tN,
(ii) the d values required to reconstitute the original series xt from the differenced series wt,
(iii) the intermediate series et, for N - maxp, Q × s < t N , and
(iv) the residual series at, for N-q<tN.
If the number of original undifferenced observations was n, then d=d+D×s and N=n-d.
To update the state set, given a number of new undifferenced observations xt, t=n+1,n+2,,n+k, the four series above are first reconstituted.
Differencing and residual calculation operations are then applied to the new observations and k new values of wt,et and at are derived.
The first k values in these three series are then discarded and a new state set is obtained.
The residuals in the at series corresponding to the k new observations are preserved in an output array. The parameters of the time series model are not changed in this routine.




1:     stnst – Real (Kind=nag_wp) arrayInput/Output
On entry: the state set derived from g13aef or g13aff, or as modified using earlier calls of g13agf.
On exit: the updated values of the state set.
2:     nst – IntegerInput
On entry: the number of values in the state set array st.
Constraint: nst=P×s+D×s+d+q+maxp,Q×s. (As returned by g13aef or g13aff).
3:     mr7 – Integer arrayInput
On entry: the orders vector p,d,q,P,D,Q,s of the ARIMA model, in the usual notation.
  • 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:     parnpar – Real (Kind=nag_wp) arrayInput
On entry: the estimates of the p values of the ϕ parameters, the q values of the θ parameters, the P values of the Φ parameters and the Q values of the Θ parameters in the model – in that order, using the usual notation.
5:     npar – IntegerInput
On entry: the number of ϕ, θ, Φ and Θ parameters in the model.
Constraint: npar=p+q+P+Q.
6:     c – Real (Kind=nag_wp)Input
On entry: the constant to be subtracted from the differenced data.
7:     anxnuv – Real (Kind=nag_wp) arrayInput
On entry: the new undifferenced observations which are to be used to update st.
8:     nuv – IntegerInput
On entry: k, the number of new observations in anx.
9:     anexrnuv – Real (Kind=nag_wp) arrayOutput
On exit: the residuals corresponding to the new observations in anx.
10:   wanwa – Real (Kind=nag_wp) arrayWorkspace
11:   nwa – IntegerInput
On entry: the dimension of the array wa as declared in the (sub)program from which g13agf is called.
Constraint: nwa4×npar+3×nst.
12:   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, npar=value.
Constraint: npar=p+q+P+Q.
The orders vector mr is invalid.
On entry, nst=value.
Constraint: nst=P×s+D×s+d+q+maxQ×s,p.
On entry, nuv=value.
Constraint: nuv>0.
On entry, nwa=value and the minimum size required=value.
Constraint: nwa4×npar+3×nst.
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

g13agf is not threaded in any implementation.

Further Comments

The time taken by g13agf is approximately proportional to nuv×npar.


The following program is based on data derived from a study of monthly airline passenger totals (in thousands) to which a logarithmic transformation had been applied. The time series model was based on seasonal and non-seasonal differencing both of order 1, with seasonal period 12. The number of parameters estimated was two: a non-seasonal moving average parameter θ1 with value 0.327 and a seasonal moving average parameter Θ1 with value 0.6270. There was no constant correction. These, together with the state set array, were obtained using g13aef.
Twelve new observations are supplied. The routine updates the state set and outputs a set of residuals corresponding to the new observations.

Program Text

Program Text (g13agfe.f90)

Program Data

Program Data (g13agfe.d)

Program Results

Program Results (g13agfe.r)