help for ivactest

Perform Cumby-Huizinga test for autocorrelation after IV/OLS estimation

ivactest [, q(#) [, s(#) ]

ivactest is for use after ivreg2, ivreg, regress and newey. ivactest is for use with time-series data. You must tsset your data before using ivactest; see tsset. You may apply ivactest to a single time series of a panel dataset.


ivactest performs the general specification test of serial correlation proposed by Cumby and Huizinga (1992) after OLS or instrumental variables (IV) estimation. In their words, the null hypothesis of the test is that the regression error is a moving average of known order q>=0 against the general alternative that autocorrelations of the regression error are nonzero at lags greater than q. The test is general enough to test the hypothesis that the regression error has no serial correlation (q=0) or the null hypothesis that serial correlation in the regression error exists, but dies out at a known finite lag (q>0).

The test is especially attractive because it can be used in three frequently encountered cases where alternative such as the Box-Pierce test (wntestq), Durbin's h test (regress postestimationts##durbinalt) and the Breusch-Godfrey test (regress postestimationts##bgodfrey) are not applicable. One of these cases is the presence of endogenous regressors, which renders each of these tests invalid. A second case involves the overlapping data commonly encountered in financial markets where the observation interval is shorter than the holding period, which requires the estimation of the induced moving average (MA) process. The Cumby-Huizinga test avoids estimation of the MA process by utilizing only the sample autocorrelations of the residuals and a consistent estimate of their asymptotic covariance matrix. The third case involves conditional heteroskedasticity of the regression error term, which is also handled without difficulty by the Cumby-Huizinga test.

If the prior estimation command estimated a VCE under the assumption of i.i.d. errors, the Cumby-Huizinga statistic becomes the Breusch-Godfrey statistic for the same number of autocorrelations, and will return the same result as estat bgodfrey. That special case of the test was first derived by Sargan in an unpublished working paper in 1976, cited by Cumby and Huizinga (fn. 13).

ivactest can be used after OLS regression with regress, newey, ivreg or ivreg2 of Baum, Schaffer and Stillman (2003).


q(#) specifies the lowest lag order to be tested. By default q=0. q>0 cannot be used if the previous command estimated a VCE under the assumption of i.i.d. errors.

s(#) specifies the number of lag orders to be tested. By default s=1.

The default test is a test with the null hypothesis that the residuals are nonautocorrelated versus the alternative that they exhibit AR(1). The parameters s and q may be used to test any sequence of autocorrelations. Fo > r instance, q(4) s(4) tests the null hypothesis that autocorrelations 5-8 of the residual process are jointly zero, allowing autocorrelations 1-4 to take on any value.

Saved results

ivactest saves the value of the test statistic, its p-value, and the degrees of freedom of the test. It also saves the minimum and maximum lag tested. See return list.


. use http://www.stata-press.com/data/r9/lutkepohl.dta

(Quarterly SA West German macro data, Bil DM, from Lutkepohl 1993 Table E.1)

. regress investment income

. ivactest

. regress investment income, robust

. ivactest, s(4)

. newey investment income, lag(4)

. ivactest, s(8)

. ivreg2 investment ( income= lconsumption lincome)

. ivactest, s(2)

. ivactest, s(4)

. ivreg2 investment ( income= lconsumption lincome), gmm

. ivactest, q(4) s(4)


Baum, C. F., Schaffer, M. E., Stillman, S., 2003. Instrumental variables and GMM: Estimation and testing. The Stata Journal, Vol. 3, No. 1, pp. 1-31. Unpublished working paper version: Boston College Department of Economics Working Paper No. 545. http://fmwww.bc.edu/ec-p/WP545.pdf

Baum, C. F., Schaffer, M. E., and Stillman, S. 2007. Enhanced routines for instrumental variables/GMM estimation and testing. Boston College Department of Economics Working Paper No. 667.

Cumby, R. E. and Huizinga, J. 1992. Testing the autocorrelation structure of disturbances in ordinary least squares and instrumental variables regressions. Econometrica, Vol. 60, No. 1, pp. 185-195.

ivactest is not an official Stata command. It is a free contribution to the research community, like a paper. Please cite it as such:

Baum, C.F., Schaffer, M.E., 2007. ivreg2: Stata module perform Cumby-Huizinga test for autocorrelation after IV/OLS estimation. http://ideas.repec.org/c/boc/bocode/s456841.html


Christopher F Baum, Boston College, USA baum@bc.edu

Mark E. Schaffer, Heriot-Watt University, UK m.e.schaffer@hw.ac.uk

Also see

Manual: [R] regression postestimation On-line: help for ivreg2, ivhettest, ivendog (if installed)