Closed mjskay closed 3 years ago
Thanks! Makes total sense. I'm not doing much with it at the moment, just setting up some infrastructure in ggdist that will at some point be used with it, but likely not in the next release. I'll hold off on doing anything substantial user-facing with it until you've nailed down a desired format.
Great.
I expect that the format will be a generalisation of <hilo>
, which allows multiple upper<dbl>
and lower<dbl>
values for a single confidence level<dbl>
. I think this will not change the <hilo>
type, even though <hilo>
could be represented using <hdr>
to keep the storage format of <hilo>
efficient.
You may also be interested in the {gghdr}
dev package, which was hacked together at the most recent OzUnconf. The package was developed as a {ggplot2} extension for Rob's {hdrcde}
package.
It doesn't use {distributional}
for the {hdr}
code, but it was planned to use the {hdr}
object type once finalised. The code contained in the package is less interesting than the types of high density region visualisations that it provides.
Cool! Yeah, ggdist currently supports that style of plot with its non-dist stats via the point_interval()
function family, which produces tidy data frames of intervals and point estimates, including hdis (though not as a nice vector format like hilo).
e.g. this doesn't give multiple intervals because the default point_interval is median_qi
:
data.frame(x = rnorm(4000, c(1,6), c(1,2))) %>%
ggplot(aes(y = 0, x = x)) +
stat_halfeye() +
geom_rug(alpha = .02) +
scale_color_brewer() +
theme_ggdist()
But this does:
data.frame(x = rnorm(4000, c(1,6), c(1,2))) %>%
ggplot(aes(y = 0, x = x)) +
stat_halfeye(point_interval = mode_hdi) +
geom_rug(alpha = .02) +
scale_color_brewer() +
theme_ggdist()
Something similar to the gghdr plots would be to use mode_hdi
with stat_interval
(though unfortunately there isn't a great way for this to put points at multiple modes the way gghdr does):
data.frame(x = rnorm(4000, c(1,6), c(1,2))) %>%
ggplot(aes(y = 0, x = x)) +
stat_interval(point_interval = mode_hdi) +
geom_rug(alpha = .02) +
scale_color_brewer() +
theme_ggdist()
While this works with sample data, at the moment with distributional objects and the stat_dist_...
family, only medians and quantile intervals are supported. What I have changed recently is making it so that the ggdist::point_interval()
functions can take distributional objects. That said, I haven't updated stat_dist_...
to actually use the point_interval functions yet, which is when that change will really become visible and useful to folks using distributional objects; I can wait on that until the hdr format is finalized.
This is in a similar vein to #58. It moves the main implementation of
hdr()
fromhdr.distribution()
tohdr.dist_default()
, and usesdist_apply()
inhdr.distribution()
in a similar manner to howhilo.distribution()
works.Previous behavior:
New behavior: