# Interaction within*between in mixed models: slope of the within factor as random or not?

I am struggling with conceptual understanding and analytical choice in mixed models.

In a within-subject experiment (2 conditions, factor X), I want to test if the effect of the condition on the outcome response (Y) is influenced by a third variable measured at the subject level (moderator W, at between level).

Thus I coded: fit<-lmer(Y~X*W+(1|Subject), data)

Should I allow the slope of the condition (X) to varying in each of the subjects --> (1+X|Subject)?

Would not the variance of the interaction with the between-level moderator (W) be already explained (at least partially) and concealed by the inclusion of the random slope?

If I understood well, the inclusion of the random slope would take from the residual variance all the variance due to unconsidered subject-level variables, including the variance due to the moderator W.

I hope I could explain my doubts clearly... Thank you

Welcome to the site, Marco.

The random slope is necessary for multiple reasons. Among the most important is recent methodological work by Heisig & Schaeffer, which shows that for a level 1 variable involved in a cross-level interaction with a level 2 variable, that interaction is more likely to be significant if the level 1 variable is not specified as random. You might say this is a good thing for getting your paper published. But as Heisig & Schaeffer point out, the coefficient test is anti-conservative. Because we make so many decisions based on p-values (a topic for another post), we want to make sure the tests we use to determine statistical significance are rigorous. And based on their simulations, they find that the most rigorous test of a cross-level interaction in a mixed or multilevel model can only be had when the level 1 variable's slope is specified as random.

As to your other related questions, the inclusion of the random slope for X allows the association between X and Y to vary across Subjects. It doesn't explain anything else; it adds a new variance term to the model, as you noted, that you can now use Subject-level variables to explain. When you interact X with W, you are trying to explain the slope variation. It answers the following question: Is part of the reason why the association between X and Y varies between persons due to between-Subject differences on W?