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

Syntax

C#
public static void g05ph(
	int mode,
	int n,
	double xmean,
	int ip,
	double[] phi,
	int iq,
	double[] theta,
	double avar,
	double[] r,
	G05..::..G05State g05state,
	out double var,
	double[] x,
	out int ifail
)
Visual Basic
Public Shared Sub g05ph ( _
	mode As Integer, _
	n As Integer, _
	xmean As Double, _
	ip As Integer, _
	phi As Double(), _
	iq As Integer, _
	theta As Double(), _
	avar As Double, _
	r As Double(), _
	g05state As G05..::..G05State, _
	<OutAttribute> ByRef var As Double, _
	x As Double(), _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void g05ph(
	int mode, 
	int n, 
	double xmean, 
	int ip, 
	array<double>^ phi, 
	int iq, 
	array<double>^ theta, 
	double avar, 
	array<double>^ r, 
	G05..::..G05State^ g05state, 
	[OutAttribute] double% var, 
	array<double>^ x, 
	[OutAttribute] int% ifail
)
F#
static member g05ph : 
        mode : int * 
        n : int * 
        xmean : float * 
        ip : int * 
        phi : float[] * 
        iq : int * 
        theta : float[] * 
        avar : float * 
        r : float[] * 
        g05state : G05..::..G05State * 
        var : float byref * 
        x : float[] * 
        ifail : int byref -> unit 

Parameters

mode
Type: System..::..Int32
On entry: a code for selecting the operation to be performed by the method.
mode=0
Set up reference vector only.
mode=1
Generate terms in the time series using reference vector set up in a prior call to g05ph.
mode=2
Set up reference vector and generate terms in the time series.
Constraint: mode=0, 1 or 2.
n
Type: System..::..Int32
On entry: n, the number of observations to be generated.
Constraint: n0.
xmean
Type: System..::..Double
On entry: the mean of the time series.
ip
Type: System..::..Int32
On entry: p, the number of autoregressive coefficients supplied.
Constraint: ip0.
phi
Type: array<System..::..Double>[]()[][]
An array of size [ip]
On entry: the autoregressive coefficients of the model, ϕ1,ϕ2,,ϕp.
iq
Type: System..::..Int32
On entry: q, the number of moving average coefficients supplied.
Constraint: iq0.
theta
Type: array<System..::..Double>[]()[][]
An array of size [iq]
On entry: the moving average coefficients of the model, θ1,θ2,,θq.
avar
Type: System..::..Double
On entry: σ2, the variance of the Normal perturbations.
Constraint: avar0.0.
r
Type: array<System..::..Double>[]()[][]
An array of size [lr]
On entry: if mode=1, the reference vector from the previous call to g05ph.
On exit: the reference vector.
g05state
Type: NagLibrary..::..G05..::..G05State
An Object of type G05.G05State.
var
Type: System..::..Double%
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
Type: array<System..::..Double>[]()[][]
An array of size [n]
On exit: contains the next n observations from the time series.
ifail
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

Description

Let the vector xt, denote a time series which is assumed to follow an autoregressive moving average (ARMA) model of the form:
xt-μ=ϕ1xt-1-μ+ϕ2xt-2-μ++ϕpxt-p-μ+εt-θ1εt-1-θ2εt-2--θqεt-q
where εt, is a residual series of independent random perturbations assumed to be Normally distributed with zero mean and variance σ2. The parameters ϕi, for i=1,2,,p, are called the autoregressive (AR) parameters, and θj, for j=1,2,,q, the moving average (MA) parameters. The parameters in the model are thus the p ϕ values, the q θ values, the mean μ and the residual variance σ2.
g05ph sets up a reference vector containing initial values corresponding to a stationary position using the method described in Tunnicliffe–Wilson (1979). The method can then return a realization of x1,x2,,xn. On a successful exit, the recent history is updated and saved in the reference vector r so that g05ph may be called again to generate a realization of xn+1,xn+2,, etc. See the description of the parameter mode in [Parameters] for details.
One of the initialization methods (G05KFF not in this release) (for a repeatable sequence if computed sequentially) or (G05KGF not in this release) (for a non-repeatable sequence) must be called prior to the first call to g05ph.

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

Error Indicators and Warnings

Errors or warnings detected by the method:
ifail=1
On entry, mode0, 1 or 2.
ifail=2
On entry, n<0.
ifail=4
On entry, ip<0.
ifail=5
phi does not define a stationary autoregressive process.
ifail=6
On entry, iq<0.
ifail=8
On entry, avar<0.0.
ifail=9
Either r has been corrupted or the value of ip or iq is not the same as when r was set up in a previous call to g05ph with mode=0 or 2.
ifail=10
On entry, lr<ip+iq+6+maxip,iq+1.
ifail=11
On entry,state vector was not initialized or has been corrupted.
ifail=-9000
An error occured, see message report.
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value

Accuracy

Any errors in the reference vector's initial values should be very much smaller than the error term; see Tunnicliffe–Wilson (1979).

Parallelism and Performance

None.

Further Comments

The time taken by g05ph is essentially of order ip2.
The ARMA model for a time series can also be written as:
xn-E=A1xn-1-E++ANAxn-NA-E+B1an++BNBan-NB+1
where
  • xn is the observed value of the time series at time n,
  • NA is the number of autoregressive parameters, Ai,
  • NB is the number of moving average parameters, Bi,
  • E is the mean of the time series,
and
  • at is a series of independent random Standard Normal perturbations.
This is related to the form given in [Description] by:
  • B12=σ2,
  • Bi+1=-θiσ=-θiB1,  i=1,2,,q,
  • NB=q+1,
  • E=μ,
  • Ai=ϕi,  i=1,2,,p,
  • NA=p.

Example

See Also