Skip to main content
1 of 5
Tom Wenseleers
  • 3.4k
  • 1
  • 32
  • 46

First I should say that if your aim was to formulate a mixed model that was exactly analogous to a repeated measures ANOVA you would also have to enforce compound symmetry, which in lme would be done as follows

library(lmerTest)    
library(nlme)
fit=lme(Y~ color*shape, random=~1|subject, correlation=corCompSymm(form=~1|id),weights=NULL,data=data)
Y ~ color*shape + 1|subject
anova(fit)
summary(fit)

(you could also use a general correlation structure to relax the assumption of compound symmetry)

Adding random slopes in lmer can sometimes improve your fit, but not always. Best is to check the Aikaike Information Criterion (AIC(fit)) and see if it is actually better than a simpler random intercept model.

Difference in interpretation would basically be that in a random intercept model, all that you add to the model is some random per subject variation in mean reaction time. If you add random slopes then this will also allow the effect of color and/or shape to vary across subjects. Note also that you could allow correlated or uncorrelated random intercepts.

A model with (color|subject) = (1+color|subject) would have a random effect of color on reaction time for each subject and would include a correlated estimate of a per-subject intercept

A model with (0+color|subject) = (-1+color|subject) would allow for a random effect of color on reaction time but would force the mean intercept to be the same for all subjects

Finally a model with terms (1|subject) + (0+color|subject) would allow uncorrelated random intercepts over subjects (ie so that mean reaction time is different per subject) and allow for random variation in the effect of color on reaction time per subject

So I supposed a full model would be Y ~ color*shape + (color|subject) + (shape|subject) (with random slopes and correlated random intercepts) or Y ~ color*shape + (1|subject) + (0+color|subject) + (0+shape|subject) (with random slopes and uncorrelated random intercepts)

In lme you could also still fit different types of correlation and variance structures as well though. Best to use AIC to compare the fit of those.

Tom Wenseleers
  • 3.4k
  • 1
  • 32
  • 46