## Jamovi and R plotting different graphs

General help and assistance with jamovi. Bug reports can be made at our issues page: https://github.com/jamovi/jamovi/issues . (If you're unsure feel free to discuss it here)

## Jamovi and R plotting different graphs

Hi,

I am trying to conduct a linear mixed effects analysis in Jamovi. Here is the code for the model that I am fitting in R.

sad.df.model13 <- lmer(response_time ~ language*target_intensity*z_AoA + task_order*language + language*target_intensity*z_PPVT
+ (1|subject) + (1|face), data = df_sad, REML = FALSE,
control= lmerControl(optimizer = "bobyqa"))

language, target_intensity and task_order are all factors with two levels. z_PPVT and z_AoA are centered continuous variables.

The interaction between language and z_AoA is significant so I plotted the interaction with interact_plot function to visualize the relationship.

interact_plot(sad.df.model13, pred = z_AoA, modx = language, interval = TRUE,
colors = "Set2", x.label = "Age of Acquisition", y.label = "Reaction Time (msecs)",
legend.main = "Language")

I did the same analysis with Jamovi and all of the model results and parameter estimates are the same.

However, for some reason, when I tried to plot the same interaction in Jamovi, the resulting graph is totally different than the one in R (even though the parameter estimate for the interaction is the same)

So I am wondering what might the underlying problem? I am attaching both graphs as well as my data.

Thanks in advance!
Attachments Jamovi.png (38.35 KiB) Viewed 2011 times SadData.omv
(83.44 KiB) Downloaded 208 times RPlot.png (27.5 KiB) Viewed 2012 times
zaslan

Posts: 1
Joined: Wed Jun 12, 2019 1:32 pm

## Re: Jamovi and R plotting different graphs

pro-tip, if you're using a module, mention that at the very beginning of your post. (i.e. "I'm using the GAMLj module and ...")

let me attend marcello to this.

cheers

jonathon jonathon

Posts: 1760
Joined: Fri Jan 27, 2017 10:04 am

## Re: Jamovi and R plotting different graphs

Hi zaslan
I've been working on your issue and, although I do not have a clear explanation for the discrepancy in the two plots, I have good reasons to believe the the plot in GAMLj is fine. First, if you look at the simple effects you see the they are in line to what we see in the GAMLj plot. the effect of AoA is slightly negative for ENG and clearly negative for TR, as the plot shows.
To be sure, I re-ran your model in R and made the simple slople of AoA "by hand", meaning re-estimating the model coding `language` with 0 and 1 to change the reference group for which the effect of AoA is estimated. The estimates of the effect of AoA are in line with GAMLj simple effects and the plots. Here is the syntax

Code: Select all
`contrasts(data\$language)<-contr.treatment(2,1)mod<-lmer(response_time ~ target_intensity+language+task_order          +target_intensity*language+task_order*language          +z_AoA+z_PPVT          +target_intensity*z_AoA+language*z_AoA          +target_intensity*z_PPVT+language*z_PPVT          +language*target_intensity*z_AoA+language*target_intensity*z_PPVT          +(1|subject)+(1|face),data=data)summary(mod)contrasts(data\$language)<-contr.treatment(2,2)mod<-lmer(response_time ~ target_intensity+language+task_order          +target_intensity*language+task_order*language          +z_AoA+z_PPVT          +target_intensity*z_AoA+language*z_AoA          +target_intensity*z_PPVT+language*z_PPVT          +language*target_intensity*z_AoA+language*target_intensity*z_PPVT          +(1|subject)+(1|face),data=data)summary(mod)`

Exploring a bit more, it seems that `interact_plot` gets confused by the three way interaction. If you run a simpler model without three way interaction, you get the same plot in GALMj and in interact_plot

Code: Select all
`mod1<-lmer(response_time ~ target_intensity+language*target_intensity+ target_intensity*language           + z_AoA+z_AoA*language+z_AoA*target_intensity           +(1|subject)+(1|face),data=data)interact_plot(mod1, pred = z_AoA, modx = language, interval = TRUE,              modx.values=c("ENG","TR "),              colors = "Set2", x.label = "Age of Acquisition", y.label = "Reaction Time (msecs)",              legend.main = "Language")` but if you add the three way interaction, interact_plot gives a completely different plot. This should not happen, because I have all centered contrasts, thus adding the three-way interaction should only slightly change the two way interaction plot.

Code: Select all
`mod2<-lmer(response_time ~ task_order*target_intensity+language*target_intensity+ target_intensity*language           + z_AoA+z_AoA*language+z_AoA*target_intensity           +  language*target_intensity*z_AoA           +(1|subject)+(1|face),data=data)interact_plot(mod2, pred = z_AoA, modx = language, interval = TRUE,              modx.values=c("ENG","TR "),              colors = "Set2", x.label = "Age of Acquisition", y.label = "Reaction Time (msecs)",              legend.main = "Language")`  mcfanda@gmail.com

Posts: 260
Joined: Thu Mar 23, 2017 9:24 pm

Return to Help