Interaction plot based on Mean and SD

Hi. I would like to have an interaction plot showing the interaction between two continuous variables. I have done the moderation analysis based on three levels of the moderator (-1 SD, Mean, + 1SD) and I would like to draw the plot based on that too (something like this: Plot interaction effects in regression models — interact_plot • interactions). I am using Rstudio by the way and I am a beginner. So, simple solutions would be very appreciated. The easiest way I found was the interact_plot () that does not work.
Thank you all in advance!
Fatemeh

Hi,

Welcome to the RStudio community!

If you like us to be able to help you, you will have to be a bit more specific on what is not working for you with your dataset. The interact_plot link you shared does have a nice and easy example at the end showing how to create the plot, so try and recreate that first, and see if you run into any issues.

Once you are familiar with that, try and apply it to your own dataset. If it generates errors, you can create a reprex and share that here so we can take a look at your specific issue in more detail. A reprex consists of the minimal code and data needed to recreate the issue/question you're having. You can find instructions how to build and share one here:

Good luck,
PJ

Hi,
Thank you for your reply! I have tried the codes in the link I mentioned. However, it does not work. It says 'interaction_plot is not available. I have installed all the required packages mentioned in the link, but it still does not work. I also searched for 'interact_plot' in R studio with '?interact_plot' and nothing showed up. Look forward to hearing from you!
Fatemeh

Hi,

Lets first see if you can just run the example they provide

library(interactions)

states <- as.data.frame(state.x77)
states$HSGrad <- states$`HS Grad`
fit <- lm(Income ~ HSGrad + Murder * Illiteracy, data = states)
interact_plot(model = fit, pred = Murder, modx = Illiteracy)

If you run this in R, do you get the plot output as shows in their example?

PJ

Hi,
Yes, I have tried it in R too and received the same error again (' could not find function "interact_plot').
Fatemeh

I would look into the effects and ggeffects packages.

Are you sure you installed the package?

install.packages("interactions") #Run once
library(interactions) #load library

PJ

Hi PJ,
No forgot to do so. :slight_smile:
Thank you for your help. I just got the nice plot.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.