How do random effects adjust for confounding in a model? This post explains that they do just as fixed effects do. This makes sense intuitively. However, I don't understand how the inclusion of a random effect can change the estimated effect of a treatment on the outcome.
If a random intercept is assumed to have a mean of zero, wouldn't the other coefficients in the model be unaffected (only their standard errors would change)?
To make this more concrete: I want to estimate the effect of a medical treatment on death. I believe that the medical center is a confounder (the particular hospital affects both likelihood of the subject receiving the treatment and likelihood of the subject dying). Will including hospital as a random intercept adjust the estimated coefficient for treatment even though the expected value of the random effect for hospital is 0?
Xrepresenting a group. Is that what you were imagining here as well? If so, then forlm2, we might instead run the model aslm2 <- lm(Y ~ E + as.factor(X)). – Erik Ruzek Jun 26 '20 at 18:18Xis a grouping variable. I have edited the answer to reflect this. Cheers ! – Robert Long Jun 26 '20 at 18:57n <- 10000you will find them very close to 1.. – Robert Long Jun 26 '20 at 19:11