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.
The function may be called by the names: g05phc, nag_rand_times_arma or nag_rand_arma.
Let the vector , denote a time series which is assumed to follow an autoregressive moving average (ARMA) model of the form:
where , is a residual series of independent random perturbations assumed to be Normally distributed with zero mean and variance . The parameters , for , are called the autoregressive (AR) parameters, and , for , the moving average (MA) parameters. The parameters in the model are thus the values, the values, the mean and the residual variance .
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 . 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 , 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.
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
1: – Nag_ModeRNGInput
On entry: a code for selecting the operation to be performed by the function.
Set up reference vector only.
Generate terms in the time series using reference vector set up in a prior call to g05phc.
Set up reference vector and generate terms in the time series.
, or .
2: – IntegerInput
On entry: , the number of observations to be generated.
3: – doubleInput
On entry: the mean of the time series.
4: – IntegerInput
On entry: , the number of autoregressive coefficients supplied.
5: – const doubleInput
On entry: the autoregressive coefficients of the model, .
6: – IntegerInput
On entry: , the number of moving average coefficients supplied.
7: – const doubleInput
On entry: the moving average coefficients of the model, .
8: – doubleInput
On entry: , the variance of the Normal perturbations.
9: – doubleCommunication Array
On entry: if , the reference vector from the previous call to g05phc.
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: – 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.
13: – doubleOutput
On exit: contains the next observations from the time series.
14: – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
6Error Indicators and Warnings
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument had an illegal value.
On entry, .
On entry, .
On entry, lr is not large enough, : minimum length required .
On entry, .
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.
On entry, state vector has been corrupted or not initialized.
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.
ip or iq is not the same as when r was set up in a previous call.
Previous value of and .
Previous value of and .
On entry, .
Reference vector r has been corrupted or not initialized correctly.
On entry, the AR parameters are outside the stationarity region.
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
Background information to multithreading can be found in the Multithreading documentation.
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.
The time taken by g05phc is essentially of order .
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 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:
is the observed value of the time series at time ,
is the number of autoregressive parameters, ,
is the number of moving average parameters, ,
is the mean of the time series,
is a series of independent random Standard Normal perturbations.
This is related to the form given in Section 3 by:
This example generates values for an autoregressive model given by
where is a series of independent random Normal perturbations with variance . 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.