I've been analysing some data using linear mixed effect modelling in R. I'm planning to make a poster with the results and I was just wondering if anyone experienced with mixed effect models could suggest which plots to use in illustrating the results of the model. I was thinking about residual plots, plot of fitted values vs original values, etc.

I know this will very much depend on my data but I was just trying to get a feel for the best way to illustrate results of linear mixed effect models. I'm using the nlme package in R.



1 Answer 1


It depends on your model, but, in my experience, even colleagues, who don't have a good understanding of mixed effects models, really like if you plot the predictions with different grouping levels:

fm2 <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1|Subject)

newdat <- expand.grid(Sex=unique(Orthodont$Sex),

p <- ggplot(Orthodont, aes(x=age, y=distance, colour=Sex)) +
  geom_point(size=3) +
  geom_line(aes(y=predict(fm2), group=Subject, size="Subjects")) +
  geom_line(data=newdat, aes(y=predict(fm2, level=0, newdata=newdat), size="Population")) +
  scale_size_manual(name="Predictions", values=c("Subjects"=0.5, "Population"=3)) +

enter image description here

  • $\begingroup$ @ Roland, thanks for your answer. My model is a linear mixed effect model containing independent and dependent variables with some covariates. $\endgroup$
    – John_dydx
    May 17, 2014 at 9:35
  • $\begingroup$ @ Roland, can I just ask if fm2 <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1|Subject) is the same as fm3 <- lme(distance ~ age*Sex, data = Orthodont, random = ~ 1|Subject) . I'm trying to use Sex as a covariate for the model. $\endgroup$
    – John_dydx
    May 17, 2014 at 12:43
  • 1
    $\begingroup$ No. age * Sex is the same as age + Sex + age:Sex, i.e., it includes the interaction. $\endgroup$
    – Roland
    May 17, 2014 at 12:49
  • 1
    $\begingroup$ Yes, of course. You'd need to remove colour=Sex. $\endgroup$
    – Roland
    May 17, 2014 at 17:23
  • 1
    $\begingroup$ Yes, but that's basic ggplot2 functionalty. Study the documentation and tutorials. You might want to use scale_colour_manual. $\endgroup$
    – Roland
    May 20, 2014 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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