-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plot_model type="pred" with own title and solid not dashed error bars does not work #959
Comments
Thanks for reporting. For now, as a workaround, you could add a title via ggplot: library(sjPlot)
data(efc)
efc$sexdummy <- as.factor(ifelse(efc$c161sex == 1, "Sex_1", "Sex_2"))
efc$carerrelation <- ifelse(efc$e15relat == 1, "Child",
ifelse(efc$e15relat == 2, "Partner",
"Other"))
efc$carerrelation<- as.factor(efc$carerrelation)
#My model
m2 <- glm(sexdummy ~ carerrelation , data = efc, family = "binomial")
plot_model(
m2,
type = "pred",
show.values = TRUE,
value.offset = 0.3,
colors = "bw"
) + ggplot2::ggtitle("My title") |
Thank you! While that works for the title, any chance in getting the error bars from dashed to solid? I tried that with ggplot but so far without any luck. |
I suggest using the ggeffects package, which is internally used in sjPlot. user interface is very similar, but gives you more flexibility regarding plots: library(ggeffects)
data(efc)
efc$sexdummy <- as.factor(ifelse(efc$c161sex == 1, "Sex_1", "Sex_2"))
efc$carerrelation <- ifelse(efc$e15relat == 1, "Child",
ifelse(efc$e15relat == 2, "Partner",
"Other"))
efc$carerrelation<- as.factor(efc$carerrelation)
#My model
m2 <- glm(sexdummy ~ carerrelation , data = efc, family = "binomial")
?plot.ggeffects
predict_response(m2, "carerrelation") |> plot()
predict_response(m2, "carerrelation") |> plot() + ggplot2::ggtitle("test") See |
Oh, I See, I thought it was "just" a small bug in plot_model I had discovered. Thanks for the workaround! |
I want a graph using plot_model with type "pred" with my own individual title and solid (not dashed) lines on the error bar. However, both don't work - any help highly appreciated.
My current MWE:
Thank you for fixing the issue.
For a picture see: https://stackoverflow.com/q/79396777/6473874?sem=2
Sadly, cannot repex it, as I always get this error:
reprex:::reprex_addin()
ℹ Rendering reprex...
Error in reprex_render() :
This reprex appears to crash R. Call
reprex()
again withstd_out_err = TRUE
to get more info.ℹ Rendering reprex...
Error in
reprex_render()
:! This reprex appears to crash R. Call
reprex()
again withstd_out_err = TRUE
to get more info.Run
rlang::last_trace()
to see where the error occurred.The text was updated successfully, but these errors were encountered: