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