nag_arma_time_series (g05hac) (PDF version)
g05 Chapter Contents
g05 Chapter Introduction
NAG C Library Manual

NAG Library Function Document

nag_arma_time_series (g05hac)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_arma_time_series (g05hac) generates an autoregressive moving average (ARMA) time series with Normally distributed errors (or residuals). It initializes the series to a stationary position and sets up a reference vector enabling the function to be called repeatedly, adding terms to the previous series at each call.

2  Specification

#include <nag.h>
#include <nagg05.h>
void  nag_arma_time_series (Nag_Boolean start, Integer p, Integer q, const double phi[], const double theta[], double mean, double vara, Integer n, double w[], double ref[], NagError *fail)

3  Description

An ARMA model, denoted by ARMA p,q , is a mixture of an autoregressive process of order p  (AR) and a moving average (MA) process of order q  and can be written as
x n - μ = ϕ 1 x n-1 - μ + + ϕ p x n-p - μ + a n - θ 1 a n-1 - θ q a n-q
where x n  are the realization of the series, μ  is the mean of the series and a n  are the errors (or residuals, also often called the white noise) which are independently distributed as normal with mean zero and variance σ 2 . The arguments ϕ i  are the autoregressive arguments and the arguments θ i  are the moving average arguments.
The function sets up initial values corresponding to a stationary position using the method described by Tunnicliffe–Wilson (1979). It generates n  terms of the time series by first calculating the next term in the autoregressive series and then applying the moving-average summation and storing the result.

4  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

5  Arguments

1:     startNag_BooleanInput
On entry: start must be Nag_TRUE if a new series is to begin, if start is Nag_FALSE a previously generated series will be continued. If start is Nag_FALSE then the scalar arguments p, q, mean and vara and the contents of the array arguments, phi and theta must not be changed.
2:     pIntegerInput
On entry: the number of autoregressive coefficients supplied.
Constraint: p0 .
3:     qIntegerInput
On entry: the number of moving-average coefficients supplied.
Constraint: q0 .
4:     phi[p]const doubleInput
On entry: the autoregressive coefficients of the model, if any, phi[i-1]  must contain ϕ i , for i = 1 , 2 , , p .
5:     theta[q]const doubleInput
On entry: the moving-average coefficients of the model, if any, theta[i-1]  must contain θ i , for i = 1 , 2 , , q .
6:     meandoubleInput
On entry: the mean of the time series.
7:     varadoubleInput
On entry: the variance of the errors, σ 2 .
Constraint: vara>0.0 .
8:     nIntegerInput
On entry: the number of observations to be generated.
Constraint: n1 .
9:     w[n]doubleOutput
On exit: the realization of the time series.
10:   ref[5×maxp,q+7]doubleOutput
On exit: the reference vector and the recent history of the series.
11:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_INT_ARG_LT
On entry, n=value.
Constraint: n1.
On entry, p=value.
Constraint: p0.
On entry, q=value.
Constraint: q0.
NE_REAL_ARG_LE
On entry, vara must not be less than or equal to 0.0: vara=value .
NE_REF_VEC
The reference vector set up by the previous call of this function has become corrupt.
NE_START_P_Q
The function has been called either with start=Nag_FALSE  the first time or at least one of p or q has been changed in a subsequent call with start=Nag_FALSE .
NE_STATIONARITY
The input series does not constitute a stationary time-series model.

7  Accuracy

Not applicable.

8  Further Comments

None.

9  Example

The program below shows two calls of nag_arma_time_series (g05hac). In the first call an ARMA series is generated. In the second call terms are added to the already existing series.

9.1  Program Text

Program Text (g05hace.c)

9.2  Program Data

None.

9.3  Program Results

Program Results (g05hace.r)


nag_arma_time_series (g05hac) (PDF version)
g05 Chapter Contents
g05 Chapter Introduction
NAG C Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012