g05phf generates a realization of a univariate time series from an autoregressive moving average (ARMA) model. The realization may be continued or a new realization generated at subsequent calls to g05phf.
where ${\epsilon}_{t}$, is a residual series of independent random perturbations assumed to be Normally distributed with zero mean and variance ${\sigma}^{2}$. The parameters $\left\{{\varphi}_{i}\right\}$, for $\mathit{i}=1,2,\dots ,p$, are called the autoregressive (AR) parameters, and $\left\{{\theta}_{j}\right\}$, for $\mathit{j}=1,2,\dots ,q$, the moving average (MA) parameters. The parameters in the model are thus the $p$$\varphi $ values, the $q$$\theta $ values, the mean $\mu $ and the residual variance ${\sigma}^{2}$.
g05phf sets up a reference vector containing initial values corresponding to a stationary position using the method described in Tunnicliffe–Wilson (1979). The routine can then return a realization of ${x}_{1},{x}_{2},\dots ,{x}_{n}$. On a successful exit, the recent history is updated and saved in the reference vector r so that g05phf may be called again to generate a realization of ${x}_{n+1},{x}_{n+2},\dots $, etc. See the description of the argument mode in Section 5 for details.
One of the initialization routines g05kff (for a repeatable sequence if computed sequentially) or g05kgf (for a non-repeatable sequence) must be called prior to the first call to g05phf.
4References
Knuth D E (1981) The Art of Computer Programming (Volume 2) (2nd Edition) Addison–Wesley
Tunnicliffe–Wilson G (1979) Some efficient computational procedures for high order ARMA models J. Statist. Comput. Simulation8 301–309
5Arguments
1: $\mathbf{mode}$ – IntegerInput
On entry: a code for selecting the operation to be performed by the routine.
${\mathbf{mode}}=0$
Set up reference vector only.
${\mathbf{mode}}=1$
Generate terms in the time series using reference vector set up in a prior call to g05phf.
${\mathbf{mode}}=2$
Set up reference vector and generate terms in the time series.
Constraint:
${\mathbf{mode}}=0$, $1$ or $2$.
2: $\mathbf{n}$ – IntegerInput
On entry: $n$, the number of observations to be generated.
Constraint:
${\mathbf{n}}\ge 0$.
3: $\mathbf{xmean}$ – Real (Kind=nag_wp)Input
On entry: the mean of the time series.
4: $\mathbf{ip}$ – IntegerInput
On entry: $p$, the number of autoregressive coefficients supplied.
Constraint:
${\mathbf{ip}}\ge 0$.
5: $\mathbf{phi}\left({\mathbf{ip}}\right)$ – Real (Kind=nag_wp) arrayInput
On entry: the autoregressive coefficients of the model, ${\varphi}_{1},{\varphi}_{2},\dots ,{\varphi}_{p}$.
6: $\mathbf{iq}$ – IntegerInput
On entry: $q$, the number of moving average coefficients supplied.
Constraint:
${\mathbf{iq}}\ge 0$.
7: $\mathbf{theta}\left({\mathbf{iq}}\right)$ – Real (Kind=nag_wp) arrayInput
On entry: the moving average coefficients of the model, ${\theta}_{1},{\theta}_{2},\dots ,{\theta}_{q}$.
8: $\mathbf{avar}$ – Real (Kind=nag_wp)Input
On entry: ${\sigma}^{2}$, the variance of the Normal perturbations.
Constraint:
${\mathbf{avar}}\ge 0.0$.
9: $\mathbf{r}\left({\mathbf{lr}}\right)$ – Real (Kind=nag_wp) arrayCommunication Array
On entry: if ${\mathbf{mode}}=1$, the reference vector from the previous call to g05phf.
On exit: the reference vector.
10: $\mathbf{lr}$ – IntegerInput
On entry: the dimension of the array r as declared in the (sub)program from which g05phf is called.
Note: the actual argument supplied must be the array state supplied to the initialization routines g05kff or g05kgf.
On entry: contains information on the selected base generator and its current state.
On exit: contains updated information on the state of the generator.
12: $\mathbf{var}$ – Real (Kind=nag_wp)Output
On exit: the proportion of the variance of a term in the series that is due to the moving-average (error) terms in the model. The smaller this is, the nearer is the model to non-stationarity.
13: $\mathbf{x}\left({\mathbf{n}}\right)$ – Real (Kind=nag_wp) arrayOutput
On exit: contains the next $n$ observations from the time series.
14: $\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 $0$ is recommended. 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:
${\mathbf{ifail}}=1$
On entry, ${\mathbf{mode}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{mode}}=0$, $1$ or $2$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{n}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{n}}\ge 0$.
${\mathbf{ifail}}=4$
On entry, ${\mathbf{ip}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{ip}}\ge 0$.
${\mathbf{ifail}}=5$
On entry, the AR parameters are outside the stationarity region.
${\mathbf{ifail}}=6$
On entry, ${\mathbf{iq}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{iq}}\ge 0$.
${\mathbf{ifail}}=8$
On entry, ${\mathbf{avar}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{avar}}\ge 0.0$.
${\mathbf{ifail}}=9$
ip or iq is not the same as when r was set up in a previous call.
Previous value of ${\mathbf{ip}}=\u27e8\mathit{\text{value}}\u27e9$ and ${\mathbf{ip}}=\u27e8\mathit{\text{value}}\u27e9$.
Previous value of ${\mathbf{iq}}=\u27e8\mathit{\text{value}}\u27e9$ and ${\mathbf{iq}}=\u27e8\mathit{\text{value}}\u27e9$.
Reference vector r has been corrupted or not initialized correctly.
${\mathbf{ifail}}=10$
On entry, lr is not large enough, ${\mathbf{lr}}=\u27e8\mathit{\text{value}}\u27e9$: minimum length required $\text{}=\u27e8\mathit{\text{value}}\u27e9$.
${\mathbf{ifail}}=11$
On entry, state vector has been corrupted or not initialized.
${\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
Any errors in the reference vector's initial values should be very much smaller than the error term; see Tunnicliffe–Wilson (1979).
8Parallelism and Performance
g05phf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
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 g05phf is essentially of order ${\left({\mathbf{ip}}\right)}^{2}$.
Note: The reference vector, r, contains a copy of the recent history of the series. If attempting to re-initialize the series by calling g05kfforg05kgf a call to g05phf with ${\mathbf{mode}}=0$ must also be made. In the repeatable case the calls to g05phf should be performed in the same order (at the same point(s) in simulation) every time g05kff is used. When the generator state is saved and restored using the argument state, the time series reference vector must be saved and restored as well.
The ARMA model for a time series can also be written as:
where ${\epsilon}_{t}$ is a series of independent random Normal perturbations with variance $1.0$. The random number generators are initialized by g05kff and then g05phf is called to initialize a reference vector and generate a sample of ten observations.