1
$\begingroup$

I am a relatively inexperienced R user and is a newbie here. I would like to ask for your advice regarding how to plot a three-way interaction graph in R.

My mixed effects regression model looks like this:

model1 <- lmer(score ~ TaskType * Language * Time + VocabSize + (1|ID), data= vocabtestscore)

TaskType is binary (1 and 2) and refers to the type of second language word learning task the participants completed. Language is also categorical (the students' first or second language) and refers to the language used in the glosses of the target words (words they didn't know) in the task. The study has a factorial design, so there are 2*2 = 4 word learning task conditions. Each participant is in only one of the four conditions. Finally, VocabSize refers to participants' previous vocabulary size, as measured by a test. This is the only continuous predictor.

After task completion, each student completed two post-tests of their knowledge of the target words: immediate and delayed post-tests. Therefore, Time refers to the time of testing and is binary.

Based on the regression results, there is a significant three-way interaction between TaskType, Language, and Time. Therefore, I would like to plot a graph to illustrate the interaction.

I searched online and found that the code below might be the code I need:

emmip(model1 , Language ~ TaskType | Time, CIs=TRUE)   

And below is the graph I obtained:

https://i.stack.imgur.com/Ulxxw.jpg

Did I plot the interaction correctly? What I am not sure is whether this interaction plot takes into account the fact that my model is a mixed effects model and the fact that VocabSize is present in the model.

I would appreciate any suggestions.

$\endgroup$

1 Answer 1

1
$\begingroup$

What you show seems fine. With a 2x2x2 interaction you have 8 estimates to display. You chose to show separate plots for immediate and delayed post-test times with four estimates in each, but in principle you could instead show separate plots for language or for task type. The choice depends on what you want to emphasize visually.

Don't forget that the display makes implicit assumptions about the value of VocabSize and the value of the random effect (ID). As neither of those is involved in an interaction (or random slope) involving your 3 interacting predictors, those assumptions just affect the specific values displayed on the y-axis. Check the emmeans help pages to make sure you know what those assumptions are; they should be reported in the legend of a figure like this.

$\endgroup$
5
  • $\begingroup$ Thank you very much, @EdM I really appreciate it. Would you mind specifying where I can find the assumptions you referred to? I think these assumptions are the reasons why I doubted if my interaction plot is correct -- the values on the y-axis in the plot are different from the y values when I try inserting the values of each binary predictor (e.g., 0, 1) into the model. I just want to make sure I get the right information and report the assumptions in the legend as you suggested. $\endgroup$ Oct 15, 2022 at 15:22
  • 1
    $\begingroup$ @silverfox_33 see the emmeans help page for emmip() and, more important perhaps, for the ref_grid() function that it calls. The default for a continuous covariate in ref_grid() is cov.reduce=mean, so the estimates would be produced at the mean of your VocabSize covariate. The emmeans package only provides estimates for fixed effects, so the random-effect term is effectively set to 0. $\endgroup$
    – EdM
    Oct 15, 2022 at 15:46
  • $\begingroup$ I see. So in the interaction plot, the values on the Y-axis is calculated at the mean of the VocabSize covariate and random effects are disregarded. Thank you very much @EdM ! $\endgroup$ Oct 15, 2022 at 16:02
  • $\begingroup$ @silverfox_33 yes, that's the default implied by your code. Can't hurt to double-check. You can specify other choices to emmeans functions if you wish. It's worth studying how to use that package in some detail, as it's a very flexible and powerful system for evaluating results from many types of models. $\endgroup$
    – EdM
    Oct 15, 2022 at 19:55
  • $\begingroup$ Thank you so much @EdM ! $\endgroup$ Oct 16, 2022 at 3:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.