strengejacke / sjPlot

sjPlot - Data Visualization for Statistics in Social Science

Home Page:https://strengejacke.github.io/sjPlot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sjPlot showing extra regression line

aaldoh opened this issue · comments

Hello! I'm trying to visualise an interaction using terciles or quartiles and whenever I try to do so, I get an extra regression line. For example:

test_mod <- lm(hp ~ drat*wt, mtcars)
plot_model(test_mod,type = "eff", terms = c("drat","wt [terciles]"))

image

Any idea how to make them 3? I also tried with quart instead of terciles and I ended up with 5 plotted lines.

commented

For terciles, you have the 33.3% and 66.6% quantiles, including minimum and maximum, resulting in four values:

stats::quantile(mtcars$wt, probs = (0:3) / 3, na.rm = TRUE)
#>        0% 33.33333% 66.66667%      100% 
#>  1.513000  2.811667  3.500000  5.424000

Created on 2023-06-20 with reprex v2.0.2

See all options here: https://strengejacke.github.io/ggeffects/reference/values_at.html

Ah brilliant! Thank you. I now see that there are options excluding the minimum and maximum. I couldn't see it in the documentation for plot_model "mdrt.values" column but the linked page clears it all up.

commented

Yes, I mainly work on the ggeffects package, and sjPlot just wraps ggeffects::ggpredict(), so I somewhat neglect updating sjPlot a bit ;-)