# IMSL_RANDOM_ARMA

The IMSL_RANDOM_ARMA function generates a time series from a specific IMSL_ARMA model.

Note: This routine requires an IDL Analyst license. For more information, contact your Exelis VIS sales or technical support representative.

The IMSL_RANDOM_ARMA function simulates an IMSL_ARMA(p, q) process, {Wt}, for t = 1, 2, ..., n. The model is:

Let µ be the mean of the time series {Wt}. The overall constant θ0 (Const) is:

\theta_{0} = \left\{\begin{matrix}

\mu & p = 0 \\

\mu \Big( 1 - \sum_{i=1}^{p} \phi_{i} \Big) & p > 0

\end{matrix}\right.

Time series whose innovations have a nonnormal distribution may be simulated by providing the appropriate innovations in Input_Noise and start values in W_Init.

The time series is generated according to the following model:

X(i) = Const + ar(0) * X(i – Ar_Lags(0)) + ... + ar(p – 1) * X(i – Ar_Lags(p – 1)) + A(I) – ma(0) * A(i – Ma_Lags(0)) – ... – ma(q – 1) * A(i – Ma_Lags(q – 1))

where the constant is related to the mean of the series:

W

as follows:

Const = W · (1 - ar(0) - ... + (-ar(q - 1)))

and where:

X(t) = W(t), t = 0, 1, ..., n − 1

and:

W(t) = W_Init(t + p), t = –p, –p + 1, ..., −2, −1

and A is either Input_Noise (if Input_Noise is used) or Output_Noise (otherwise).

## Examples

For additional information on using IMSL_RANDOM_ARMA, see Additional Examples.

### Example 1

In this example, IMSL_RANDOM_ARMA is used to generate a time series of length five, using an IMSL_ARMA model with three autoregressive parameters and two moving average parameters. The start values are 0.1000, 0.0500, and 0.0375.

IMSL_RANDOMOPT, SET = 123457

n = 5

nparams = [3, 2]

ar = [0.5, 0.25, 0.125]

ma = [-0.5, -0.25]

r = IMSL_RANDOM_ARMA(n, nparams, ar, ma)

PM, r, FORMAT = '(5F10.3)',$

TITLE = ' IMSL_ARMA random deviates'

IMSL_ARMA random deviates

0.637 0.317 -0.366 -2.122 -1.407

## Syntax

Result = IMSL_RANDOM_ARMA(n, nparams [, /ACCEPT_REJECT] [, AR_LAGS=array] [, CONST=value] [, /DOUBLE] [, INPUT_NOISE=array] [, MA_LAGS=array] [, OUTPUT_NOISE=variable] [, /VAR_NOISE] [, W_INIT=array])

Result = IMSL_RANDOM_ARMA(n, nparams, ar [, /ACCEPT_REJECT] [, AR_LAGS=array] [, CONST=value] [, /DOUBLE] [, INPUT_NOISE=array] [, MA_LAGS=array] [, OUTPUT_NOISE=variable] [, /VAR_NOISE] [, W_INIT=array])

Result = IMSL_RANDOM_ARMA(n, nparams, ma [, /ACCEPT_REJECT] [, AR_LAGS=array] [, CONST=value] [, /DOUBLE] [, INPUT_NOISE=array] [, MA_LAGS=array] [, OUTPUT_NOISE=variable] [, /VAR_NOISE] [, W_INIT=array])

Result = IMSL_RANDOM_ARMA(n, nparams, ar, ma [, /ACCEPT_REJECT] [, AR_LAGS=array] [, CONST=value] [, /DOUBLE] [, INPUT_NOISE=array] [, MA_LAGS=array] [, OUTPUT_NOISE=variable] [, /VAR_NOISE] [, W_INIT=array])

## Return Value

One-dimensional array of length n containing the generated time series.

## Arguments

### n

Number of observations to be generated. Parameter n must be greater than or equal to one.

### nparams

One-dimensional array containing the parameters p and q consecutively. nparams(0) = p, where p is the number of autoregressive parameters. Parameter p must be greater than or equal to zero. nparams(1) = q, where q is the number of moving average parameters. Parameter q must be greater than or equal to zero.

### ar

One-dimensional array of length p containing the autoregressive parameters.

### ma

One-dimensional array of length q containing the moving average parameters.

## Keywords

### ACCEPT_REJECT

If present and nonzero, the random noises will be generated from a normal distribution using an acceptance/rejection method. If keyword ACCEPT_REJECT is not used, the random noises will be generated using an inverse normal CDF method. This argument will be ignored if keyword INPUT_NOISE is used.

### AR_LAGS

One-dimensional array of length p containing the order of the nonzero autoregressive parameters. Default: Ar_Lags = [1, 2, ..., p]

### CONST

Overall constant. See the Discussion section. Default: Const = 0

### DOUBLE

If present and nonzero, double precision is used.

### INPUT_NOISE

One-dimensional array of length n + max (Ar_Lags(i)) containing the random noises. Keywords INPUT_NOISE and VAR_NOISE can not be used together. Keywords INPUT_NOISE and OUTPUT_NOISE cannot be used together.

### MA_LAGS

One-dimensional array of length q containing the order of the nonzero moving average parameters. Default: MA_LAGS = [1, 2, ..., q]

### OUTPUT_NOISE

Named variable into which a one-dimensional array of length n + max (Ma_Lags(i)) containing the random noises is stored.

### VAR_NOISE

If present (and INPUT_NOISE is not used), noise at is generated from a normal distribution with mean 0 and variance VAR_NOISE. VAR_NOISE and INPUT_NOISE cannot be used together. Default: VAR_NOISE = 1.0

### W_INIT

One-dimensional array of length max (Ar_Lags(i)) containing the initial values of the time series. Default: W_Init(*) = Const/(1 – ar(0) – ar(1) – ... – ar(p − 1))

## Errors

### Warning Errors

STAT_RNARM_NEG_VAR—VAR(a) = “Var_Noise” = #, VAR(a) must be greater

than 0. The absolute value of # is used for VAR(a).

## Additional Examples

### Example 2

In this example, a time series of length 5 is generated using an IMSL_ARMA model with 4 autoregressive parameters and 2 moving average parameters. The start values are 0.1, 0.05 and 0.0375.

IMSL_RANDOMOPT, SET = 123457

n = 5

nparams = [3, 2]

ar = [0.5, 0.25, 0.125]

ma = [-0.5, -0.25]

wi = [0.1, 0.05, 0.0375]

theta0 = 1

avar = 0.1

r = IMSL_RANDOM_ARMA(n, nparams, ar, ma, /ACCEPT_REJECT, $

W_INIT = wi, CONST = theta0, VAR_NOISE = avar)

PM, r, FORMAT = '(5F10.3)', $

TITLE = ' IMSL_ARMA random deviates:'

IMSL_ARMA random deviates:

1.467 1.788 2.459 3.330 3.941

## Version History

6.4 | Introduced

## See Also