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)
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 on reaction time to vary across subjects. Note also that you could allow correlated or uncorrelated random intercepts & slopes.
A random intercept model (1|subject) would merely include random variation in mean reaction time across subjects
A correlated intercept & slope model
(color|subject) = (1+color|subject)
would have a random effect of color on reaction time for each subject (so that the effect of color on reaction time is different across subjects) and would include a correlated estimate of a per-subject intercept (ie so that mean reaction time is different per subject and that this difference could be correlated to some extent with the difference in response to each color)
A random slope model
(0+color|subject) = (-1+color|subject)
would allow for a random effect of color on reaction time (so that the effect of color on reaction time is different across subjects) but would force the mean intercept to be the same for all subjects (ie so that the mean reaction time of all subjects would be the same (after correcting for the effect of color and shape if you would include those as fixed terms))
Finally you could also fit a random slope & intercept model with uncorrelated slopes & intercepts using
(1|subject) + (0+color|subject)
as this would allow random intercepts over subjects (ie so that mean reaction time is different per subject) and allow for uncorrelated random variation in the effect of color on reaction time per subject (so that the effect of color on reaction time is different across subjects)
So I supposed a full model would be
Y ~ color*shape + (color|subject) + (shape|subject)
(with correlated random slopes and intercepts)
or
Y ~ color*shape + (1|subject) + (0+color|subject) + (0+shape|subject)
(with uncorrelated random slopes and 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.