g13aj applies a fully specified seasonal ARIMA model to an observed time series, generates the state set for forecasting and (optionally) derives a specified number of forecasts together with their standard deviations.
Syntax
C# 

public static void g13aj( int[] mr, double[] par, double c, int kfc, double[] x, int nx, out double rms, double[] st, out int nst, int nfv, double[] fva, double[] fsd, int[] isf, out int ifail ) 
Visual Basic 

Public Shared Sub g13aj ( _ mr As Integer(), _ par As Double(), _ c As Double, _ kfc As Integer, _ x As Double(), _ nx As Integer, _ <OutAttribute> ByRef rms As Double, _ st As Double(), _ <OutAttribute> ByRef nst As Integer, _ nfv As Integer, _ fva As Double(), _ fsd As Double(), _ isf As Integer(), _ <OutAttribute> ByRef ifail As Integer _ ) 
Visual C++ 

public: static void g13aj( array<int>^ mr, array<double>^ par, double c, int kfc, array<double>^ x, int nx, [OutAttribute] double% rms, array<double>^ st, [OutAttribute] int% nst, int nfv, array<double>^ fva, array<double>^ fsd, array<int>^ isf, [OutAttribute] int% ifail ) 
F# 

static member g13aj : mr : int[] * par : float[] * c : float * kfc : int * x : float[] * nx : int * rms : float byref * st : float[] * nst : int byref * nfv : int * fva : float[] * fsd : float[] * isf : int[] * ifail : int byref > unit 
Parameters
 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$;
 $d+s\times \left(P+D\right)\le n$;
 $p+dq+s\times \left(P+DQ\right)\le n$.
 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 $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 that order.
 c
 Type: System..::..DoubleOn entry: $c$, the expected value of the differenced series (i.e., $c$ is the constant correction). Where there is no constant term, c must be set to $0.0$.
 kfc
 Type: System..::..Int32On entry: must be set to $0$ if c was not estimated, and $1$ if c was estimated. This is irrespective of whether or not ${\mathbf{c}}=0.0$. The only effect is that the residual degrees of freedom are one greater when ${\mathbf{kfc}}=0$. Assuming the supplied time series to be the same as that to which the model was originally fitted, this ensures an unbiased estimate of the residual meansquare.Constraint: ${\mathbf{kfc}}=0$ or $1$.
 x
 Type: array<System..::..Double>[]()[][]An array of size [nx]On entry: the $n$ values of the original undifferenced time series.
 nx
 Type: System..::..Int32On entry: $n$, the length of the original undifferenced time series.
 rms
 Type: System..::..Double%On exit: the residual variance (mean square) associated with the model.
 st
 Type: array<System..::..Double>[]()[][]An array of size [ist]On exit: the nst values of the state set.
 nst
 Type: System..::..Int32%On exit: the number of values in the state set array st.
 nfv
 Type: System..::..Int32On entry: the required number of forecasts. If ${\mathbf{nfv}}\le 0$, no forecasts will be computed.
 fva
 Type: array<System..::..Double>[]()[][]An array of size [ifv]
 fsd
 Type: array<System..::..Double>[]()[][]An array of size [ifv]
 isf
 Type: array<System..::..Int32>[]()[][]An array of size [$4$]On exit: contains validity indicators, one for each of the four possible parameter types in the model (autoregressive, moving average, seasonal autoregressive, seasonal moving average), in that order.Each indicator has the interpretation:
$1$ On entry the set of parameter values of this type does not satisfy the stationarity or invertibility test conditions. $\phantom{}0$ No parameter of this type is in the model. $\phantom{}1$ Valid parameter values of this type have been supplied.
 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 ${x}_{1},{x}_{2},\dots ,{x}_{n}$ supplied to the method is assumed to follow a seasonal autoregressive integrated moving average (ARIMA) model with known parameters.
The model is defined by the following relations.
(a)  ${\nabla}^{d}{\nabla}_{s}^{D}{x}_{t}c={w}_{t}$ where ${\nabla}^{d}{\nabla}_{s}^{D}{x}_{t}$ is the result of applying nonseasonal differencing of order $d$ and seasonal differencing of seasonality $s$ and order $D$ to the series ${x}_{t}$, and $c$ is a constant. 
(b)  ${w}_{t}={\Phi}_{1}{w}_{ts}+{\Phi}_{2}{w}_{t2\times s}+\cdots +{\Phi}_{P}{w}_{tP\times s}+{e}_{t}{\Theta}_{1}{e}_{ts}{\Theta}_{2}{e}_{t2\times s}\cdots {\Theta}_{Q}{e}_{tQ\times s}\text{.}$ This equation describes the seasonal structure with seasonal period $s$; in the absence of seasonality it reduces to ${w}_{t}={e}_{t}$. 
(c)  ${e}_{t}={\varphi}_{1}{e}_{t1}+{\varphi}_{2}{e}_{t2}+\cdots +{\varphi}_{p}{e}_{tp}+{a}_{t}{\theta}_{1}{a}_{t1}{\theta}_{2}{a}_{t2}\cdots {\theta}_{q}{a}_{tq}\text{.}$ This equation describes the nonseasonal structure. 
Given the series, the constant $c$, and the model parameters $\Phi $, $\Theta $, $\varphi $, $\theta $, the method computes the following.
(a)  The state set required for forecasting. This contains the minimum amount of information required for forecasting and comprises:


(b)  A set of $L$ forecasts of ${x}_{t}$ and their estimated standard errors, ${s}_{t}$, for $\mathit{t}=n+1,\dots ,n+L$ ($L$ may be zero).
The forecasts and estimated standard errors are generated from the state set, and are identical to those that would be produced from the same state set by g13ah. 
Use of g13aj should be confined to situations in which the state set for forecasting is unknown. Forecasting from the series requires recalculation of the state set and this is relatively expensive.
References
Box G E P and Jenkins G M (1976) Time Series Analysis: Forecasting and Control (Revised Edition) Holden–Day
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]), or ${\mathbf{kfc}}\ne 0$ or $1$.
 ${\mathbf{ifail}}=2$
 On entry, ${\mathbf{nx}}dD\times s\le \mathbf{\_npar}+{\mathbf{kfc}}$, i.e., the number of terms in the differenced series is not greater than the number of parameters in the model. The model is overparameterised.
 ${\mathbf{ifail}}=3$
 On entry, the workspace array w is too small.
 ${\mathbf{ifail}}=4$
 ${\mathbf{ifail}}=5$
 This indicates a failure in (F04ASF not in this release) which is used to solve the equations giving estimates of the backforecasts.
 ${\mathbf{ifail}}=6$
 On entry, valid values were not supplied for all parameter types in the model. Inspect array isf for further information on the parameter type(s) in error.
 ${\mathbf{ifail}}=7$
On entry, ${\mathbf{ifv}}<\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{nfv}}\right)$.
 ${\mathbf{ifail}}=9000$
 An error occured, see message report.
 ${\mathbf{ifail}}=1000$
 The array lengths are not the same for arrays
 ${\mathbf{ifail}}=8000$
 Negative dimension for array $\u2329\mathit{\text{value}}\u232a$
 ${\mathbf{ifail}}=6000$
 Invalid Parameters $\u2329\mathit{\text{value}}\u232a$
Accuracy
The computations are believed to be stable.
Parallelism and Performance
None.
Further Comments
The time taken by g13aj is approximately proportional to $n$ and the square of the number of backforecasts derived.