[R-sig-ME] Visualising mixed effects model

Joshua Wiley jwiley.psych at gmail.com
Sun Apr 7 18:24:23 CEST 2013


Hi Ross,

If Subject is a factor, I do not think that it makes any sense to both
add it as a fixed effect, and have a random intercept by subject.  You
do not have a random Subject effect, you have a random intercept by
Subject.  Perhaps the former would make sense if, say, subjects were
nested within sites, but as is I doubt very much it is what you hope
it is.

The first model seems to do what you describe, which is condition
reaction estimates on days, as well as allow individual variability by
Subject.  You could extract the conditional models from the model
using ranef(m1), which would give you individual subject estimates.
If you add subject in as a fixed effect and it is a factor, every
subject will already have their own intercept, so there will be
nothing left over to be accounted for by the random (1 | Subject), and
really you could go back to a fixed effects model:

lm(Reaction ~ Days + Subject, data = sleepstudy)

Cheers,

Josh


On Sun, Apr 7, 2013 at 5:55 AM, Ross Ahmed <rossahmed at googlemail.com> wrote:
> Using the Śsleepstudyą dataset, I find this plotŠ
>
> library(ggplot2)
> ggplot(sleepstudy, aes(Days, Reaction, group=Subject, colour=Subject)) +
> geom_point() + geom_path()
>
> Šreally help me understand this modelŠ
>
> library(lme4)
> (m1 <- lmer(Reaction ~ Days + (1 | Subject), sleepstudy))
>
> However, I cannot wrap my head round how to visualise this modelŠ
>
> (m2 <- lmer(Reaction ~ Days + Subject + (1 | Subject), sleep study))
>
> Šin which ąSubjectą is specified as both a fixed effect and mixed effect.
> Any clues as to how to plot this model?
>
> Thanks
> Ross
>
>
>
>
>
>         [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://joshuawiley.com/
Senior Analyst - Elkhart Group Ltd.
http://elkhartgroup.com



More information about the R-sig-mixed-models mailing list