0

I have a significant interaction from the following linear mixed effects model:

library(lmer4)
library(ggplot2)
library(lmerTest)
library(effects)
library(extrafont)

mod_father_son <- lmer(AIP_s_child.z ~ AIP_s_parent.z*Q_mean.z + 
                  (1 + AIP_s_parent.z:Q_mean.z || Family_number), 
                data = data_father_son, REML = FALSE)

My data looks similar to this (Q_mean and AIP_s are z-scores):

Id_parent   Family_number   AIP_s_parent.z   Q_mean.z   Child_id   AIP_s_child.z

A1          1               -.008            -0.5       B1         .005
A1          1               -.008            -0.5       B2         .04
C1          2                .06             -.006      D1         -.007
E1          3               -.1              0.02       F1         -.06

I want to visualise it in the best way and I was thinking a line graph showing the interaction at +1, 0, -1 of Q_mean.z. My code for my current graph is:

fs <- as.data.frame(Effect(c("AIP_s_parent.z","Q_mean.z"),mod = mod_father_son))

fs <- mutate(fs, Q_mean.z = as.character(Q_mean.z))

plot_fs <- ggplot(fs, aes(AIP_s_parent.z,fit, group=Q_mean.z, linetype = Q_mean.z))+
 geom_line() + 
 labs(x = "Gender stereotypes father", y = "Gender stereotypes son", linetype = "Questionnaire score")

plot_fs + theme_classic() +
 scale_color_gradient(low = "black", high = "gray90") +
 theme(text=element_text(size=12,  family="Times New Roman"))

And the graph looks like this: enter image description here

Is this correct as the interpretation of the graph makes no sense with the output of the model? I've been told by someone that i should use predict () with ggplot however, I don't know how to do that. Additionally, I'd like only three lines on my plot (+1, 0, -1 of Q_mean.z) as five is confusing and difficult to read. If a line graph is not the best way to visualise the interaction, I am open to suggestions.

Julia M
  • 133
  • 1
  • 9
  • Your idea seem to be good. To get more help you need to share your data or at least a part of it that would make your example (reproducible)[https://stackoverflow.com/questions/5963269]. Also you should indicate the packages you use (for example for the `Effect` function in a capital E) – Gilles San Martin Mar 17 '18 at 18:55
  • Thank you. I'm afraid I cannot share the real data for ethical reasons, but that's why I added an example of what the data frame looks like. I've also added the packages I've used, thanks for reminding me! – Julia M Mar 17 '18 at 21:50

0 Answers0