NAG Library Function Document
nag_tsa_resid_corr (g13asc) is a diagnostic checking function suitable for use after fitting a Box–Jenkins ARMA model to a univariate time series using nag_tsa_multi_inp_model_estim (g13bec)
. The residual autocorrelation function is returned along with an estimate of its asymptotic standard errors and correlations. Also, nag_tsa_resid_corr (g13asc) calculates the Box–Ljung portmanteau statistic and its significance level for testing model adequacy.
||nag_tsa_resid_corr (Nag_ArimaOrder *arimav,
const double v,
const double par,
Consider the univariate multiplicative autoregressive-moving average model
, denotes a time series and
, is a residual series assumed to be Normally distributed with zero mean and variance
'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
are assumed to lie outside the unit circle. The model (1)
is also assumed to be invertible, that is the zeros of
are assumed to lie outside the unit circle. When both
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:
denotes an estimate of the
. A portmanteau statistic,
, is calculated from the formula (see Box and Ljung (1978)
denotes the number of residual autocorrelations computed. (Advice on the choice of
is given in Section 8
.) Under the hypothesis of model adequacy,
has an asymptotic
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 nag_tsa_resid_corr (g13asc).)
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
arimav – Nag_ArimaOrder *
Pointer to structure of type Nag_ArimaOrder with the following members:
- p – Integer
- d – IntegerInput
- q – IntegerInput
- bigp – IntegerInput
- bigd – IntegerInput
- bigq – IntegerInput
- s – IntegerInput
: these seven members of arimav
must specify the orders vector
, respectively, of the ARIMA model for the output noise component.
, , and refer, respectively, to the number of autoregressive , moving average , seasonal autoregressive and seasonal moving average arguments.
, and refer, respectively, to the order of non-seasonal differencing, the order of seasonal differencing and the seasonal period.
- if , then and .
n – IntegerInput
On entry: the number of observations in the residual series, .
v[n] – const doubleInput
On entry: must contain an estimate of , for .
must contain at least two distinct elements.
m – IntegerInput
: the value of
, the number of residual autocorrelations to be computed. See Section 8
for advice on the value of m
par[narma] – const doubleInput
On entry: the parameter estimates in the order , , , only.
the elements in par
must satisfy the stationarity and invertibility conditions.
narma – IntegerInput
On entry: the number of ARMA arguments, , , and arguments, i.e., .
r[m] – doubleOutput
: an estimate of the residual autocorrelation coefficient at lag
on exit then all elements of r
are set to zero.
rc – doubleOutput
: the estimated standard errors and correlations of the elements in the array r
. The correlation between
is returned as
except that if
contains the standard error of
. If on exit,
, then all off-diagonal elements of rc
are set to zero and all diagonal elements are set to
tdrc – IntegerInput
: the stride separating matrix column elements in the array rc
chi – double *Output
: the value of the portmanteau statistic,
on exit then chi
is returned as zero.
df – Integer *Output
: the number of degrees of freedom of chi
siglev – double *Output
: the significance level of chi
based on df
degrees of freedom. If
on exit then siglev
is returned as one.
fail – NagError *Input/Output
The NAG error argument (see Section 3.6
in the Essential Introduction).
6 Error Indicators and Warnings
On entry, while . These arguments must satisfy .
Dynamic memory allocation failed.
Constraints on the members of arimav
On entry, the autoregressive (or moving average) arguments are extremely close to or outside the stationarity (or invertibility) region. To proceed, you must supply different parameter estimates in the array par
This is an unlikely exit. At least one of the diagonal elements of rc
was found to be either negative or zero. In this case all off-diagonal elements of rc
are returned as zero and all diagonal elements of rc
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 rc
are returned as zero and the diagonal elements set to
. All other output quantities will be correct.
This is an unlikely exit brought about by an excessive number of iterations being needed to evaluate the zeros of the AR or MA polynomials. All output arguments are undefined.
On entry, the residuals are practically identical giving zero (or near zero) variance. In this case chi
is set to zero, siglev
to one and all the elements of r
set to zero.
On entry, , , , while .
On entry, , , .
On entry, .
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG
The computations are believed to be stable.
The time taken by nag_tsa_resid_corr (g13asc) depends upon the number of residual autocorrelations to be computed, .
8.2 Choice of
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
are such that
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
8.3 Approximate Standard Errors
all the standard errors in rc
are set to
. This is the asymptotic standard error of
when all the autoregressive and moving average arguments are assumed to be known rather than estimated.
A program to fit an ARIMA(1,1,2) model to a series of 30 observations. 10 residual autocorrelations are computed.
9.1 Program Text
Program Text (g13asce.c)
9.2 Program Data
Program Data (g13asce.d)
9.3 Program Results
Program Results (g13asce.r)