# Random effect slopes in linear mixed models

In my data, the RT (gaze) of individuals (ID) is examined as a function of a visual conditions, the factor size (small, medium, large). Base model:

print(Base <- lmer(RT ~ Size + (1|ID), data=rt), cor=F)


Random effect:

print(NoCor <- lmer(RT ~ Size + (0+Size|ID) , data=rt))
print(WithCor <- lmer(RT ~ Size + (1+Size|ID), data=rt))


Addition of ID slopes improves the Base model. My question is, how can a significant random effect (Size/ID) be interpreted when there is no relationship between the random and fixed effect, i.e., when the correlation between the random factor and the fixed facor does not improve the model [the anova(NoCr, WithCor) does not show a significant improvement]?

• you probably meant print(NoCor <- lmer(RT ~ Size + (0+Size|ID) +(1|Subject), data=rt)) as in this package example: A mixed-eﬀects model with independent random eﬀects Linear mixed model fit by REML Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) Data: sleepstudy; you should edit your post to fix your code. Commented Apr 18, 2011 at 10:48

First, you should compare models from lmer after fitting with ML (maximum likelihood) since the default is REML. So something like:

fit.nc <- update(NoCor, REML=FALSE)
fit.wc <- udpate(WithCor, REML=FALSE)
anova(fit.nc, fit.wc)


It would help to see the output of the random effects variation from your fits. For example, to answer: is there a strong correlation between the intercept and slope and what are the variation sizes?

If you find that the random slope only model (NoCor) provides the best fit, then this means that the Size variable has a different effect between groups (depending on the variation). But the no intercept implies that the mean response at some zero level (baseline for your factor Size) is the same across all groups.

A random slope only model is not as common unless informed by theory -- usually we assume baseline variation between groups (random intercept) and then let effects (slope) vary as well. If you don't think there's a good reason to accept the slope-only model, then you may want to keep the random intercept & slope model since it may conform better to theory.

In this case it would not be expected to find substantive differences between the 'NoCor' model and the 'WithCor' model that you have specified. This is because 'Size' is a factor, not a numeric covariate, and what changes between the two models is that instead of the random effects being referenced to the intercept (base level) the random effects are set as stand alone. You can see when you contrast them with ANOVA that there is no difference in AIC, BIC and logLik and no differences in the degrees of freedom (both models have the same number of parameters).

I've found that it might be better to create dummy variables if you want to estimate a variance component for each level of a factor, without including correlations. Something like:

rt$Size1<- ifelse(rt$Size == "small", 1, 0)
rt$Size2<- ifelse(rt$Size == "med", 1, 0)
rt$Size3<- ifelse(rt$Size == "large", 1, 0)
NoCor2 <- lmer(RT ~ Size + (0+Size1|ID) + (0+Size2|ID) + (0+Size3|ID), data=rt)


You might also want to try the slightly simpler model:

NoCorHom <- lmer(RT ~ Size + (1|ID) + (1|ID:Size), data=rt)


You can see from the model summary that this fits a single variance for the size factor, equivalent to assuming sphericity and homogeneity (just like a regular repeated measures ANOVA).

If Size was numeric then you would be looking at something like the below to compare the correlation parameter:

NoCor3 <- lmer(RT ~ Size + (1|ID) + (0+Size|ID), data=rt)
#vs
Cor <- lmer(RT ~ Size + (1+Size|ID), data=rt)