g13asf is a diagnostic checking routine suitable for use after fitting a Box–Jenkins ARMA model to a univariate time series using
g13aeforg13aff.
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.
The routine may be called by the names g13asf or nagf_tsa_uni_arima_resid.
3Description
Consider the univariate multiplicative autoregressive-moving average model
(1)
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.
4References
Box G E P and Ljung G M (1978) On a measure of lack of fit in time series models Biometrika65 297–303
McLeod A I (1978) On the distribution of the residual autocorrelations in Box–Jenkins models J. Roy. Statist. Soc. Ser. B40 296–302
5Arguments
1: – IntegerInput
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) arrayInput
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 arrayInput
On entry: the orders vector (, , , , , , ) as supplied to g13aeforg13aff.
Constraints:
;
;
if , then and .
4: – IntegerInput
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) arrayInput
On entry: the parameter estimates in the order , , , only.
Constraint:
the elements in par must satisfy the stationarity and invertibility conditions.
6: – IntegerInput
On entry: the total number of , , and parameters, i.e., .
Constraint:
.
7: – IntegerInput
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) arrayOutput
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) arrayOutput
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: – IntegerInput
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.
On exit: the significance level of chi based on idf degrees of freedom. If on exit, siglev is returned as one.
14: – Integer arrayWorkspace
15: – IntegerInput
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) arrayWorkspace
17: – IntegerInput
On entry: the dimension of the array work as declared in the (sub)program from which g13asf is called.
Constraint:
.
18: – IntegerInput/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).
6Error 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.
7Accuracy
The computations are believed to be stable.
8Parallelism 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.
9Further Comments
9.1Timing
The time taken by g13asf depends upon the number of residual autocorrelations to be computed, .
9.2Choice 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 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 .
9.3Approximate 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.
9.4Alternative Applications
g13asf may be used for diagnostic checking of suitable univariate ARMA models, as described in Section 3, fitted by
g13beforg13ddf.
Great care must be taken in obtaining the input values for g13asf from the output values from
g13beforg13ddf.
10Example
This example fits an ARIMA model to a series of observations. residual autocorrelations are computed.