I know there are several questions on specifying random effects with lmer. I looked at perhaps 20 of them, and they all seemed to be basic questions or questions about nesting in 3-level structures.

I need to know how the proper syntax for a full HLM model that uses multiple level 1 variables. By "full HLM" I just mean that every level 2 equation will includes a random effect and every level 2 variable influences the coefficient for every level 1 variable.

I have used these two sources to convert HLM structures to the generic multilevel/mixed-modeling provided by lme4:

source 1 source 2, using nlme but showing same basic idea

Assume there is one level 2 variable Z and two level-1 variables A and B. Say the output is Y and the grouping variable is G.

Which of the following is the correct specification of the full HLM model:

myModel<- lmer(Y~Z*(A+B) + (A + B |G))


myModel<- lmer(Y~Z(A+B) + (A|G) + (B|G))

I have found a source that explicitly addresses this case.

According to this document from the University of Freibourgh the correct syntax is the one with a single term (A + B |G).

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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