|
NAG[g05pac] NAG[nag_rngs_arma_time_series] - Generates a realisation of a time series from an ARMA model
|
|
Calling Sequence
g05pac(mode, xmean, p, phi, q, theta, avar, var, x, igen, iseed, r, 'n'=n, 'fail'=fail)
nag_rngs_arma_time_series(. . .)
Parameters
|
mode - integer;
|
|
|
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 nag_rngs_arma_time_series (g05pac).
|
|
Set up reference vector and generate terms in the time series.
|
|
Constraint: . .
|
|
|
xmean - float;
|
|
|
On entry: the mean of the time series.
|
|
|
p - integer;
|
|
|
On entry: , the number of autoregressive coefficients supplied.
|
|
Constraint: . .
|
|
|
phi - Vector(1..dim, datatype=float[8]);
|
|
|
Note: the dimension, dim, of the array phi must be at least .
|
|
On entry: the autoregressive coefficients of the model, .
|
|
|
q - integer;
|
|
|
On entry: , the number of moving average coefficients supplied.
|
|
Constraint: . .
|
|
|
theta - Vector(1..dim, datatype=float[8]);
|
|
|
Note: the dimension, dim, of the array theta must be at least .
|
|
On entry: the moving average coefficients of the model, .
|
|
|
avar - float;
|
|
|
On entry: the variance of the normal perturbations, .
|
|
Constraint: . .
|
|
|
var - assignable;
|
|
|
Note: On exit the variable var will have a value of type float.
|
|
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.
|
|
|
x - Vector(1..dim, datatype=float[8]);
|
|
|
Note: the dimension, dim, of the array x must be at least .
|
|
On exit: contains the next observations from the time series.
|
|
|
iseed - Vector(1.. , datatype=integer[kernelopts('wordsize')/8]);
|
|
|
On entry: contains values which define the current state of the selected generator.
|
|
On exit: contains updated values defining the new state of the selected generator.
|
|
|
r - Vector(1.. , datatype=float[8]);
|
|
|
Note: the dimension, dim, of the array r must be at least .
|
|
On entry: if mode is set to , the reference vector from the previous call to nag_rngs_arma_time_series (g05pac).
|
|
On exit: the reference vector.
|
|
|
'n'=n - integer; (optional)
|
|
|
Default value: the second dimension of the array x.
|
|
On entry: , the number of observations to be generated.
|
|
Constraint: . .
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
nag_rngs_arma_time_series (g05pac) generates a realisation of a univariate time series from an autoregressive moving average (ARMA) model. The realisation may be continued or a new realisation generated at subsequent calls to nag_rngs_arma_time_series (g05pac).
|
|
Description
|
|
Let the vector , denote a time series which is assumed to follow an autoregressive moving average (ARMA) model of the form:
(1)
where , is a residual series of independent random perturbations assumed to be Normally distributed with zero mean and variance . The arguments , for , are called the autoregressive (AR) arguments, and , for , the moving average (MA) arguments. The arguments in the model are thus the values, the values, the mean and the residual variance .
nag_rngs_arma_time_series (g05pac) 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 realisation of . On a successful exit, the recent history is updated and saved in the reference vector r so that nag_rngs_arma_time_series (g05pac) may be called again to generate a realisation of etc. See the description of the argument mode in Section [Parameters] for details.
One of the initialization functions g05kbc (nag_rngs_init_repeatable) (for a repeatable sequence if computed sequentially) or g05kcc (nag_rngs_init_nonrepeatable) (for a non-repeatable sequence) must be called prior to the first call to nag_rngs_arma_time_series (g05pac).
|
|
Error Indicators and Warnings
|
|
"NE_BAD_PARAM"
On entry, argument had an illegal value.
"NE_INT"
On entry, . Constraint: .
On entry, . Constraint: .
On entry, . Constraint: .
On entry, . Constraint: .
"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 consult NAG for assistance.
"NE_REAL"
On entry, . Constraint: .
"NE_STATIONARY_AR"
phi does not define a stationary autoregressive process.
|
|
Accuracy
|
|
The errors in the initialization process should be very much smaller than the error term; see Tunnicliffe–Wilson (1979).
|
|
Further Comments
|
|
The time taken by nag_rngs_arma_time_series (g05pac) is essentially of order .
Note: g05kbc (nag_rngs_init_repeatable) and g05kcc (nag_rngs_init_nonrepeatable) must be used with care if this function is used as well. The reference vector, as mentioned before, contains a copy of the recent history of the series. This will not be altered properly by calls to any of the above functions. A call to g05kbc (nag_rngs_init_repeatable) or g05kcc (nag_rngs_init_nonrepeatable) should be followed by a call to nag_rngs_arma_time_series (g05pac) with to re-initialize the time series reference vector in use. To maintain repeatability with g05kbc (nag_rngs_init_repeatable), the calls to nag_rngs_arma_time_series (g05pac) should be performed in the same order and at the same point or points in the simulation every time g05kbc (nag_rngs_init_repeatable) is used. When the generator state is saved and restored using the arguments igen and iseed, 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
|
is the observed value of the time series at time ,
|
|
is the number of autoregressive arguments, ,
|
|
is the number of moving average arguments, ,
|
|
is the mean of the time series,
|
and
|
is a series of independent random Standard Normal perturbations.
|
This is related to the form given in Section [Description] by:
|
,
|
|
,
|
|
,
|
|
,
|
|
,
|
|
.
|
|
|
|
Examples
|
|
>
|
mode := 0:
xmean := 0:
p := 2:
q := 0:
avar := 1:
n := 10:
igen := 1:
phi := Vector([0.4, 0.2], datatype=float[8]):
theta := Vector([0], datatype=float[8]):
x := Vector(10, datatype=float[8]):
iseed := Vector([1762543, 9324783, 4234401, 742355], datatype=integer[kernelopts('wordsize')/8]):
r := Vector(9, datatype=float[8]):
NAG:-g05pac(mode, xmean, p, phi, q, theta, avar, var, x, igen, iseed, r, 'n' = n):
|
|
|
See Also
|
|
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. Simulation 8 301–309
g05 Chapter Introduction.
NAG Toolbox Overview.
NAG Web Site.
|
|