The IMSL_LACK_OF_FIT function performs lack-of-fit test for a univariate time series or transfer function given the appropriate correlation function.

This routine requires an IDL Advanced Math and Stats license. For more information, contact your sales or technical support representative.

Routine IMSL_LACK_OF_FIT may be used to diagnose lack of fit in both IMSL_ARMA and transfer function models. The table belowshows typical arguments for these situations:

Model LAGMIN LAGMAX NPFREE
IMSL_ARMA (p, q) 1

p + q

Transfer function

0

r + s

The IMSL_LACK_OF_FIT function performs a portmanteau lack of fit test for a time series or transfer function containing n observations given the appropriate sample correlation function:

for k = L, L + 1, …, K where L = Lagmin and K = lagmax.

The basic form of the test statistic Q is:

with L = 1 if:

is an autocorrelation function. Given that the model is adequate, Q has a chi-squared distribution with K - L + 1 – m degrees of freedom where m = npfree is the number of parameters estimated in the model. If the mean of the time series is estimated, Woodfield (1990) recommends not including this in the count of the parameters estimated in the model. Thus, for an IMSL_ARMA(p, q) model set npfree = p + q regardless of whether the mean is estimated or not. The original derivation for time series models is due to Box and Pierce (1970) with the above modified version discussed by Ljung and Box (1978). The extension of the test to transfer function models is discussed by Box and Jenkins (1976, pages 394–395).

Example


Consider the Wölfer Sunspot Data (Anderson 1971, page 660) consisting of the number of sunspots observed each year from 1749 through 1924. The data set for this example consists of the number of sunspots observed from 1770 through 1869. An IMSL_ARMA(2,1) with nonzero mean is fitted using the IMSL_ARMA. The auto-correlations of the residuals are estimated using the IMSL_AUTOCORRELATION. A portmanteau lack of fit test is computed using 10 lags with IMSL_LACK_OF_FIT.

The warning message from IMSL_ARMA in the output can be ignored. (See the example for routine IMSL_ARMA for a full explanation of the warning message.)

p	=	2
q	=	1
tc	=	0.125
lagmax		=	10
npfree		=	4
 
; Get sunspot data for 1770 through 1869, store it in x()
data	=	IMSL_STATDATA(2)
x	=	data(21:120,1)
 
; Get residuals for IMSL_ARMA(2, 1) for autocorrelation/lack
; of fit
params = IMSL_ARMA(x, p, q, /Lsq, TOL_CONVERGENCE = tc, $
  RESIDUAL = r)
 
; Get autocorrelations from residuals for lack of fit test
; NOTE:	number of observations is equal to number of residuals
corrs	=	IMSL_AUTOCORRELATION(r, lagmax)
 
; Get lack of fit test statistic and p-value
; NOTE: number of observations is equal to original number of data
result	=	IMSL_LACK_OF_FIT(N_ELEMENTS(x), corrs, npfree)
 
; Print parameter estimates, test statistic, and p_value
; NOTE:	Test Statistic Q follows a Chi-squated dist.
PRINT, 'Lack of Fit Statistic (Q) =', result(0), $
  FORMAT = '(A28, F8.3)'
PRINT, 'P-value (PVALUE) = ', result(1), FORMAT = '(A28, F8.4)'

IDL prints:

Lack of Fit Statistic (Q) = 23.89239
  P-value (PVALUE) =	0.00055

Syntax


Result = IMSL_LACK_OF_FIT(Nobs, Cf, Npfree [, /DOUBLE] [, LAGMIN=value])

Return Value


One-dimensional array of length 2 with the test statistic, Q, and its p-value, p. Under the null hypothesis, Q has an approximate chi-squared distribution with lagmax - Lagmin + 1 – npfree degrees of freedom.

Arguments


Cf

One-dimensional array containing the correlation function.

Nobs

Number of observations of the stationary time series.

Npfree

Number of free parameters in the formulation of the time series model. Npfree must be greater than or equal to zero and less than lagmax where lagmax = (N_ELEMENTS(Cf) – 1). Woodfield (1990) recommends Npfree = p + q.

Keywords


DOUBLE (optional)

If present and nonzero, double precision is used.

LAGMIN (optional)

Minimum lag of the correlation function. LAGMIN corresponds to the lower bound of summation in the lack of fit test statistic. Default: 1.

Version History


6.4

Introduced

See Also


IMSL_ARMA, IMSL_AUTOCORRELATION