# naginterfaces.library.rand.times_​arma¶

naginterfaces.library.rand.times_arma(mode, n, xmean, phi, theta, avar, comm, statecomm)[source]

times_arma 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 times_arma.

For full information please refer to the NAG Library document for g05ph

https://www.nag.com/numeric/nl/nagdoc_28.7/flhtml/g05/g05phf.html

Parameters
modeint

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 times_arma.

Set up reference vector and generate terms in the time series.

nint

, the number of observations to be generated.

xmeanfloat

The mean of the time series.

phifloat, array-like, shape

The autoregressive coefficients of the model, .

thetafloat, array-like, shape

The moving average coefficients of the model, .

avarfloat

, the variance of the Normal perturbations.

commdict, communication object, modified in place

Communication structure for the reference vector.

If , this argument must have been initialized by a prior call to times_arma.

statecommdict, RNG communication object, modified in place

RNG communication structure.

This argument must have been initialized by a prior call to init_repeat() or init_nonrepeat().

Returns
varfloat

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.

xNone or float, ndarray, shape

Contains the next observations from the time series.

Raises
NagValueError
(errno )

On entry, .

Constraint: , or .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, the AR parameters are outside the stationarity region.

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

Reference vector [‘r’] has been corrupted or not initialized correctly.

(errno )

or is not the same as when [‘r’] was set up in a previous call.

Previous value of and .

Previous value of and .

(errno )

On entry, [‘state’] vector has been corrupted or not initialized.

Notes

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 .

times_arma 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 times_arma may be called again to generate a realization of , etc. See the description of the argument in Parameters for details.

One of the initialization functions init_repeat() (for a repeatable sequence if computed sequentially) or init_nonrepeat() (for a non-repeatable sequence) must be called prior to the first call to times_arma.

References

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