I have a Difference-in-Differences (DID) model that includes both year fixed effects (fe) and country random effects (re). My question is: Should I be using the "mixed" command or the "xtreg" command to include both fixed effects and random effects in the same DID equation? I have attempted both and not been successful. Below is a summary of my study design and attempts.
Study Design: 10 years of pooled cross-sectional survey data from 16 countries. Binary outcome variable. DID study design. Treatment group consists of 4 countries participating in an intervention. The remaining 12 countries never have the intervention. The interaction term pools together the 4 countries (labeled A, B, C, D here for simplicity) participating in the intervention, i.e., treat=1 if (country==A | country==B | country==C | country==D). Post=1 if year>2010. The intervention is implemented at the national level. All subject-level data are collapsed to the country-region level. Following survey instructions, I included denormalized country-year-subject probability weights, which allowed me to analyze multiple country-years together. I am using Stata v13.1 on a PC.
Test model with year fe and country fe:
reg y treat*post treat post controlsvar countryFE* yearFE* [pweight=weight], robust cluster(countryregion)
mixed y treat*post treat post controlsvar yearFE* [pweight=weight], robust cluster(countryregion) || country: R.country
xtreg y treat*post treat post controlsvar yearFE* [pweight=weight], re i(country) vce(cluster countryregion)
xtreg y treat*post treat post controlsvar yearFE*, re i(country) vce(robust)
Study Design: 10 years of pooled cross-sectional survey data from 16 countries. Binary outcome variable. DID study design. Treatment group consists of 4 countries participating in an intervention. The remaining 12 countries never have the intervention. The interaction term pools together the 4 countries (labeled A, B, C, D here for simplicity) participating in the intervention, i.e., treat=1 if (country==A | country==B | country==C | country==D). Post=1 if year>2010. The intervention is implemented at the national level. All subject-level data are collapsed to the country-region level. Following survey instructions, I included denormalized country-year-subject probability weights, which allowed me to analyze multiple country-years together. I am using Stata v13.1 on a PC.
Test model with year fe and country fe:
reg y treat*post treat post controlsvar countryFE* yearFE* [pweight=weight], robust cluster(countryregion)
- First, I use the reg command to confirm that if I include both country fixed effects and year fixed effects that the regression runs without errors.
- Next, I describe 3 attempts to use year fixed effects and country random effects. The syntax of the "reg" command does not allow for both fe and re in the same equation, so I try to use mixed and xtreg.
mixed y treat*post treat post controlsvar yearFE* [pweight=weight], robust cluster(countryregion) || country: R.country
- error: Highest level groups are not nested within countryregion. I understand this to mean, "highest level group (country) is not nested within the same cluster (countryregion) every year." This occurs because some surveys did not collect data on every country-region every year.
xtreg y treat*post treat post controlsvar yearFE* [pweight=weight], re i(country) vce(cluster countryregion)
- error: pweight not allowed with between-effects and random-effects models
- error (run the same code without pweight): panels are not nested within clusters. I think this is a similar error to what I received when using mixed. Not the solution because I need to include weights.
xtreg y treat*post treat post controlsvar yearFE*, re i(country) vce(robust)
- limitation: As a test, if I remove the pweight and clustervar, then the code will execute. Not the solution because I need to include weights and can not longer cluster my se.
Comment