I'm working through Gelman and Hill, Data Analysis and Regression using Multilevel/Hierarchical Models (2007), using the arm
package, and trying to relate multilevel models to the econometric framework I'm more familiar with. I expected a multilevel model with a non-varying slope coefficient and a varying intercept coefficient to provide identical results to a fixed effect regression with no constant.
I expected the following R and Stata code to produce the same results. They do not - can you tell me why?
R code:
M1 <- lmer(y ~ x1 + x2 + (1 | county))
Stata code:
reg y x1 x2 i.county, noconstant
The coefficients produced by these two approaches are quite different.
The Stata code regresses y on x1, x2 and K additional indicator variables for each county. What is R doing that is different? Is there an OLS regression analog?