*! version 1.1.1 06apr2018

xtqptest

xtqptest -- Bias-corrected LM-based test for panel serial correlation, see Born & Breitung (2016) and Wursten (2018)

Syntax

xtqptest
varlist
[if] [in]
[, lags(integer) order(integer) force]

Main
lags check for serial correlation up to order lags

order check for serial correlation of order order

force skips checking if residuals include the fixed effect

Description

xtqptest calculates the bias-corrected Q(P) statistic for serial correlation described in Born & Breitung (2016) for varlist of ue-residuals.

The underlying concept of the test is to regress current demeaned residuals on past demeaned and bias-corrected residuals (up to order lags) using a heteroskedasticity and autocorrelation robust estimator.
A Wald test is then performed on the estimated coefficients. xtqptest calculates the Q(p) statistic that is asymptotically equivalent to this Wald test.

The authors have verified that the test in its current form is also valid for unbalanced panels. It might be slightly oversized (rejects the null too often), but this is still a matter of debate.

If order() is specified, xtqptest calculates the LM(k) statististic instead (also described in BB(2016)). This test also works with e-residuals.
Unlike the default option, the order()-version tests for serial correlation of order order. E.g. only second order correlation, not first and/or second order correlation.

This test is based on heteroskedasticity and autocorrelation robust t-test of the predictive power of lagged (of order order) demeaned residuals on current demeaned residuals.

Options

lags The test looks for autocorrelation up to order lags. Default value is 2.

order The test looks for autocorrelation of order order.

force The test only works if the dataset contains no gaps and the residuals provided include the fixed effect. Force skips testing if the latter condition is true.

Remarks

Only valid for fixed effect models without gaps. Unbalanced panels (different starts/ends) are allowed.

You must use the ue-option when predicting the residuals. That is, this test requires the fixed effect-included residuals (ci + eit).

Any mistakes are my own.

Just like academic papers, coding software takes time and effort. As a result, please cite the Stata Journal article, Wursten (2018), when you make use of this command, just like you would cite a useful paper. A full reference can be found below.
This article contains additional information about the tests, its usage and its strengths, as well as some Monte Carlo evidence.

Examples

. sysuse xtline1.dta, clear

. xtreg calories, fe

. predict ue_residuals_1, ue

. xtqptest ue_residuals_1, lags(1)

. xtqptest ue_residuals_1, order(1)

Stored results

xtqptest stores the following in r():

Matrices

r(p) p values

r(QP) values of the Q(P) statistics

r(LM) values of the LM(k) statistics

Scalars

r(pvaluei) The p-values are also stored as scalars (often more convenient)

r(qpi) Same for the qp-statistics

r(lmi) Same for the lm-statistics

References

Testing for Serial Correlation in Fixed-Effects Panel Data Models, Benjamin Born and Jörg Breitung, Econometric Reviews 2016

Testing for serial correlation in fixed-effects panel models, Jesse Wursten, Stata Journal 2018

Author

Jesse Wursten
Faculty of Economics and Business
KU Leuven
jesse.wursten@kuleuven.be