In the research, both autocorrelation and heteroskedasticity are detected in panel data analysis. I can solve them separately in stata with command "xtregar" and "robust", respectly. However, I cannot find a way to solve both problems at the same time.
If possible, please show me how to repair autocorrelation and heteroskedasticity problem for panel data in one estimaion. It will be great by using Stata, but SPSS is also fine.


A standard way of correcting for this is by using heteroskedasticity and autocorrelation consistent (HAC) standard errors. They are also known after their developers as Newey-West standard errors. They can be applied in Stata using the newey command. The Stata help file for this command is here: http://www.stata.com/help.cgi?newey

The difficulty in applying these errors is that you need to choose the number of lags that you want the procedure to consider in the autocorrelation structure. The standard autocorrelation tests usually provide good guidance, though.

This approach relies on asymptotics, so large data sets work better here.

There are alternatives, including the block bootstrap. Check out this article for a comparison of approaches to dealing with autocorrelation in panel data:

Bertrand, Marianne, Ester Duflo, and Sendhil Mullainathan. 2004. "How Much Should We Trust Differences-in-Differences Estimates?" Quarterly Journal of Economics. 119(1): 249--275. [prepub version]


The answer depends on what do you define as heteroskedasticity. For panel data model:


the heteroskedasticity can be defined in various ways:






I am not familiar with Stata, but quick check on the Internet suggests that option cluster will deal with the latter two cases, you only need to specify correct clustvar. Coincidentally for the last case this will also guard against autocorrelation of the following type:

$$u_{it}=\rho u_{i,t-1}+e_{it}.$$

To see why, rewrite the panel data in vector format:


where $y_i'=(y_{i1},...,y_{iT})$, $u_i=(u_{i1},...,u_{it})$. Then classical robust standard errors guard against


which is $T\times T$ matrix, which is the same for all $i$. It is not hard to see then that both intra-group heteroskedasticity and AR(1) autocorrelation give covariance matrix which is a special case of general $\Omega_T$.

Rewriting the model in


you can guard for other cases of heteroskedasticity:


but then it is not possible to do anything about AR(1).

If you are interested in getting efficient estimators for both of these cases by using generalised least squares, then you can have readily available feasible estimates from simple OLS regression:

$$\hat\Omega_T=\frac{1}{N}\sum_{i=1}^N\hat{u}_{i}\hat{u}_{i}'$$ $$\hat\Omega_N=\frac{1}{T}\sum_{t=1}^T\hat{u}_{t}\hat{u}_{t}'$$

I do not know about Stata, but if I remember correctly Eviews has an option to use these matrices for estimation.

If you have more complicated covariance structure, I think you will need to develop your own solution.

  • $\begingroup$ +1 @mpiktas, You're right, clustering may be a more efficient model for the heteroskedasticity and autocorrelation structure given in panel data than HAC standard errors. This approach is similar to the block bootstrap as well. They are all discussed in the Bertrand et al. reference that I give. $\endgroup$
    – Charlie
    Sep 12 '11 at 14:29

In STATA you can deal with both problems by using the options (for fixed effects)

, fe vce(cluster code)

hope this helps

  • $\begingroup$ Welcome to the site, @hussam. Would you mind expanding on this a little w/ a few sentences to explain how these options deal w/ both problems? $\endgroup$ Mar 21 '13 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.