LOFCF
Performs lack‑of‑fit test for a univariate time series or transfer function given the appropriate correlation function.
Required Arguments
NOBS — Number of observations in the stationary time series. (Input)
NOBS must be greater than or equal to two.
LAGMIN — Minimum lag of the correlation function. (Input)
LAGMIN corresponds to the lower bound of summation in the lack of fit test statistic. Generally, LAGMIN is set to one if CF is an autocorrelation function and is set to zero if CF is a cross correlation function.
LAGMAX — Maximum lag of the correlation function. (Input)
LAGMAX corresponds to the upper bound of summation in the lack of fit test statistic. LAGMAX must be greater than or equal to LAGMIN and less than NOBS.
CF — Vector of length LAGMAX + 1 containing the correlation function. (Input)
The correlation coefficient for lag k is given by CF(k + 1), k = LAGMIN, LAGMIN + 1, …, LAGMAX.
NPFREE — Number of free parameters in the formulation of the time series model. (Input)
NPFREE must be greater than or equal to zero and less than LAGMAX.
Q — Lack of fit test statistic. (Output)
PVALUEp‑value of the test statistic Q. (Output)
Under the null hypothesis, Q has an approximate chi‑squared distribution with
LAGMAX  LAGMIN + 1  NPFREE degrees of freedom.
FORTRAN 90 Interface
Generic: CALL LOFCF (NOBS, LAGMIN, LAGMAX, CF, NPFREE, Q, PVALUE)
Specific: The specific interface names are S_LOFCF and D_LOFCF.
FORTRAN 77 Interface
Single: CALL LOFCF (NOBS, LAGMIN, LAGMAX, CF, NPFREE, Q, PVALUE)
Double: The double precision name is DLOFCF.
Description
Routine LOFCF 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 and L = 0 if
is a cross‑correlation 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 ARMA(pq) 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).
Comments
Routine LOFCF may be used to diagnose lack of fit in both ARMA and transfer function models. Typical arguments for these situations are
Model
LAGMIN
LAGMAX
NPFREE
ARMA(p, q)
1
p + q
Transfer function
0
r + s
See the “Description” section for further information.
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 ARMA(2,1) with nonzero mean is fitted using routine NSLSE. The autocorrelations of the residuals are estimated using routine ACF. A portmanteau lack of fit test is computed using 10 lags with LOFCF.
The warning message from NSLSE in the output can be ignored. (See the Example for routine NSLSE for a full explanation of the warning message.)
 
USE IMSL_LIBRARIES
 
IMPLICIT NONE
INTEGER IARDEG, IMEAN, IPRINT, ISEOPT, LAGMAX, LAGMIN, LDCOV,&
LDX, MAXBC, MDX, NOBS, NP, NPAR, NPFREE, NPMA
PARAMETER (IARDEG=2, IMEAN=1, IPRINT=0, ISEOPT=0, LAGMAX=10, &
LAGMIN=1, LDX=176, MAXBC=10, MDX=2, NOBS=100, NPAR=2, &
NPFREE=4, NPMA=1, NP=NPAR+NPMA+IMEAN, LDCOV=NP)
!
INTEGER LAGAR(NPAR), LAGMA(NPMA), MAXIT, NA, NCOL, NOUT, NROW
REAL A(NOBS-IARDEG+MAXBC), ACV(LAGMAX+1), AVAR, &
CF(LAGMAX+1), CNST, COV(LDCOV,NP), PAR(NPAR), &
PMA(NPMA), PVALUE, Q, RELERR, SEAC(LAGMAX), TOLBC, &
TOLSS, W(NOBS), WMEAN, X(LDX,MDX)
!
EQUIVALENCE (W(1), X(22,2))
!
DATA LAGAR/1, 2/, LAGMA/1/
!
CALL UMACH (2, NOUT)
! Wolfer Sunspot Data for
! years 1770 through 1869
CALL GDATA (2, X, NROW, NCOL)
! USE Default Convergence parameters
! Compute preliminary parameter
! estimates for ARMA(2,1) model
CALL NSPE (W, CNST, PAR, PMA, AVAR, WMEAN=WMEAN)
! Compute least squares estimates
! for model
TOLSS = 0.125
!
CALL NSLSE (W, PAR, LAGAR, PMA, LAGMA, MAXBC, CNST, COV, &
AVAR, IMEAN=IMEAN, WMEAN=WMEAN, TOLSS=TOLSS, A=A)
! Compute autocorrelations of the
! residuals
CALL ACF (A, LAGMAX, CF)
!
CALL LOFCF (NOBS, LAGMIN, LAGMAX, CF, NPFREE, Q, PVALUE)
!
WRITE (NOUT,99998) Q
WRITE (NOUT,99999) LAGMAX - LAGMIN + 1 - NPFREE, PVALUE
!
99998 FORMAT (/4X, 'Lack of Fit statistic (Q) = ', F12.3)
 
 
99999 FORMAT (/4X, 'Degrees of freedom (LAGMAX-LAGMIN+1-NPFREE) = ', &
I8/4X, 'P-value (PVALUE) = ', F12.4)
END
Output
 
***WARNING ERROR 1 from NSLSE. Least squares estimation of the parameters
*** has failed to converge. Increase MAXBC and/or TOLBC and/or
*** TOLSS. The estimates of the parameters at the last iteration
*** may be used as new starting values.
 
Lack of Fit statistic (Q) = 14.572
 
Degrees of freedom (LAGMAX-LAGMIN+1-NPFREE) = 6
P-value (PVALUE) = 0.0239
Published date: 03/19/2020
Last modified date: 03/19/2020