-
Notifications
You must be signed in to change notification settings - Fork 93
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
Confidence interval bands partially or completely disappear when axes rescaled #933
Comments
i am having this same issue when trying to plot a 3-way interaction. this remains even when there are no removed rows for missing values. any help would be much appreicuated! |
Can you try: ggeffects::predict_response(mod.example, terms = c("x1", "x2")) |> plot() |
i wind up with the same issue, although since i have a 3 way interaction, in my case it is: ggeffects::predict_response(mod.example, terms = c("x1", "x2", "x3")) |> plot() x1 is a 4 level, unordered factor and x2 and x3 are continuous variables that have been centered and scaled. this is an nb model with an log-transformed offset, if that helps |
not sure if this helps or not, but i made a df using ggeffects and noticed that the largest value of the "conf.high" column is 76.25. if i set my y scale to c(0, 77) the CI bands look fine. but if i go below the max, i get the cut-off CI band. this happens at each grouping level of x1. so as long as the upper limit of the y scale is above the max "conf.high" value for the x1 grouping, the CI bands look ok. but for any x1 group that has a conf.high above the upper end of the y scale, the CI bands partially disappear. for example, if i set the upper scale to 56, this leads to 2 plots with wonky CI bands, and 2 with no problems. |
this gets me the plot of interest, using the df created with predict_response: edit: i accidentally cropped the last line of code with the y limits ggplot(mydf, aes(x, predicted, colour = group)) + |
yes, if the values of the confidence intervals exceed the axis limits, they're "cropped". that's the default ggplot2-behaviour. I think you can avoid this by adding a ggeffects::predict_response(mod.example, terms = c("x1", "x2", "x3")) |>
plot() +
ggplot2::coord_cartesian() or you change the y-limits: ggeffects::predict_response(mod.example, terms = c("x1", "x2", "x3")) |>
plot() +
ggplot2::ylim(c(..., ...))
# or
ggeffects::predict_response(mod.example, terms = c("x1", "x2", "x3")) |>
plot(limits = c(..., ...) See examples here: https://strengejacke.github.io/ggeffects/articles/introduction_plotcustomize.html#changing-the-y-axis-appearance |
i'll keep working through examples, but so far (using the suggestions above), i still get the same truncated CI bands. thanks! |
Strange, it should work as described here: |
it does work with coord_cartesian(ylim = c(0, 50)), but only when i plot directly with ggplot on the ggeffcts object. i can't get it to work through ggeffects |> plot. |
Hi Dr. Luedecke - thanks for all your work on this amazing package!
I am working on plotting the marginal effects for a GLM with two numerical explanatory variables.
Here is the model with the variables genericized:
Any insights or work-arounds would be much appreciated!
Thank you,
Jerry S
The text was updated successfully, but these errors were encountered: