g13as is a diagnostic checking method suitable for use after fitting a Box–Jenkins ARMA model to a univariate time series using (G13AEF not in this release) g13af. The residual autocorrelation function is returned along with an estimate of its asymptotic standard errors and correlations. Also, g13as calculates the Box–Ljung portmanteau statistic and its significance level for testing model adequacy.

Syntax

C#
public static void g13as(
	int n,
	double[] v,
	int[] mr,
	int m,
	double[] par,
	int ishow,
	double[] r,
	double[,] rcm,
	out double chi,
	out int idf,
	out double siglev,
	out int ifail
)
Visual Basic
Public Shared Sub g13as ( _
	n As Integer, _
	v As Double(), _
	mr As Integer(), _
	m As Integer, _
	par As Double(), _
	ishow As Integer, _
	r As Double(), _
	rcm As Double(,), _
	<OutAttribute> ByRef chi As Double, _
	<OutAttribute> ByRef idf As Integer, _
	<OutAttribute> ByRef siglev As Double, _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void g13as(
	int n, 
	array<double>^ v, 
	array<int>^ mr, 
	int m, 
	array<double>^ par, 
	int ishow, 
	array<double>^ r, 
	array<double,2>^ rcm, 
	[OutAttribute] double% chi, 
	[OutAttribute] int% idf, 
	[OutAttribute] double% siglev, 
	[OutAttribute] int% ifail
)
F#
static member g13as : 
        n : int * 
        v : float[] * 
        mr : int[] * 
        m : int * 
        par : float[] * 
        ishow : int * 
        r : float[] * 
        rcm : float[,] * 
        chi : float byref * 
        idf : int byref * 
        siglev : float byref * 
        ifail : int byref -> unit 

Parameters

n
Type: System..::..Int32
On entry: n, the number of observations in the residual series.
If g13as is used following a call to (G13AEF not in this release), then n must be the value icount[1] returned by (G13AEF not in this release).
If g13as is used following a call to g13af, then n must be the value nres returned by g13af.
Constraint: n3.
v
Type: array<System..::..Double>[]()[][]
An array of size [n]
On entry: v[t-1] must contain an estimate of εt, for t=1,2,,n.
If g13as is used following a call to (G13AEF not in this release) then the actual argument v must be exr[icount[0]] as returned by (G13AEF not in this release).
If g13as is used following a call to g13af then the actual argument v must be res as returned by g13af.
Constraint: v must contain at least two distinct elements.
mr
Type: array<System..::..Int32>[]()[][]
An array of size [7]
On entry: the orders vector (p, d, q, P, D, Q, s) as supplied to (G13AEF not in this release) g13af.
Constraints:
  • p,q,P,Q,s0;
  • p+q+P+Q>0;
  • if s=0, then P=0 and Q=0.
m
Type: System..::..Int32
On entry: the value of m, the number of residual autocorrelations to be computed. See [Choice of m] for advice on the value of m.
Constraint: _npar<m<n.
par
Type: array<System..::..Double>[]()[][]
An array of size [dim1]
Note: dim1 must satisfy the constraint: _npar=mr[0]+mr[2]+mr[3]+mr[5]
On entry: the parameter estimates in the order ϕ1,ϕ2,,ϕp, θ1,θ2,,θq, Φ1,Φ2,,ΦP, Θ1,Θ2,,ΘQ only.
Constraint: the elements in par must satisfy the stationarity and invertibility conditions.
ishow
Type: System..::..Int32
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.
r
Type: array<System..::..Double>[]()[][]
An array of size [m]
On exit: an estimate of the residual autocorrelation coefficient at lag l, for l=1,2,,m. If ifail=3 on exit then all elements of r are set to zero.
rcm
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, m]
Note: dim1 must satisfy the constraint: dim1m
On exit: the estimated standard errors and correlations of the elements in the array r. The correlation between r[i-1] and r[j-1] is returned as rcm[i-1,j-1] except that if i=j then rcm[i-1,j-1] contains the standard error of r[i-1]. If on exit, ifail5, then all off-diagonal elements of rcm are set to zero and all diagonal elements are set to 1/n.
chi
Type: System..::..Double%
On exit: the value of the portmanteau statistic, Qm. If ifail=3 on exit then chi is returned as zero.
idf
Type: System..::..Int32%
On exit: the number of degrees of freedom of chi.
siglev
Type: System..::..Double%
On exit: the significance level of chi based on idf degrees of freedom. If ifail=3 on exit, siglev is returned as one.
ifail
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

Description

Consider the univariate multiplicative autoregressive-moving average model
ϕBΦBsWt-μ=θBΘBsεt (1)
where Wt, for t=1,2,,n, denotes a time series and εt, for t=1,2,,n, is a residual series assumed to be normally distributed with zero mean and variance σ2 (>0). The εt's are also assumed to be uncorrelated. Here μ is the overall mean term, s is the seasonal period and B is the backward shift operator such that BrWt=Wt-r. The polynomials in (1) are defined as follows:
ϕB=1-ϕ1B-ϕ2B2--ϕpBp
is the non-seasonal autoregressive (AR) operator;
θB=1-θ1B-θ2B2--θqBq
is the non-seasonal moving average (MA) operator;
ΦBs=1-Φ1Bs-Φ2B2s--ΦPBPs
is the seasonal AR operator; and
ΘBs=1-Θ1Bs-Θ2B2s--ΘQBQs
is the seasonal MA operator. The model (1) is assumed to be stationary, that is the zeros of ϕB and ΦBs are assumed to lie outside the unit circle. The model (1) is also assumed to be invertible, that is the zeros of θB and ΘBs are assumed to lie outside the unit circle. When both ΦBs and ΘBs are absent from the model, that is when P=Q=0, then the model is said to be non-seasonal.
The estimated residual autocorrelation coefficient at lag l, r^l, is computed as:
r^l=t=l+1nε^t-l-ε-ε^t-ε-t=1nε^t-ε-2,  l=1,2,
where ε^t denotes an estimate of the tth residual, εt, and ε-=t=1nε^t/n. A portmanteau statistic, Qm, is calculated from the formula (see Box and Ljung (1978)):
Qm=nn+2l=1mr^l2/n-l
where m denotes the number of residual autocorrelations computed. (Advice on the choice of m is given in [Choice of m].) Under the hypothesis of model adequacy, Qm has an asymptotic χ2-distribution on m-p-q-P-Q degrees of freedom. Let r^T=r^1,r^2,,r^m then the variance-covariance matrix of r^ is given by:
Varr^=Im-XXTX-1XT/n.
The construction of the matrix X is discussed in McLeod (1978). (Note that the mean, μ, and the residual variance, σ2, play no part in calculating Varr^ and therefore are not required as input to g13as.)
Note:  for additive models with fixed parameter values (i.e., fitted by g13dd) (G13DSF not in this release) should be used instead of 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

Error Indicators and Warnings

Note: g13as may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (NPAR, LDRCM) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
ifail=1
On entry,mr[0]<0,
ormr[2]<0,
ormr[3]<0,
ormr[5]<0,
ormr[6]<0,
ormr[6]=0 and either mr[3]>0 or mr[5]>0,
ormr[0]=mr[2]=mr[3]=mr[5]=0,
ormn,
orn<3,
orliw is too small,
orlwork is too small.
ifail=2
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.
ifail=3
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.
ifail=4
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 parameters are undefined.
ifail=5
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 1/n. All other output quantities will be correct.
ifail=6
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 1/n.
ifail=-9000
An error occured, see message report.
ifail=-6000
Invalid Parameters value
ifail=-4000
Invalid dimension for array value
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value

Accuracy

The computations are believed to be stable.

Parallelism and Performance

None.

Further Comments

Timing

The time taken by g13as depends upon the number of residual autocorrelations to be computed, m.

Choice of m

The number of residual autocorrelations to be computed, m should be chosen to ensure that when the ARMA model (1) is written as either an infinite order autoregressive process:
Wt-μ=j=1πjWt-j-μ+εt
or as an infinite order moving average process:
Wt-μ=j=1ψjεt-j+εt
then the two sequences π1,π2, and ψ1,ψ2, are such that πj and ψj are approximately zero for j>m. An overestimate of m is therefore preferable to an under-estimate of m. In many instances the choice m=10 will suffice. In practice, to be on the safe side, you should try setting m=20.

Approximate Standard Errors

When ifail=5 or 6 all the standard errors in rcm are set to 1/n. This is the asymptotic standard error of r^l when all the autoregressive and moving average parameters are assumed to be known rather than estimated.

Alternative Applications

g13as may be used for diagnostic checking of suitable univariate ARMA models, as described in [Description], fitted by g13be or g13dd. Great care must be taken in obtaining the input values for g13as from the output values from g13be or g13dd.

Example

This example fits an ARIMA1,1,2 model to a series of 30 observations. 10 residual autocorrelations are computed.

Example program (C#): g13ase.cs

Example program data: g13ase.d

Example program results: g13ase.r

See Also