g13aff is an easy-to-use version of g13aef. It fits a seasonal autoregressive integrated moving average (ARIMA) model to an observed time series, using a nonlinear least squares procedure incorporating backforecasting. Parameter estimates are obtained, together with appropriate standard errors. The residual series is returned, and information for use in forecasting the time series is produced for use in g13agfandg13ahf.
The estimation procedure is iterative, starting with initial parameter values such as may be obtained using g13adf. It continues until a specified convergence criterion is satisfied or until a specified number of iterations have been carried out. The progress of the iteration can be monitored by means of an optional printing facility.
The routine may be called by the names g13aff or nagf_tsa_uni_arima_estim_easy.
3Description
The time series ${x}_{1},{x}_{2},\dots ,{x}_{n}$ supplied to the routine is assumed to follow a seasonal autoregressive integrated moving average (ARIMA) model defined as follows:
where ${\nabla}^{d}{\nabla}_{s}^{D}{x}_{t}$ is the result of applying non-seasonal differencing of order $d$ and seasonal differencing of seasonality $s$ and order $D$ to the series ${x}_{t}$, as outlined in the description of g13aaf. The differenced series is then of length $N=n-{d}^{\prime}$, where ${d}^{\prime}=d+(D\times s)$ is the generalized order of differencing. The scalar $c$ is the expected value of the differenced series, and the series ${w}_{1},{w}_{2},\dots ,{w}_{N}$ follows a zero-mean stationary autoregressive moving average (ARMA) model defined by a pair of recurrence equations. These express ${w}_{t}$ in terms of an uncorrelated series ${a}_{t}$, via an intermediate series ${e}_{t}$. The first equation describes the seasonal structure:
The second equation describes the non-seasonal structure. If the model is purely non-seasonal the first equation is redundant and ${e}_{t}$ above is equated with ${w}_{t}$:
and (optionally) $c$ are obtained by minimizing a quadratic form in the vector $w={({w}_{1},{w}_{2},\dots ,{w}_{N})}^{\prime}$.
The minimization process is iterative, iterations being performed until convergence is achieved (see Section 3 in g13aef for full details), or until the user-specified maximum number of iterations are completed.
The final values of the residual sum of squares and the parameter estimates are used to obtain asymptotic approximations to the standard deviations of the parameters, and the correlation matrix for the parameters. The ‘state set’ array of information required by forecasting is also returned.
Note: if the maximum number of iterations are performed without convergence, these quantities may not be reliable. In this case, the sequence of iterates should be checked, using the optional monitoring routine, to verify that convergence is adequate for practical purposes.
4References
Box G E P and Jenkins G M (1976) Time Series Analysis: Forecasting and Control (Revised Edition) Holden–Day
Marquardt D W (1963) An algorithm for least squares estimation of nonlinear parameters J. Soc. Indust. Appl. Math.11 431
On entry: the orders vector $(p,d,q,P,D,Q,s)$ of the ARIMA model whose parameters are to be estimated. $p$, $q$, $P$ and $Q$ refer respectively to the number of autoregressive $\left(\varphi \right)$, moving average $\left(\theta \right)$, seasonal autoregressive $\left(\Phi \right)$ and seasonal moving average $\left(\Theta \right)$ parameters. $d$, $D$ and $s$ refer respectively to the order of non-seasonal differencing, the order of seasonal differencing and the seasonal period.
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 (P+D)\le n$;
$p+d-q+s\times (P+D-Q)\le n$.
2: $\mathbf{par}\left({\mathbf{npar}}\right)$ – Real (Kind=nag_wp) arrayInput/Output
On entry: the initial 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 that order.
On exit: contains the latest values of the estimates of these parameters.
3: $\mathbf{npar}$ – IntegerInput
On entry: the total number of $\varphi $, $\theta $, $\Phi $ and $\Theta $ parameters to be estimated.
Constraint:
${\mathbf{npar}}=p+q+P+Q$.
4: $\mathbf{c}$ – Real (Kind=nag_wp)Input/Output
On entry: if ${\mathbf{kfc}}=0$, c must contain the expected value, $c$, of the differenced series.
If ${\mathbf{kfc}}=1$, c must contain an initial estimate of $c$.
Therefore, if c and kfc are both zero on entry, there is no constant correction.
If ${\mathbf{kfc}}=1$, c contains the latest estimate of $c$.
5: $\mathbf{kfc}$ – IntegerInput
On entry: must be set to $1$ if the constant, $c$, is to be estimated and $0$ if it is to be held fixed at its initial value.
Constraint:
${\mathbf{kfc}}=0$ or $1$.
6: $\mathbf{x}\left({\mathbf{nx}}\right)$ – Real (Kind=nag_wp) arrayInput
On entry: the $n$ values of the original undifferenced time series.
7: $\mathbf{nx}$ – IntegerInput
On entry: $n$, the length of the original undifferenced time series.
8: $\mathbf{s}$ – Real (Kind=nag_wp)Output
On exit: the residual sum of squares after the latest series of parameter estimates has been incorporated into the model. If the routine exits with a faulty input parameter, s contains zero.
9: $\mathbf{ndf}$ – IntegerOutput
On exit: the number of degrees of freedom associated with s, ${\mathbf{ndf}}=n-d-D\times s-p-q-P-Q-{\mathbf{kfc}}$.
10: $\mathbf{sd}\left({\mathbf{nppc}}\right)$ – Real (Kind=nag_wp) arrayOutput
On exit: the standard deviations corresponding to the parameters in the model ($p$ autoregressive, $q$ moving average, $P$ seasonal autoregressive, $Q$ seasonal moving average and $c$, if estimated, in that order). If the routine exits with ifail containing a value other than $0$ or $9$, or if the required number of iterations is zero, the contents of sd will be indeterminate.
11: $\mathbf{nppc}$ – IntegerInput
On entry: the number of $\varphi $, $\theta $, $\Phi $, $\Theta $ and $c$ parameters to be estimated. ${\mathbf{nppc}}=p+q+P+Q+1$ if the constant is being estimated and ${\mathbf{nppc}}=p+q+P+Q$ if not.
12: $\mathbf{cm}({\mathbf{ldcm}},{\mathbf{nppc}})$ – Real (Kind=nag_wp) arrayOutput
On exit: the correlation coefficients associated with each pair of the nppc parameters. These are held in the first nppc rows and the first nppc columns of cm. These correlation coefficients are indeterminate if ifail contains on exit a value other than $0$ or $9$, or if the required number of iterations is zero.
13: $\mathbf{ldcm}$ – IntegerInput
On entry: the first dimension of the array cm as declared in the (sub)program from which g13aff is called.
Constraint:
${\mathbf{ldcm}}\ge {\mathbf{nppc}}$.
14: $\mathbf{st}\left({\mathbf{nx}}\right)$ – Real (Kind=nag_wp) arrayOutput
On exit: the value of the state set in its first nst elements. If the routine exits with ifail containing a value other than $0$ or $9$, the contents of st will be indeterminate.
15: $\mathbf{nst}$ – IntegerOutput
On exit: the size of the state set. ${\mathbf{nst}}=P\times s+D\times s+d+q+\mathrm{max}\phantom{\rule{0.125em}{0ex}}(p,Q\times s)$.
nst should be used subsequently in g13agfandg13ahf as the dimension of st.
16: $\mathbf{kpiv}$ – IntegerInput
On entry: must be nonzero if the progress of the optimization is to be monitored using the built-in printing facility. Otherwise kpiv must contain zero. If selected, monitoring output will be sent to the current advisory message unit (as defined by x04abf). For each iteration, the heading
G13AFZ MONITORING OUTPUT - ITERATION n
followed by the argument values, and residual sum of squares, are printed.
17: $\mathbf{nit}$ – IntegerInput
On entry: the maximum number of iterations to be performed.
On exit: the first four elements of isf contain success/failure indicators, one for each of the four types of parameter in the model (autoregressive, moving average, seasonal autoregressive, seasonal moving average), in that order.
Each indicator has the interpretation:
$\mathrm{-2}$
On entry parameters of this type have initial estimates which do not satisfy the stationarity or invertibility test conditions.
$\mathrm{-1}$
The search procedure has failed to converge because the latest set of parameter estimates of this type is invalid.
$\phantom{-}0$
No parameter of this type is in the model.
$\phantom{-}1$
Valid final estimates for parameters of this type have been obtained.
20: $\mathbf{res}\left({\mathbf{ires}}\right)$ – Real (Kind=nag_wp) arrayOutput
On exit: the first nres elements of res contain the model residuals derived from the differenced series. If the routine exits with ifail holding a value other than $0$ or $9$, these elements of res will be indeterminate. The rest of the array res is used as workspace.
21: $\mathbf{ires}$ – IntegerInput
On entry: the dimension of the array res as declared in the (sub)program from which g13aff is called.
Constraint:
${\mathbf{ires}}\ge 15\times {Q}^{\prime}+11n+13\times {\mathbf{nppc}}+8\times {P}^{\prime}+12+2\times {({Q}^{\prime}+{\mathbf{nppc}})}^{2}$, where ${P}^{\prime}=p+(P\times s)$ and ${Q}^{\prime}=q+(Q\times s)$.
22: $\mathbf{nres}$ – IntegerOutput
On exit: the number of model residuals returned in res.
23: $\mathbf{ifail}$ – IntegerInput/Output
On entry: ifail must be set to $0$, $\mathrm{-1}$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $\mathrm{-1}$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $\mathrm{-1}$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $\mathrm{-1}$ is recommended since useful values can be provided in some output arguments even when ${\mathbf{ifail}}\ne {\mathbf{0}}$ on exit. When the value $-\mathbf{1}$ or $\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).
6Error Indicators and Warnings
If on entry ${\mathbf{ifail}}=0$ or $\mathrm{-1}$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
Note: in some cases g13aff may return useful information.
${\mathbf{ifail}}=1$
On entry, ${\mathbf{kfc}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{kfc}}=0$ or $1$.
On entry, ${\mathbf{npar}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{npar}}=p+q+P+Q$.
The model is over-parameterised. The number of parameters in the model is greater than the number of terms in the differenced series, i.e., ${\mathbf{npar}}+{\mathbf{kfc}}\ge {\mathbf{nx}}-d-D\times s$.
${\mathbf{ifail}}=3$
On entry, ${\mathbf{nit}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{nit}}\ge 0$.
${\mathbf{ifail}}=4$
On entry, ${\mathbf{nx}}=\u27e8\mathit{\text{value}}\u27e9$ and minimum required size for the state set $\text{array}=\u27e8\mathit{\text{value}}\u27e9$ (the minimum size required is returned in nst). This occurs only for very unusual models with long seasonal periods or large numbers of parameters. First check that the orders vector mr has been set up as intended. If it has, change to g13aef with st dimensioned at least nst.
${\mathbf{ifail}}=5$
On entry, ${\mathbf{ires}}=\u27e8\mathit{\text{value}}\u27e9$ and the minimum size $\text{required}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{ires}}\ge 15\times {Q}^{\prime}+11n+13\times {\mathbf{nppc}}+8\times {P}^{\prime}+12+2\times {({Q}^{\prime}+{\mathbf{nppc}})}^{2}$, where ${P}^{\prime}=p+(P\times s)$ and ${Q}^{\prime}=q+(Q\times s)$.
${\mathbf{ifail}}=6$
On entry, ${\mathbf{ldcm}}=\u27e8\mathit{\text{value}}\u27e9$ and ${\mathbf{nppc}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{ldcm}}\ge {\mathbf{nppc}}$.
${\mathbf{ifail}}=7$
A failure in the search procedure has occurred. This may be due to a badly conditioned sum of squares function, or the default convergence criterion may be too strict. Use g13aef with a less strict convergence criterion. Some output arguments may contain meaningful values.
${\mathbf{ifail}}=8$
The inversion of the Hessian matrix in the calculation of the covariance matrix of the parameter estimates has failed. Some output arguments may contain meaningful values.
${\mathbf{ifail}}=9$
Failure whilst calculating backforecasts. Some output arguments may contain meaningful values.
${\mathbf{ifail}}=10$
Satisfactory parameter estimates could not be obtained for all parameter types in the model. Inspect array isf for futher information on the parameter type(s) in error.
${\mathbf{ifail}}=-99$
An unexpected error has been triggered by this routine. Please
contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
7Accuracy
The computations are believed to be stable.
8Parallelism and Performance
g13aff is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g13aff makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.
9Further Comments
The time taken by g13aff is approximately proportional to ${\mathbf{nx}}\times {\mathbf{itc}}\times {(q+Q\times s+{\mathbf{nppc}})}^{2}$.
10Example
This example reads $30$ observations from a time series relating to the rate of the earth's rotation about its polar axis. Differencing of order $1$ is applied, and the number of non-seasonal parameters is $3$, one autoregressive ($\varphi $) and two moving average ($\theta $). No seasonal effects are taken into account.
The constant is estimated. Up to $50$ iterations are allowed.
The initial estimates of ${\varphi}_{1}$, ${\theta}_{1}$, ${\theta}_{2}$ and $c$ are zero.
Some intermediate monitoring output from g13afz has been omitted.