NAG FL Interface
g13asf (uni_arima_resid)
1
Purpose
g13asf is a diagnostic checking routine suitable for use after fitting a Box–Jenkins ARMA model to a univariate time series using
g13aef or
g13aff.
The residual autocorrelation function is returned along with an estimate of its asymptotic standard errors and correlations. Also,
g13asf calculates the Box–Ljung portmanteau statistic and its significance level for testing model adequacy.
2
Specification
Fortran Interface
Subroutine g13asf ( |
n, v, mr, m, par, npar, ishow, r, rcm, ldrcm, chi, idf, siglev, iw, liw, work, lwork, ifail) |
Integer, Intent (In) |
:: |
n, mr(7), m, npar, ishow, ldrcm, liw, lwork |
Integer, Intent (Inout) |
:: |
ifail |
Integer, Intent (Out) |
:: |
idf, iw(liw) |
Real (Kind=nag_wp), Intent (In) |
:: |
v(n), par(npar) |
Real (Kind=nag_wp), Intent (Inout) |
:: |
rcm(ldrcm,m) |
Real (Kind=nag_wp), Intent (Out) |
:: |
r(m), chi, siglev, work(lwork) |
|
C Header Interface
#include <nag.h>
void |
g13asf_ (const Integer *n, const double v[], const Integer mr[], const Integer *m, const double par[], const Integer *npar, const Integer *ishow, double r[], double rcm[], const Integer *ldrcm, double *chi, Integer *idf, double *siglev, Integer iw[], const Integer *liw, double work[], const Integer *lwork, Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
g13asf_ (const Integer &n, const double v[], const Integer mr[], const Integer &m, const double par[], const Integer &npar, const Integer &ishow, double r[], double rcm[], const Integer &ldrcm, double &chi, Integer &idf, double &siglev, Integer iw[], const Integer &liw, double work[], const Integer &lwork, Integer &ifail) |
}
|
The routine may be called by the names g13asf or nagf_tsa_uni_arima_resid.
3
Description
Consider the univariate multiplicative autoregressive-moving average model
where
, for
, denotes a time series and
, for
, is a residual series assumed to be normally distributed with zero mean and variance
(
). The
's are also assumed to be uncorrelated. Here
is the overall mean term,
is the seasonal period and
is the backward shift operator such that
. The polynomials in
(1) are defined as follows:
is the non-seasonal autoregressive (AR) operator;
is the non-seasonal moving average (MA) operator;
is the seasonal AR operator; and
is the seasonal MA operator. The model
(1) is assumed to be stationary, that is the zeros of
and
are assumed to lie outside the unit circle. The model
(1) is also assumed to be invertible, that is the zeros of
and
are assumed to lie outside the unit circle. When both
and
are absent from the model, that is when
, then the model is said to be non-seasonal.
The estimated residual autocorrelation coefficient at lag
,
, is computed as:
where
denotes an estimate of the
th residual,
, and
. A portmanteau statistic,
, is calculated from the formula (see
Box and Ljung (1978)):
where
denotes the number of residual autocorrelations computed. (Advice on the choice of
is given in
Section 9.2.) Under the hypothesis of model adequacy,
has an asymptotic
-distribution on
degrees of freedom. Let
then the variance-covariance matrix of
is given by:
The construction of the matrix
is discussed in
McLeod (1978). (Note that the mean,
, and the residual variance,
, play no part in calculating
and therefore are not required as input to
g13asf.)
Note: for additive models with fixed parameter values (i.e., fitted by
g13ddf)
g13dsf should be used instead of
g13asf.
4
References
Box G E P and Ljung G M (1978) On a measure of lack of fit in time series models Biometrika 65 297–303
McLeod A I (1978) On the distribution of the residual autocorrelations in Box–Jenkins models J. Roy. Statist. Soc. Ser. B 40 296–302
5
Arguments
-
1:
– Integer
Input
-
On entry:
, the number of observations in the residual series.
If
g13asf is used following a call to
g13aef, then
n must be the value
returned by
g13aef.
If
g13asf is used following a call to
g13aff, then
n must be the value
nres returned by
g13aff.
Constraint:
.
-
2:
– Real (Kind=nag_wp) array
Input
-
On entry:
must contain an estimate of
, for
.
If
g13asf is used following a call to
g13aef then the actual argument
v must be
as returned by
g13aef.
If
g13asf is used following a call to
g13aff then the actual argument
v must be
res as returned by
g13aff.
Constraint:
must contain at least two distinct elements.
-
3:
– Integer array
Input
-
On entry: the orders vector (
,
,
,
,
,
,
) as supplied to
g13aef or
g13aff.
Constraints:
- ;
- ;
- if , then and .
-
4:
– Integer
Input
-
On entry: the value of
, the number of residual autocorrelations to be computed. See
Section 9.2 for advice on the value of
m.
Constraint:
.
-
5:
– Real (Kind=nag_wp) array
Input
-
On entry: the parameter estimates in the order , , , only.
Constraint:
the elements in
par must satisfy the stationarity and invertibility conditions.
-
6:
– Integer
Input
-
On entry: the total number of , , and parameters, i.e., .
Constraint:
.
-
7:
– Integer
Input
-
On entry: must be nonzero if the residual autocorrelations, their standard errors and the portmanteau statistics are to be printed and zero otherwise.
These quantities are available also as output variables in
r,
rcm,
chi,
idf and
siglev.
-
8:
– Real (Kind=nag_wp) array
Output
-
On exit: an estimate of the residual autocorrelation coefficient at lag
, for
. If
on exit then all elements of
r are set to zero.
-
9:
– Real (Kind=nag_wp) array
Output
-
On exit: the estimated standard errors and correlations of the elements in the array
r. The correlation between
and
is returned as
except that if
then
contains the standard error of
. If on exit,
, then all off-diagonal elements of
rcm are set to zero and all diagonal elements are set to
.
-
10:
– Integer
Input
-
On entry: the first dimension of the array
rcm as declared in the (sub)program from which
g13asf is called.
Constraint:
.
-
11:
– Real (Kind=nag_wp)
Output
-
On exit: the value of the portmanteau statistic,
. If
on exit then
chi is returned as zero.
-
12:
– Integer
Output
-
On exit: the number of degrees of freedom of
chi.
-
13:
– Real (Kind=nag_wp)
Output
-
On exit: the significance level of
chi based on
idf degrees of freedom. If
on exit,
siglev is returned as one.
-
14:
– Integer array
Workspace
-
15:
– Integer
Input
-
On entry: the dimension of the array
iw as declared in the (sub)program from which
g13asf is called.
Constraint:
.
-
16:
– Real (Kind=nag_wp) array
Workspace
-
17:
– Integer
Input
-
On entry: the dimension of the array
work as declared in the (sub)program from which
g13asf is called.
Constraint:
.
-
18:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
or
to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value
or
is recommended. If message printing is undesirable, then the value
is recommended. Otherwise, the value
is recommended since useful values can be provided in some output arguments even when
on exit.
When the value or 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:
Note: in some cases g13asf may return useful information.
-
On entry, and .
Constraint: .
On entry, and the minimum size
Constraint: .
On entry, and the minimum size .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, and .
Constraint: and .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: and .
-
On entry, the non-seasonal autoregressive operator is nonstationary. To proceed you must supply different parameter estimates in the array
par.
On entry, the non-seasonal moving average operator is non-invertible. To proceed you must supply different parameter estimates in the array
par.
On entry, the seasonal autoregressive operator is nonstationary. To proceed you must supply different parameter estimates in the array
par.
On entry, the seasonal moving average operator is non-invertible. To proceed you must supply different parameter estimates in the array
par.
-
On entry, the elements of
v are nearly identical giving near-zero variance. In this case
chi is set to zero and
siglev to one and all the elements of
r are set to zero.
-
Excessive iterations needed to find zeros of determinental polynomials.
-
On entry, one or more of the AR operators has a factor in common with one or more of the MA operators. To proceed this common factor must be deleted from the model. In this case, the off-diagonal elements of
rcm are returned as zero and the diagonal elements are set to
. All other output quantities will be correct.
-
The matrix
rcm could not be computed because one of its diagonal elements was found to be non-positive. In this case, the off-diagonal elements of
rcm are returned as zero and the diagonal elements set to
.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See
Section 9 in the Introduction to the NAG Library FL Interface for further information.
7
Accuracy
The computations are believed to be stable.
8
Parallelism and Performance
g13asf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g13asf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
The time taken by g13asf depends upon the number of residual autocorrelations to be computed, .
The number of residual autocorrelations to be computed,
should be chosen to ensure that when the ARMA model
(1) is written as either an infinite order autoregressive process:
or as an infinite order moving average process:
then the two sequences
and
are such that
and
are approximately zero for
. An overestimate of
is therefore preferable to an under-estimate of
. In many instances the choice
will suffice. In practice, to be on the safe side, you should try setting
.
When
or
all the standard errors in
rcm are set to
. This is the asymptotic standard error of
when all the autoregressive and moving average parameters are assumed to be known rather than estimated.
g13asf may be used for diagnostic checking of suitable univariate ARMA models, as described in
Section 3, fitted by
g13bef or
g13ddf.
Great care must be taken in obtaining the input values for
g13asf from the output values from
g13bef or
g13ddf.
10
Example
This example fits an ARIMA model to a series of observations. residual autocorrelations are computed.
10.1
Program Text
10.2
Program Data
10.3
Program Results