I have data from a design in which items are completely nested within
subjects. Subject is the only second-level factor, but I have
multiple first-level factors (IVs). Say there are 2 such independent
variables that I am interested in. What is the proper syntax to fit a
mixed-effects model with a by-subject random intercept, and by-subject
random slopes for both the 2 IVs?
I can think of at least two possibilities:
lmer(DV ~ IV1 + IV2 + (1 + IV1 + IV2 | Subject))
lmer(DV ~ IV1 + IV2 + (1 + IV1 | Subject) + (1 + IV2 | Subject))
Or maybe there is some other way to do it? Maybe the correct syntax
depends on whether the random effect of subjects on the intercept and
slopes are correlated or not? (If so, how do I proceed?)
Finally, what would be the syntax if I wanted to include a random
subject effect for the INTERACTION of IV1 and IV2?
Thanks very much,
~jason
PS: additional search terms: multi-level linear model, MLM,
hierarchical, repeated measures
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jason R. Finley
Department of Psychology
University of Illinois, Urbana-Champaign
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.