help for actest

Perform Cumby-Huizinga general test for autocorrelation in time series

actest
[
varname
]
[if]
[in]
[ ,
lags(numlist)
strictexog
q0
bp
small
robust
cluster(varlist)
kernel(string)
bw(#)
psd(string)
]

actest may be used on the univariate time series specified in varname
or after regress, newey, ivreg, ivregress, ivreg2 and newey2.
actest is for use with time-series data. You must tsset your data before
using actest; see tsset. You may apply actest to a panel dataset that has been defined by tsset or
xtset.

Description

actest performs the general specification test of serial correlation in a time series proposed by Cumby and Huizinga (C-H, 1990, 1992).
It can be applied to a univariate time series or as a postestimation command after OLS or instrumental variables (IV) estimation.
The null hypothesis of the test is that the time series is a
moving average of known order q, which could be zero or a positive value. The test considers the general alternative that
autocorrelations of the time series are nonzero at lags greater than q.
The test is general enough to test the hypothesis that the time series has
no serial correlation (q=0) or the null hypothesis that serial correlation in
the time series 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 alternatives such as the Box-Pierce/Ljung-Box (B-P-L-B) 'portmanteau' or Q test (wntestq), Durbin's h test (estat durbinalt)
and the Breusch-Godfrey (B-G) test (estat bgodfrey) are not applicable.

The B-P-L-B test may be applied to the residuals of a time series regression (or indeed to any time series) to test for autocorrelation at lag orders 1...p, with the null hypothesis that all p autocorrelations are zero.
In a regression context, the maintained hypothesis is that the regressors are strictly exogenous and the time series is homoskedastic.

The B-G test, of which Durbin's h test is a special case, relaxes the assumption of strictly exogenous regressors, allowing predeterminedness or weak exogeneity in the regressors.
It may be applied to any time series by regressing that series on a constant.
Like the portmanteau test, the B-G test may be used to test for autocorrelation at lag orders 1...p, with the null hypothesis that all p autocorrelations are zero.

These tests are not appropriate in several circumstances. The presence of conditional heteroskedasticity in the time series violates the assumptions underlying the portmanteau and B-G tests.
Endogenous regressors render each of these tests invalid, preventing their use in the context of an instrumental variables regression.
A third case involves the overlapping data commonly encountered
in financial markets where the observation interval is shorter than the holding
period.

One of the major advantages of the C-H framework is that it can be used to test for autocorrelation at lag orders (q+1)...(q+s) under the null hypothesis that the series being tested is MA(q).
For instance, in the case of overlapping data, such as the three-month Treasury bill rate observed at a monthly frequency, the error process is MA(2) by construction, and cannot be i.i.d.
In applying the C-H test, we may allow for q=2 and test for autocorrelation at higher than 2nd order.
In general, the C-H test, when applied to lag order m, applies the null hypothesis that the time series is MA(q) where q=m-1.

The C-H test may also be applied to realistically test for autocorrelation at a specific lag order.
Although it was originally developed for a univariate time-series setting, it may also be applied in the fixed-T large-N panel data context.
The C-H test is then essentially the same test as the Arellano and Bond (1991) test for autocorrelation, implemented for Stata by Roodman (2009) as abar.

The options available in actest permit the user to conduct, as special cases of the C-H test, a B-P-L-B Q test, a B-G test, or an A-B test, as well as tests appropriate for non-i.i.d. time series.

actest may be used as a standalone command by specifying a varname, or it may be used as a postestimation command after several regression commands. In the latter case, actest operates on the residuals of the prior regression.

Options

lags(numlist) specifies the lag orders to be tested.
If a single value m greater than 1 is provided, tests are conducted for lag orders 1...m
for two hypotheses: that all autocorrelations in the range 1...m are zero, and that the autocorrelation at each lag order is zero, allowing for nonzero autocorrelations at lower lag orders.
If a numlist m n is given, the tests are conducted for lag orders m through n. If a numlist m m is given, the test is conducted for that lag order only.
If the option is not specified, a test for first-order autocorrelation is performed.

strictexog specifies that the regressors in the prior regression may be considered strictly exogenous, as is assumed in the portmanteau test.

q0 specifies that tests of autocorrelation at specific lag orders are to be conducted under the null hypothesis of no autocorrelation at any lag order (q=0), as is assumed in the portmanteau and B-G tests.

bp specifies that the Box-Pierce test, in its original form, is to be performed.

small specifies that the Ljung-Box test, which incorporates a small-sample correction for the original Box-Pierce test, is to be performed.

robust specifies that the time series being tested may exhibit conditional heteroskedasticity, so that a robust form of the C-H test is to be performed.

cluster(varlist) specifies that the time series being tested may exhibit both within-cluster arbitrary correlation and between-cluster heteroskedasticity, as defined by the clustering variable(s).
As in ivreg2, two-way clustering is supported.

kernel(string) specifies that the time series being tested may exhibit arbitrary autocorrelation, so that an autocorrelation-robust VCE should be computed, using the specified kernel.
This option should rarely be used, as the default for actest, the truncated kernel with bandwidth=q, is the most appropriate for the C-H test's
null hypothesis of MA(q) (Hayashi 2000, p. 408).
The choices of kernel available are those defined in ivreg2.
Note that in line with ivreg2, HAC estimates require the use of the robust option as well.

bw(#) specifies that the time series being tested may exhibit arbitrary autocorrelation, so that an autocorrelation-robust VCE should be computed, using the specified bandwidth parameter.
This option should rarely be used, as the default for actest, the truncated kernel with bandwidth=q, is the most appropriate for the C-H test
null hypothesis of MA(q) (Hayashi 2000, p. 408).
Note that in line with ivreg2, HAC estimates require the use of the robust option as well.

psd(string) specifies the method to be used to deal with a non-positive semidefinite (PSD) VCE.
Some kernels, including the default truncated kernel, are not guaranteed to produce a PSD VCE in finite samples.
The default is psd(psda), where negative eigenvalues will be replaced with their absolute values, per Stock and Watson (2008).
With the option psd(psd0), negative eigenvalues will be replaced with zeros.
Note that actest will indicate in the test output whether a test statistic uses such an adjustment.

Saved results

actest saves the minimum and maximum lag orders tested in r(minlag), r(maxlag).
The matrix r(results) contains, in each row, the results up to that lag order (in columns 3-4) and the results for that lag order (in columns 6-7).
See return list.

Examples

Comparison with B-P-L-B Q test, applied to a time series

. webuse air2

. wntestq air, lags(1)

. actest air, lags(1) bp small

. wntestq air, lags(4)

. actest air, lags(4) bp small

. wntestq air in 1/72, lags(4)

. actest air in 1/72, lags(4) bp small

. wntestq air if t>80, lags(4)

. actest air if t>80, lags(4) bp small

Comparison with B-P-L-B Q test: strictly exogenous regressors

. qui reg air time

. qui predict double airhat, residual

. wntestq airhat, lags(4)

. actest airhat, lags(4) bp small strict

Comparison with Breusch-Godfrey test: predetermined regressors

. qui reg air

. estat bgodfrey, lags(1)

. actest, lags(1)

. estat bgodfrey, lags(4)

. actest, lags(4)

. actest, lags(4) robust

. qui reg air L(1/2).air

. estat bgodfrey, lags(4)

. actest, lags(4)

. actest, lags(3 4)

. webuse lutkepohl

. qui reg investment L(1/4).income

. estat bgodfrey, lags(1/8)

. actest, lags(8)

Application in an IV context

. qui ivreg2 investment (income=L(1/2).income)

. actest, lags(3)

. actest, lags(3) robust

Comparison with Arellano-Bond abar test (reported as N(0,1) vs. actest's chi-sq(1))

. qui reg investment income

. abar, lags(2)

. di r(ar1)^2 * e(N)/e(df_r)

. di r(ar2)^2 * e(N)/e(df_r)

. actest, lags(2) q0

Application with HAC VCE

. qui ivreg2 investment income, robust kernel(bartlett) bw(5)

. actest, lags(4) q0 robust kernel(bartlett) bw(5)

Application to panel data, pooled OLS estimates, and comparison to abar test

. webuse abdata

. qui reg n w k, clu(id)

. abar, lags(2)

. di r(ar1)^2

. di r(ar2)^2

. actest, lags(2) clu(id)

Application to panel data, IV-GMM estimates

. qui ivreg2 D.n (D.w D.k = D(1/2).(w k)), noco gmm2s clu(id)

. actest, lags(3) clu(id)

References

Arellano, M., Bond, S., 1991. Some tests of specification for panel data: Monte Carlo evidence and an application to employment equations. Review of Economic Studies, 58:2, 277-297.

Baum, C. F., Schaffer, M. E., Stillman, S., 2003. Instrumental variables and GMM:
Estimation and testing. Stata Journal, 3:1, 1-31.
http://ideas.repec.org/a/tsj/stataj/v3y2003i1p1-31.html.

Baum, C. F., Schaffer, M. E., and Stillman, S. 2007. Enhanced routines for instrumental variables/GMM estimation and testing. Stata Journal, 7:4, 465-506.
http://ideas.repec.org/a/tsj/stataj/v7y2007i4p465-506.html.

Cumby, R. E. and Huizinga, J. 1990. Testing the autocorrelation structure
of disturbances in ordinary least squares and instrumental variables regressions.
NBER Technical Working Paper No. 92.

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

Hayashi, F. 2000. Econometrics. Princeton University Press.

Roodman, D. M. 2009. How to do xtabond2: An introduction to difference and system GMM in Stata. Stata Journal, 9:1, 86-136.
http://ideas.repec.org/a/tsj/stataj/v9y2009i1p86-136.html.

Citation of actest

actest 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. 2013.
actest: Stata module to perform Cumby-Huizinga general test for autocorrelation in time series.
http://ideas.repec.org/c/boc/bocode/s457668.html

Authors

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, abar (if installed)