-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Use ggdist::curve_interval
for plotting curves in Bayesian models
#455
Comments
Mmh interesting, I'll try to include that... I suppose it will go somewhere here: this one looks funny tho |
oh actually no, this should be something that must be done at the level of bayestestR, when the computation of the CI is done. Maybe we could add an option to describe_posterior like |
or in |
Yeah, that sounds right (: |
A very hurtful thing to say to the poor graph.... |
Actually, do we need this implemented in bayestestR? It would essentially be a wrapper around |
Well it seems to be like it belongs there, because if I understand it's a different method of computing CIs, different from hdi, quantile etc. Perhaps mostly used for plotting, true, but still Moreover, modelbased now simply runs insight: which in turn calls bayestestR ^^ so yeah for generalizability (for people that use insight::get_predicted directly) it'd be convenient to have that feature in bayestestR |
I think it's okay if the curve estimation and the tabling have slightly different estimation. It would be okay to restrict the ggdist calls to see |
Another example with moderation: m <- rstanarm::stan_glm(mpg ~ factor(cyl) * hp, data = mtcars,
chains = 1, iter = 200, refresh = 0)
em_cyl <- emmeans::emmeans(m, ~ cyl + hp,
at = list(hp = seq(50, 350, by = 15))) |>
tidybayes::gather_emmeans_draws()
library(ggplot2)
em_cyl |>
ggdist::median_hdci(.width = 0.9) |>
transform(cyl = factor(cyl)) |>
ggplot(aes(hp, .value, ymin = .lower, ymax = .upper,
fill = cyl, color = cyl, group = cyl)) +
geom_ribbon(alpha = 0.2, color = NA) +
geom_line() em_cyl |>
ggdist::curve_interval(.width = 0.9) |>
transform(cyl = factor(cyl)) |>
ggplot(aes(hp, .value, ymin = .lower, ymax = .upper,
fill = cyl, color = cyl, group = cyl)) +
geom_ribbon(alpha = 0.2, color = NA) +
geom_line() Created on 2021-08-15 by the reprex package (v2.0.0) |
Chiming in since @DominiqueMakowski pinged me on mjskay/ggdist#95. I'm not sure in what context you're planning to use curve_interval, but it's worth pointing out a few things you may want to ponder:
|
One last thought from me: I was trying to figure out why your pointwise intervals were so noisy looking in the first place and realized you are using HDIs. HDIs can be very noisy, as you have discovered. If you use quantile intervals instead you'll find the pointwise bands are much smoother, besides having other benefits (like being invariant under transformation). FWIW if I were picking a default pointwise interval type I would lean in that direction. |
This gives an overall smoother line / interval (less "lumpy").
Read more, here >>
Linear regression plot
Looks lumpy...
Mmmmm... smoothhhhh
JN-plot smooth() plot
The text was updated successfully, but these errors were encountered: