What exactly constitutes a "level" in mixed models? In most texts I have read levels seem to be synonym with random variables (student ID, classroom, school, etc). But can predictors also be levels? For example, if I'm interested in math scores, family income, and IQ, can I say these are levels nested within students?

As an example consider this data set:

df = data.frame(ID=rep(c("ID1","ID2","ID3","ID4","ID5","ID6"),each=4), scores=floor(runif(24, min=0, max=100)), age=rep(c(14,17,14,16,18,12),each=4), test=rep(c(1,2),times=12), day=rep(c("day1","day2"),each=2,times=6),school=rep(c("A","B"),each=12))

I'd read it as school as the upper level (level 1), then pupil ID nested within schools (level 2), then day nested within pupil ID? (level 3), then test nested within day (level 4). Is that correct? What about age, can that be considered a separate level as well?


1 Answer 1


They are synonymous with variables, whether they are random or fixed depends on the data and the problem. See chapter 9 of https://bookdown.org/steve_midway/DAR/random-effects.html for example. The nature of the variable determines how you model them.


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.