I have been working with a proprietary data set to calculate school value added using fixed effects, and I have started trying to run an equivalent model with random effects as a robustness check. I wanted to make sure that the random effects were calculated correctly, and found that they were still correlated with the other variables in the regression. I was able to reproduce this using a publicly-available data set, and want to check three things:
My guess is that I'm making a silly mistake and using the wrong command, but it's worth checking. Thank you for any help that you can provide.
- That xtreg, re followed by predict, u are the proper commands to obtain the random effects. Notably, the data set is not a panel in the traditional "unit+time" sense, as the panel variable is "school" (or "division" in the example below) and the observations are "students".
- That these commands impose the random effects assumptions rather than requiring the data to fit them.
- That I am checking the correlations between the random effects and the covariates properly.
Code:
/* Load data from web. */ webuse citytemp /* Set the data in order to use panel-data commands. */ xtset division /* Run random-effects regression. */ xtreg heatdd tempjan cooldd, re /* Extract random effects. */ predict random_effect, u /* Test correlations between random effects and covariates in the original regression. */ reg random_effect tempjan /* Coefficient on tempjan is 2.814, p < 0.001. */ reg random_effect cooldd /* Coefficient on cooldd is -0.089, p < 0.001. */
Comment