g05phc 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 g05phc.
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}$.
g05phc sets up a reference vector containing initial values corresponding to a stationary position using the method described in Tunnicliffe–Wilson (1979). The function 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 g05phc 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 functions g05kfc (for a repeatable sequence if computed sequentially) or g05kgc (for a non-repeatable sequence) must be called prior to the first call to g05phc.
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}$ – Nag_ModeRNGInput
On entry: a code for selecting the operation to be performed by the function.
Note: the dimension, $\mathit{dim}$, of this array is dictated by the requirements of associated functions that must have been previously called. This array MUST be the same array passed as argument state in the previous call to nag_rand_init_repeatable (g05kfc) or nag_rand_init_nonrepeatable (g05kgc).
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}$ – double *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.
On exit: contains the next $n$ observations from the time series.
14: $\mathbf{fail}$ – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
6Error Indicators and Warnings
NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
On entry, argument $\u27e8\mathit{\text{value}}\u27e9$ had an illegal value.
NE_INT
On entry, ${\mathbf{ip}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{ip}}\ge 0$.
On entry, ${\mathbf{iq}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{iq}}\ge 0$.
On entry, lr is not large enough, ${\mathbf{lr}}=\u27e8\mathit{\text{value}}\u27e9$: minimum length required $\text{}=\u27e8\mathit{\text{value}}\u27e9$.
On entry, ${\mathbf{n}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{n}}\ge 0$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_INVALID_STATE
On entry, state vector has been corrupted or not initialized.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_PREV_CALL
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$.
NE_REAL
On entry, ${\mathbf{avar}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{avar}}\ge 0.0$.
NE_REF_VEC
Reference vector r has been corrupted or not initialized correctly.
NE_STATIONARY_AR
On entry, the AR parameters are outside the stationarity region.
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
g05phc 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 function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.
9Further Comments
The time taken by g05phc 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 g05kfcorg05kgc a call to g05phc with ${\mathbf{mode}}=\mathrm{Nag\_InitializeReference}$ must also be made. In the repeatable case the calls to g05phc should be performed in the same order (at the same point(s) in simulation) every time g05kfc 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 g05kfc and then g05phc is called to initialize a reference vector and generate a sample of ten observations.