g13ah produces forecasts of a time series, given a time series model which has already been fitted to the time series using (G13AEF not in this release)

**g13af**. The original observations are not required, since g13ah uses as input either the original state set produced by (G13AEF not in this release)**g13af**or the state set updated by a series of new observations using g13ag. Standard errors of the forecasts are also provided.# Syntax

C# |
---|

public static void g13ah( double[] st, int nst, int[] mr, double[] par, double c, double rms, int nfv, double[] fva, double[] fsd, out int ifail ) |

Visual Basic |
---|

Public Shared Sub g13ah ( _ st As Double(), _ nst As Integer, _ mr As Integer(), _ par As Double(), _ c As Double, _ rms As Double, _ nfv As Integer, _ fva As Double(), _ fsd As Double(), _ <OutAttribute> ByRef ifail As Integer _ ) |

Visual C++ |
---|

public: static void g13ah( array<double>^ st, int nst, array<int>^ mr, array<double>^ par, double c, double rms, int nfv, array<double>^ fva, array<double>^ fsd, [OutAttribute] int% ifail ) |

F# |
---|

static member g13ah : st : float[] * nst : int * mr : int[] * par : float[] * c : float * rms : float * nfv : int * fva : float[] * fsd : 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**originally, or as modified using earlier calls of g13ag.

- 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 which specify the model and which were output originally by (G13AEF not in this release)**g13af**.

- c
- Type: System..::..Double
*On entry*: $c$, the value of the model constant. This will have been output by (G13AEF not in this release)**g13af**.

- rms
- Type: System..::..Double
*On entry*: $V$, the residual variance associated with the model.*Constraint*: ${\mathbf{rms}}\ge 0.0$.

- nfv
- Type: System..::..Int32
*On entry*: $L$, the required number of forecasts.*Constraint*: ${\mathbf{nfv}}>0$.

- fva
- Type: array<System..::..Double>[]()[][]An array of size [nfv]
*On exit*: nfv forecast values relating to the original undifferenced series.

- fsd
- Type: array<System..::..Double>[]()[][]An array of size [nfv]

- 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 original time series is ${x}_{\mathit{t}}$, for $\mathit{t}=1,2,\dots ,n$ and parameters have been fitted to the model of this time series using (G13AEF not in this release)

**g13af**.Forecasts of ${x}_{\mathit{t}}$, for $\mathit{t}=n+1,\dots ,n+L$, are calculated in five stages, as follows:

(i) | set ${a}_{t}=0$ for $t=N+1,N+2,\dots ,N+L$, where $N=n-d-\left(D\times s\right)$ is the number of differenced values in the series; |

(ii) | calculate the values of ${e}_{\mathit{t}}$, for $\mathit{t}=N+1,\dots ,N+L$, and ${e}_{\mathit{t}}={\varphi}_{1}\times {e}_{t-1}+\cdots +\phantom{\rule{0ex}{0ex}}{\varphi}_{p}\times {e}_{t-p}+{a}_{t}-{\theta}_{1}\times {a}_{t-1}-\cdots -{\theta}_{q}\times {a}_{t-q}$; |

(iii) | calculate the values of ${w}_{\mathit{t}}$, for $\mathit{t}=N+1,\dots ,N+L$, where ${w}_{t}={\Phi}_{1}\times {w}_{t-s}+\cdots +\phantom{\rule{0ex}{0ex}}{\Phi}_{P}\times {w}_{t-s\times P}+{e}_{t}-{\Theta}_{1}\times {e}_{t-s}-\cdots -{\Theta}_{Q}\times {e}_{t-s\times Q}$ and ${w}_{t}$ for $t\le N$ are the first $s\times P$ values in the state set, corrected for the constant; |

(iv) | add the constant term $c$ to give the differenced series ${\nabla}^{d}{\nabla}_{s}^{D}{x}_{\mathit{t}}={w}_{\mathit{t}}+c$, for $\mathit{t}=N+1,\dots ,N+L$; |

(v) | the differencing operations are reversed to reconstitute ${x}_{\mathit{t}}$, for $\mathit{t}=n+1,\dots ,n+L$. |

The standard errors of these forecasts are given by ${s}_{\mathit{t}}={\left[V\times \left({\psi}_{0}^{2}+{\psi}_{1}^{2}+\dots +{\psi}_{\mathit{t}-n-1}^{2}\right)\right]}^{1/2}$, for $\mathit{t}=n+1,\dots ,n+L$, where ${\psi}_{0}=1$, $V$ is the residual variance of ${a}_{t}$, and ${\psi}_{j}$ is the coefficient expressing the dependence of ${x}_{t}$ on ${a}_{t-j}$.

To calculate ${\psi}_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,\left(L-1\right)$, the following device is used.

A copy of the state set is initialized to zero throughout and the calculations outlined above for the construction of forecasts are carried out with the settings ${a}_{N+1}=1$, and ${a}_{\mathit{t}}=0$, for $\mathit{t}=N+2,\dots ,N+L$.

The resulting quantities corresponding to the sequence ${x}_{N+1},{x}_{N+2},\dots ,{x}_{N+L}$ are precisely $1$, ${\psi}_{1},{\psi}_{2},\dots ,{\psi}_{L-1}$.

The supplied time series model is used throughout these calculations, with the exception that the constant term $c$ is taken to be zero.

# 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 given 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{nfv}}\le 0$.

- ${\mathbf{ifail}}=5$
On entry, ${\mathbf{rms}}<0.0$.

# Accuracy

The computations are believed to be stable.

# Parallelism and Performance

None.

# Further Comments

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

# Example

These consist of a set of orders indicating that there are two moving average parameters (one non-seasonal, and one seasonal with periodicity $12$).

The model constant is zero.

The state set contains $26$ values.

In addition the residual mean-square derived when the model was originally fitted is given.

Twelve forecasts and their associated errors are obtained.

Example program (C#): g13ahe.cs