|Title||Testing for panel-level heteroskedasticity and autocorrelation|
Vince Wiggins, StataCorp
Brian Poi, StataCorp
|Date||June 2001; updated June 2013|
I see how one can correct for potential heteroskedasticity across panels using xtgls, but I am unsure of a simple way to test for it.
Since iterated GLS with only heteroskedasticity produces maximum-likelihood parameter estimates, we can easily do an LR test.
We can type
to fit the model with panel-level heteroskedasticity and save the likelihood.
We can fit the model without heteroskedasticity by typing
Now there is one trick. Normally, lrtest infers the number of constraints when we fit nested models by looking at the number of parameters estimated. For xtgls, however, the panel-level variances are estimated as nuisance parameters, and their count is NOT included in the parameters estimated. So, we will need to tell lrtest how many constraints we have implied.
The number of panels/groups is stored in e(N_g) and, in the second model, we are constraining all of these to be single value, so our number of constraints can be computed and stored in a local macro by typing
The test is then obtained by typing
Iterated GLS with autocorrelation does not produce the maximum likehood estimates, so we cannot use the likelihood-ratio test procedure, as with heteroskedasticity. However, Wooldridge (2002, 282–283) derives a simple test for autocorrelation in panel-data models. Drukker (2003) provides simulation results showing that the test has good size and power properties in reasonably sized samples.
There is a user-written program, called xtserial, written by David Drukker to perform this test in Stata. To install this user-written program, type
To use xtserial, you simply specify the dependent and independent variables:
A significant test statistic indicates the presence of serial correlation.