jtools icon indicating copy to clipboard operation
jtools copied to clipboard

effect plots and partial residuals for lme4 models with 2 random slope terms and quadratic term

Open SteffenMumme opened this issue 5 years ago • 1 comments

Is there any possibity to use the effect plot with the partial residual function also for a model involving 2 random slope terms? It works brilliant for models with one random slpoe term, but not with 2. Just asking, as I might just have not fully understood the underlying problem. Additionally also it does not seem to work when including a polynomial predictor term (poly(variable, 2, raw = TRUE)), any ideas how this could work?

Cheers!

SteffenMumme avatar Oct 29 '20 12:10 SteffenMumme

Hi, I'm having trouble replicating the issue.

Here's what I'm doing, so maybe I'm just misunderstanding some aspect of your problem.

library(ggplot2)
library(jtools)
lfit_poly <- lmer(cty ~ poly(displ, 2) + year + cyl + class + fl + drv + (drv + year | manufacturer), data = mpg)
effect_plot(lfit_poly, displ, partial.residuals = T)

Now I can get an error when I use poly(x, 2, raw = TRUE). I'm not sure why this is but it will be a low priority for now since I know the raw = FALSE version works.

jacob-long avatar Apr 08 '22 03:04 jacob-long