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))
or
myModel<- lmer(Y~Z(A+B) + (A|G) + (B|G))