g13ag 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 not in this release)

**g13af**to estimate the relevant parameters. The supplied state set will originally have been produced by (G13AEF not in this release)**g13af**, but may since have been updated by earlier calls to g13ag.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.

# Syntax

C# |
---|

public static void g13ag( double[] st, int nst, int[] mr, double[] par, double c, double[] anx, int nuv, double[] anexr, out int ifail ) |

Visual Basic |
---|

Public Shared Sub g13ag ( _ st As Double(), _ nst As Integer, _ mr As Integer(), _ par As Double(), _ c As Double, _ anx As Double(), _ nuv As Integer, _ anexr As Double(), _ <OutAttribute> ByRef ifail As Integer _ ) |

Visual C++ |
---|

public: static void g13ag( array<double>^ st, int nst, array<int>^ mr, array<double>^ par, double c, array<double>^ anx, int nuv, array<double>^ anexr, [OutAttribute] int% ifail ) |

F# |
---|

static member g13ag : st : float[] * nst : int * mr : int[] * par : float[] * c : float * anx : float[] * nuv : int * anexr : float[] * ifail : int byref -> unit |

#### Parameters

- st
- Type: array<System..::..Double>[]()[][]An array of size [nst]
*On entry*: the state set derived from (G13AEF not in this release)**g13af**, or as modified using earlier calls of g13ag.*On exit*: the updated values of the state set.

- nst
- Type: System..::..Int32
*On entry*: the number of values in the state set array st.*Constraint*: ${\mathbf{nst}}=P\times s+D\times s+d+q+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(p,Q\times s\right)$. (As returned by (G13AEF not in this release)**g13af**).

- mr
- Type: array<System..::..Int32>[]()[][]An array of size [$7$]
*On entry*: the orders vector $\left(p,d,q,P,D,Q,s\right)$ of the ARIMA model, in the usual notation.*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$.

- par
- Type: array<System..::..Double>[]()[][]An array of size [dim1]
**Note:**dim1 must satisfy the constraint: $\mathbf{\_npar}=p+q+P+Q$*On entry*: the estimates of the $p$ values of the $\varphi $ parameters, the $q$ values of the $\theta $ parameters, the $P$ values of the $\Phi $ parameters and the $Q$ values of the $\Theta $ parameters in the model – in that order, using the usual notation.

- c
- Type: System..::..Double
*On entry*: the constant to be subtracted from the differenced data.

- anx
- Type: array<System..::..Double>[]()[][]An array of size [nuv]
*On entry*: the new undifferenced observations which are to be used to update st.

- nuv
- Type: System..::..Int32

- anexr
- Type: array<System..::..Double>[]()[][]An array of size [nuv]
*On exit*: the residuals corresponding to the new observations in anx.

- ifail
- Type: System..::..Int32%
*On exit*: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# Description

The time series model is specified as outlined in Section in g13ae or g13af. 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 ${w}_{t}$ (uncorrected for the constant $c$), for $\left(N-P\times s\right)<t\le N$, |

(ii) | the ${d}^{\prime}$ values required to reconstitute the original series ${x}_{t}$ from the differenced series ${w}_{t}$, |

(iii) | the intermediate series ${e}_{t}$, for $\left(N-\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(p,Q\times s\right)\right)<t\le N$, and |

(iv) | the residual series ${a}_{t}$, for $\left(N-q\right)<t\le N$. |

If the number of original undifferenced observations was $n$, then ${d}^{\prime}=d+\left(D\times s\right)$ and $N=n-{d}^{\prime}$.

To update the state set, given a number of new undifferenced observations ${x}_{t}$, $t=n+1,n+2,\dots ,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 ${w}_{t},{e}_{t}$ and ${a}_{t}$ are derived.

The first $k$ values in these three series are then discarded and a new state set is obtained.

The residuals in the ${a}_{t}$ 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 method.

# References

None.

# Error Indicators and Warnings

Errors or warnings detected by the method:

Some error messages may refer to parameters that are dropped from this interface
(NPAR) In these
cases, an error in another parameter has usually caused an incorrect value to be inferred.

- ${\mathbf{ifail}}=1$
On entry, the orders vector mr is invalid (check the constraints in [Parameters]).

- ${\mathbf{ifail}}=2$
On entry, ${\mathbf{nst}}\ne P\times s+D\times s+d+q+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(Q\times s,p\right)$.

- ${\mathbf{ifail}}=3$
On entry, ${\mathbf{nuv}}\le 0$.

# Accuracy

The computations are believed to be stable.

# Parallelism and Performance

None.

# Further Comments

The time taken by g13ag is approximately proportional to ${\mathbf{nuv}}\times \mathbf{\_npar}$.

# Example

Twelve new observations are supplied. The method updates the state set and outputs a set of residuals corresponding to the new observations.

Example program (C#): g13age.cs