# When to include random slopes in linear mixed models?

I'm running a few LMMs and I am finding that I don't quite understand when to include random slopes. I'm worried that my models will be wildly inaccurate and inflate the type I error rate.

First example: I'm testing whether condition (2 levels) affects reaction time and I'm using a mixed model because 1) subjects completed numerous trials on which reaction time was measured, so I want to include random intercepts for subjects, and 2) the reaction time data are from a task that includes two trial types that are not of relevance to the hypothesis, so I want to control for that by including trial type as a fixed effect.

Condition was manipulated within subjects. This is where I start to get confused. I plan to model condition as a fixed effect, like so:

lmer(RT ~ trialtype + condition + (1|subject), data=df, REML=F)


but is it also imperative that I include random slopes for subjects by condition like so?

lmer(RT ~ trialtype + condition + (1+condition|subject), data=df, REML=F)


(Note, to test my model I will compare this to a reduced model that drops the fixed effect of condition. Same is true for the following examples.)

Second example: I'm testing whether a measure of X predicts RT within one condition, which is different measure of X. I set this up like so:

lmer(cond2_RT ~ trialtype + Xmeasure + (1|subject), data=df, REML=F)


But I'm not sure if I should be including random slopes for subjects, like so:

lmer(cond2_RT ~ trialtype + Xmeasure + (1+Xmeasure|subject), data=df, REML=F)


I've read that it's important to include random slopes when you are testing the effect of some variable in order to control the type I error rate, but in this case I'm confused because Xmeasure is a predictor, not a manipulated variable and I don't know that I expect the relation between Xmeasure and cond2_RT to vary by subject. Am I thinking about this incorrectly?

Third and final example: I also want to test whether condition interacts with Xmeasure to predict RT. Here is how I've set this up:

lmer(cond2_RT ~ trialtype + Xmeasure*condition + (1+condition|subject), data=df, REML=F)


But again, I'm not sure if I should also be modeling random subject slopes for Xmeasure and also the interaction between condition and Xmeasure. I'm worried about including too much in the model, and also about not being able to justify the inclusion of these slopes. But I don't want to leave anything out that is crucial.

Thanks in advance for any suggestions!

• Why not remove trial types that are of no relevance to your hypothesis? – David Lane Feb 6 '17 at 21:13
• It's the effect of trial type that is not relevant. All trials yield RTs that form the dependent measure. – panpsych77 Feb 6 '17 at 21:41
• I see . You could take the mean (or median) across trial types for each subject and use that as the dependent variable. You could also take an unweighted mean of the two means (or medians) for trial types if there are different numbers of trials of each trial type. You can then do a t test, – David Lane Feb 6 '17 at 22:14
• yes, but the point was to model trial type in order to reduce error. – panpsych77 Feb 6 '17 at 22:18
• If you compute the mean for each trial type and include it as a factor you have modeled trial type. The test of the main effect of group will match the t test. Try it both ways. I would be surprised if the complicated analysis were much different from a t test. It is not impossible that they are the same. – David Lane Feb 6 '17 at 23:04

If you have real doubt about whether or not random slopes would improve your model for whatever purpose you're putting it to, you don't need to decide in advance. Instead, use a generic model-selection technique, such as estimating predictive accuracy with cross-validation and selecting the most predictively accurate model. Just make sure that whatever design you want to consider is identifiable.

• Why the downvote? Is there anything wrong with this answer? – Kodiologist Sep 20 '17 at 6:58