# Autocorrelation and heteroskedasticity in panel data

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.

-

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

, fe robust cluster(code)

hope this helps

-
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? –  gung Mar 21 at 13:00

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

$$y_{it}=x_{it}\beta+u_{it}$$

the heteroskedasticity can be defined in various ways:

$$Eu_{it}^2=\sigma^2_{it}$$

or

$$Eu_{it}^2=\sigma^2_{i}$$

or

$$Eu_{it}^2=\sigma^2_{t}.$$

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:

$$y_i=x_i\beta+u_i,$$

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

$$Eu_iu_i'=\Omega_T$$

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

$$y_t=x_t\beta+u_t$$

you can guard for other cases of heteroskedasticity:

$$Eu_{t}u_t'=\Omega_N$$

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.

-
+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. –  Charlie Sep 12 '11 at 14:29
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