2
$\begingroup$

I am new to mixed models and have been trying to teach myself how to utilize them in particular to process a repeated measures design [sample data and code presented below].

In brief, I have N=11 subjects, three manipulation groups [balanced w/ each subject participating in each], and a sleep measurement [dependent variable] taken hourly for six hours per manipulation. Ultimately, I have multiple observations per subject and per period. Sample below for visualization.

enter image description here

I believe to accurately utilize mixed models I must account for the correlation within subject across manipulation and within the periods, but I am not sure if that’s 100% correct and how to do that. Admittedly, I am also new to R which I am using to do this.

As I understand w/o taking in these correlations it would look like this:

lmer(Measurement ~ Manipulation + Hour + (1|Subject))

And taking into account these correlations, if that is what is supposed to be done, would look something like this, but not entirely sure it’s correct:

lmer(Measurement ~ Manipulation + Hour + (1|Subject) + Manipulation*Hour + Treatment*Subject + Subject*Hour + Treatment*Subject*Hour)

Any help is greatly appreciated!

$\endgroup$

1 Answer 1

2
$\begingroup$

Think of the random effects (...|random) in lme4 as another formula:

lmer(response ~ explanatory + (1|subject)) means:

  • Calculate a random intercept for subjects;

lmer(response ~ explanatory + (0 + eplanatory|subject)) means:

  • Calculate a random slope of the explanatory variable for subjects;

lmer(response ~ explanatory + (explanatory|subject)) means:

  • Calculate a random intercept and slope for subjects.

So if you think the treatment has a different effect on everyone, you might want to include a random slope for it:

lmer(Measurement ~ Manipulation + Hour + Treatment + (Treatment|Subject))

Similarly, if you think the random effect influences the effect of Hour, include it in the random effect:

lmer(Measurement ~ Manipulation + Hour + Treatment + (Hour + Treatment|Subject))

Or if you think there is an interaction beween the two:

lmer(Measurement ~ Manipulation + Hour * Treatment + (Hour * Treatment|Subject))

While technically possible for any number of slopes and interactions, you may end up with an unidentifiable model if you include higher order interactions with a limited sample size. Try to justify the random effects from the theory of your area of research and consider which might be the most important.

A quick search here revealed this question, which also concerns random slopes of interactions.

$\endgroup$

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.