0
$\begingroup$

I have an unbalanced panel data set with more than 400,000 observations over 20 years. My panel variable is a person id and my time series variable is the year. The persons are from all over Germany which means that they are from different regions. To account for possible correlations between the persons within the same regions, I would like use clustered standard errors in my fixed effects regression. The Stata code looks like this:

xtreg depvar var1 var2 ... varN if year > 1990, fe vce(cluster clustvar)

First, I used the variable "region" which is a numeric variable indicating in which region the observation (person) lives as the cluster variable (clustvar). Of course, I got the error "panels are not nested within clusters" because I forgot that people move across regions such that they appear in more than a single region. To fix this problem, I wanted to use a region-year variable which is a numeric variable indicating the year as well as the region. To visualize the variable, the follwing extract from my dataset including the variable "region-year" may help:

region year region-year
1      1991 2000
1      1992 3000
2      1991 2500
2      1992 3500
2      1993 4500

Note that this extract does not contain the person id. The values of "region-year" are chosen arbitrarily in this example. In my opinion, it is just important that all observations belonging to the same region in the same year have the same number no matter how this number looks like. Am I right? Running the regression

xtreg depvar var1 var2 ... varN if year > 1990, fe vce(cluster region-year)

also causes the error "panels are not nested within clusters". But I don't know why.

$\endgroup$
  • $\begingroup$ The clustering should not be on region-year pairs since, for example, the error for Bavaria in 2014 is presumably correlated with the error for Bavaria in 2013. $\endgroup$ – Dimitriy V. Masterov Aug 13 '14 at 22:39
3
$\begingroup$

Question 1:

In my opinion, it is just important that all observations belonging to the same region in the same year have the same number no matter how this number looks like. Am I right?

Answer: No.

Question 2. The error message.

It's very easy to think of a likely data configuration that would generate the error message. Consider the following data extract for one individual (panel)

id  region year  cluster
 1     1    2000   1 
 1     1    2001   2

Here id = 1 is observed in more than one year but stays in the same region. If so, the panel for id =1 will span two years, meaning two different "clusters". You can't escape the error.

There are apparently no natural clusters that would justify use of vce(cluster) for your problem. Moreover, there's no reason to use that option, as good alternatives are available: vce(jackknife), vce(bootstrap), and vce(robust). For most calculations, each panel is considered a cluster. See also the contributed command ivreg2 for Stata, which is available on SSC.

$\endgroup$

Your Answer

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