0

I wish to plot my interaction effect using R. Below is a picture how it should look like. I am using multilevel analysis with the lme4 package.

My model looks like this:

h3a_c_3 <- lmer(PSS_mean ~ WLoad_mean_gmc * PCT_mean_gmc + sex_m + age_m + startup_m + (1 | teamcode), data = dat)

PSS_mean stands for Perceived Stress (dependent variable), PCT_mean_gmc is team PsyCap (Moderator) and WLoad_mean_gmc(Predictor) is Work Load.

I have already tried several things but nothing worked so far.

Thank you very much in advance!

Sarah

https://drive.google.com/open?id=15JjC-s2OqDMkfl9BHMNgXnpkpUlazpfO

seabysalt
  • 67
  • 4
  • 1
    Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not use `str()`, `head()` or screenshot)? You can use the [`reprex`](https://reprex.tidyverse.org/articles/articles/magic-reprex.html) and [`datapasta`](https://cran.r-project.org/web/packages/datapasta/vignettes/how-to-datapasta.html) packages to assist you with that. See also [Help me Help you](https://speakerdeck.com/jennybc/reprex-help-me-help-you?slide=5) & [How to make a great R reproducible example?](https://stackoverflow.com/q/5963269) – Tung Oct 29 '19 at 11:49

1 Answers1

0

I can't say for sure without some data or examples for testing, but I think this should work:

library(ggeffects)
x <- ggpredict(h3a_c_3, c("WLoad_mean_gmc", "PCT_mean_gmc"))

x
plot(x)

you can find a comprehensive documentation for the ggeffects package here: http://strengejacke.github.io/ggeffects

There is even an example for mixed models with interaction terms here.

Daniel
  • 7,252
  • 6
  • 26
  • 38