NAG Library Routine Document
G05PHF
1 Purpose
G05PHF 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 G05PHF.
2 Specification
SUBROUTINE G05PHF ( |
MODE, N, XMEAN, IP, PHI, IQ, THETA, AVAR, R, LR, STATE, VAR, X, IFAIL) |
INTEGER |
MODE, N, IP, IQ, LR, STATE(*), IFAIL |
REAL (KIND=nag_wp) |
XMEAN, PHI(IP), THETA(IQ), AVAR, R(LR), VAR, X(N) |
|
3 Description
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
.
G05PHF sets up a reference vector containing initial values corresponding to a stationary position using the method described in
Tunnicliffe–Wilson (1979). The routine can then return a realisation of
. On a successful exit, the recent history is updated and saved in the reference vector
R so that G05PHF may be called again to generate a realisation of
, etc. See the description of the parameter
MODE in
Section 5 for details.
One of the initialization routines
G05KFF (for a repeatable sequence if computed sequentially) or
G05KGF (for a non-repeatable sequence) must be called prior to the first call to G05PHF.
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 Parameters
- 1: MODE – INTEGERInput
On entry: a code for selecting the operation to be performed by the routine.
- Set up reference vector only.
- Generate terms in the time series using reference vector set up in a prior call to G05PHF.
- Set up reference vector and generate terms in the time series.
Constraint:
, or .
- 2: N – INTEGERInput
On entry: , the number of observations to be generated.
Constraint:
.
- 3: XMEAN – REAL (KIND=nag_wp)Input
On entry: the mean of the time series.
- 4: IP – INTEGERInput
On entry: , the number of autoregressive coefficients supplied.
Constraint:
.
- 5: PHI(IP) – REAL (KIND=nag_wp) arrayInput
On entry: the autoregressive coefficients of the model, .
- 6: IQ – INTEGERInput
On entry: , the number of moving average coefficients supplied.
Constraint:
.
- 7: THETA(IQ) – REAL (KIND=nag_wp) arrayInput
On entry: the moving average coefficients of the model, .
- 8: AVAR – REAL (KIND=nag_wp)Input
On entry: , the variance of the Normal perturbations.
Constraint:
.
- 9: R(LR) – REAL (KIND=nag_wp) arrayCommunication Array
On entry: if , the reference vector from the previous call to G05PHF.
On exit: the reference vector.
- 10: LR – INTEGERInput
On entry: the dimension of the array
R as declared in the (sub)program from which G05PHF is called.
Constraint:
.
- 11: STATE() – INTEGER arrayCommunication Array
-
Note: the actual argument supplied must be the array
STATE supplied to the initialization routines
G05KFF or
G05KGF.
On entry: contains information on the selected base generator and its current state.
On exit: contains updated information on the state of the generator.
- 12: VAR – REAL (KIND=nag_wp)Output
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.
- 13: X(N) – REAL (KIND=nag_wp) arrayOutput
On exit: contains the next observations from the time series.
- 14: IFAIL – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. If you are unfamiliar with this parameter you should refer to
Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
.
When the value is used it is essential to test the value of IFAIL on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6 Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
On entry, , or .
On entry, .
On entry, .
PHI does not define a stationary autoregressive process.
On entry, .
On entry, .
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 G05PHF with
or
.
On entry, .
On entry, | STATE vector was not initialized or has been corrupted. |
7 Accuracy
Any errors in the reference vector's initial values should be very much smaller than the error term; see
Tunnicliffe–Wilson (1979).
The time taken by G05PHF is essentially of order .
Note: The reference vector,
R, contains a copy of the recent history of the series. If attempting to re-initialize the series by calling
G05KFF or
G05KGF a call to G05PHF with
must also be made. In the repeatable case the calls to G05PHF should be performed in the same order (at the same point(s) in simulation) every time
G05KFF is used. When the generator state is saved and restored using the parameter
STATE, 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 parameters, ,
- is the number of moving average parameters, ,
- is the mean of the time series,
and
- is a series of independent random Standard Normal perturbations.
This is the form used in G05PHF.
This is related to the form given in
Section 3 by:
- ,
- ,
- ,
- ,
- ,
- .
9 Example
This example generates values for an autoregressive model given by
where
is a series of independent random Normal perturbations with variance
. The random number generators are initialized by
G05KFF and then G05PHF is called to initialize a reference vector and generate a sample of ten observations.
9.1 Program Text
Program Text (g05phfe.f90)
9.2 Program Data
Program Data (g05phfe.d)
9.3 Program Results
Program Results (g05phfe.r)