I am modeling the effect of race on test scores and would like to use a mixed or nested linear model to obtain estimates of the interaction between race and the school a student attends. I have specified a model:
lmer(TEST_SCORE ~ PRIOR_TEST_SCORE + (RACE | SCHOOL))
- Race is a factor with three levels: Black, White, Hispanic
- School is a factor with 150 levels
- Test scores are numeric and continuous
The challenge is that some schools lack diversity, and not all races are present within all schools. When run as a fixed effects model I get NA's for the coefficients as I would expect, since those races do not exist within those schools. When I run as a mixed model and look at those same schools' estimates by race using
ranef, I find that estimates exist for races that don't attend that school.
Why is this happening and how is lmer estimating random effects for combinations that do not exist in the data? Is it not possible to use this model when all levels are not present in each nested group?