0
$\begingroup$

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?

$\endgroup$
2
  • $\begingroup$ Please supply the full Gelman and King reference. $\endgroup$
    – Nick Cox
    Commented Jan 15, 2014 at 14:26
  • $\begingroup$ Gelman and Hill, is what I meant to say. $\endgroup$
    – pnj
    Commented Jan 15, 2014 at 15:23

2 Answers 2

1
$\begingroup$

The key difference is the lmer() is a random effects model and xtreg with the fe option is a fixed effects model. A random effects model forces the random constant to be independent of x1 and x2 while a fixed effects model allows for correlations.

The effects for individual counties you get with your reg command are not necessary. You can have Stata produce a fixed effects models with only the constant and the effects of x1 and x2 by typing in Stata:

xtset county
xtreg y x1 x2, fe

This fixed effects model is exactly the same as the one you estimated with reg. You can see that by running this code:

// here I import the data you linked to
import delimited C:\temp\test.csv

// fixed effects regression using xtreg
xtset county
xtreg y x1 x2, fe

// fixed effects regression using reg
reg y x1 x2 ibn.county, hascons

The coefficients and standard errors of x1 and x2 of these two models are exactly the same.

$\endgroup$
6
  • $\begingroup$ Your code produces a third set of coefficients, different from both the R and Stata code I listed above. Can you explain or link to an explanation? Here's the data I use: link $\endgroup$
    – pnj
    Commented Jan 15, 2014 at 19:03
  • $\begingroup$ I edited the answer to respond. In short, I did not give you a third set of estimates, just a more efficient way of getting the estimates of the fixed effects regression. $\endgroup$ Commented Jan 16, 2014 at 9:16
  • $\begingroup$ Ok, so I understand that xtreg, fe is omitting a county, which explains a difference so now the two Stata fragments produce the same result. But my original question is still not answered - why does the R lmer() function produce different results? How is a multilevel model with varying intercept and non-varying slope different from the fixed effect model as implemented in Stata? $\endgroup$
    – pnj
    Commented Jan 16, 2014 at 13:38
  • $\begingroup$ No, xtreg, fe does not omit a country. I explained the difference between fixed and random effects above, so I don't understand what you do not understand. $\endgroup$ Commented Jan 16, 2014 at 13:41
  • $\begingroup$ Maybe you did not realize that lmer() is a random effects model? $\endgroup$ Commented Jan 16, 2014 at 13:42
3
$\begingroup$

The key difference is that in a fixed effects model estimates each higher level unit is treated as a separate entity - in effect each estimate is a mean. In a random effects model the allowed to vary differences are assumed to come from a distribution typically a Normal one around an overall mean . If each higher level unit is based on lot of information - that is many cases the fixed and random estimates will be very similar. But if there is little information the random effects estimate will be shrunk towards the overall mean. This is known as precision-weighted estimation and is a very useful property as strength is borrowed for a particulate estimate from all estimates, and mean square error can be reduced.

This paper does the comparison algebraically and empirically, and this paper does argues the case for the usefulness of random effects model. This paper has some simulations showing effects.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.