PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_tsa_uni_arima_resid (g13as)
Purpose
nag_tsa_uni_arima_resid (g13as) is a diagnostic checking function suitable for use after fitting a Box–Jenkins ARMA model to a univariate time series using
nag_tsa_uni_arima_estim (g13ae) or
nag_tsa_uni_arima_estim_easy (g13af).
The residual autocorrelation function is returned along with an estimate of its asymptotic standard errors and correlations. Also,
nag_tsa_uni_arima_resid (g13as) calculates the Box–Ljung portmanteau statistic and its significance level for testing model adequacy.
Syntax
[
r,
rcm,
chi,
idf,
siglev,
ifail] = g13as(
v,
mr,
m,
par,
ishow, 'n',
n, 'npar',
npar)
[
r,
rcm,
chi,
idf,
siglev,
ifail] = nag_tsa_uni_arima_resid(
v,
mr,
m,
par,
ishow, 'n',
n, 'npar',
npar)
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
Choice of .) 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
nag_tsa_uni_arima_resid (g13as).)
Note: for additive models with fixed parameter values (i.e., fitted by
nag_tsa_multi_varma_estimate (g13dd))
nag_tsa_multi_varma_diag (g13ds) should be used instead of
nag_tsa_uni_arima_resid (g13as).
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
Parameters
Compulsory Input Parameters
- 1:
– double array
-
must contain an estimate of
, for
.
If
nag_tsa_uni_arima_resid (g13as) is used following a call to
nag_tsa_uni_arima_estim (g13ae) then the actual argument
v must be
as returned by
nag_tsa_uni_arima_estim (g13ae).
If
nag_tsa_uni_arima_resid (g13as) is used following a call to
nag_tsa_uni_arima_estim_easy (g13af) then the actual argument
v must be
res as returned by
nag_tsa_uni_arima_estim_easy (g13af).
Constraint:
must contain at least two distinct elements.
- 2:
– int64int32nag_int array
-
Constraints:
- ;
- ;
- if , then and .
- 3:
– int64int32nag_int scalar
-
The value of
, the number of residual autocorrelations to be computed. See
Choice of for advice on the value of
m.
Constraint:
.
- 4:
– double array
-
The parameter estimates in the order , , , only.
Constraint:
the elements in
par must satisfy the stationarity and invertibility conditions.
- 5:
– int64int32nag_int scalar
-
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.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the array
v.
, the number of observations in the residual series.
If
nag_tsa_uni_arima_resid (g13as) is used following a call to
nag_tsa_uni_arima_estim (g13ae), then
n must be the value
returned by
nag_tsa_uni_arima_estim (g13ae).
If
nag_tsa_uni_arima_resid (g13as) is used following a call to
nag_tsa_uni_arima_estim_easy (g13af), then
n must be the value
nres returned by
nag_tsa_uni_arima_estim_easy (g13af).
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the dimension of the array
par.
The total number of , , and parameters, i.e., .
Constraint:
.
Output Parameters
- 1:
– double array
-
An estimate of the residual autocorrelation coefficient at lag
, for
. If
on exit then all elements of
r are set to zero.
- 2:
– double array
-
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
.
- 3:
– double scalar
-
The value of the portmanteau statistic,
. If
on exit then
chi is returned as zero.
- 4:
– int64int32nag_int scalar
-
The number of degrees of freedom of
chi.
- 5:
– double scalar
-
The significance level of
chi based on
idf degrees of freedom. If
on exit,
siglev is returned as one.
- 6:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Note: nag_tsa_uni_arima_resid (g13as) may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the function:
Cases prefixed with W are classified as warnings and
do not generate an error of type NAG:error_n. See nag_issue_warnings.
-
-
On entry, | , |
or | , |
or | , |
or | , |
or | , |
or | and either or , |
or | , |
or | , |
or | , |
or | , |
or | , |
or | , |
or | liw is too small, |
or | lwork is too small. |
-
-
On entry, the autoregressive (or moving average) parameters are extremely close to or outside the stationarity (or invertibility) region. To proceed, you must supply different parameter estimates in the array
par.
- W
-
On entry, the residuals are practically identical giving zero (or 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.
-
-
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, 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 set to
. All other output quantities will be correct.
-
-
This is an unlikely exit. At least one of the diagonal elements of
rcm was found to be either negative or zero. In this case all off-diagonal elements of
rcm are returned as zero and all diagonal elements of
rcm set to
.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
The computations are believed to be stable.
Further Comments
Timing
The time taken by nag_tsa_uni_arima_resid (g13as) depends upon the number of residual autocorrelations to be computed, .
Choice of m
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
.
Approximate Standard Errors
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.
Alternative Applications
nag_tsa_uni_arima_resid (g13as) may be used for diagnostic checking of suitable univariate ARMA models, as described in
Description, fitted by
nag_tsa_multi_inputmod_estim (g13be) or
nag_tsa_multi_varma_estimate (g13dd).
Great care must be taken in obtaining the input values for
nag_tsa_uni_arima_resid (g13as) from the output values from
nag_tsa_multi_inputmod_estim (g13be) or
nag_tsa_multi_varma_estimate (g13dd).
Example
This example fits an ARIMA model to a series of observations. residual autocorrelations are computed.
Open in the MATLAB editor:
g13as_example
function g13as_example
fprintf('g13as example results\n\n');
x = [-217 -177 -166 -136 -110 -95 -64 -37 -14 -25 ...
-51 -62 -73 -88 -113 -120 -83 -33 -19 21 ...
17 44 44 78 88 122 126 114 85 64];
n = int64(numel(x));
mr = [int64(1);1;2;0;0;0;0];
c = 0;
par = [0; 0; 0];
[par, c, s, ndf, sd, cm, st, nst, itc, isf, res, nres, ifail] = ...
g13af( ...
mr, par, c, x);
m = int64(10);
ishow = int64(1);
[r, rcm, chi, idf, siglev, ifail] = ...
g13as( ...
res, mr, m, par, ishow, 'n', nres);
g13as example results
RESIDUAL AUTOCORRELATION FUNCTION
---------------------------------
LAG K 1 2 3 4 5 6 7
R(K) 0.020 -0.040 -0.019 0.068 -0.143 -0.046 -0.205
ST.ERROR 0.007 0.125 0.128 0.150 0.168 0.168 0.178
---------------------------------------------------------
LAG K 8 9 10
R(K) -0.108 -0.001 -0.058
ST.ERROR 0.179 0.181 0.183
---------------------------------------------------------
BOX - LJUNG PORTMANTEAU STATISTIC = 3.465
SIGNIFICANCE LEVEL = 0.839
(BASED ON 7 DEGREES OF FREEDOM)
VALUE OF IFAIL PARAMETER ON EXIT FROM G13ASF = 0
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015