# NOT RUN {
library(dplyr)
library(tidyr)
library(ggplot2)
# generate a set of curves
k = 11 # number of curves
n = 201
df = tibble(
.draw = 1:k,
mean = seq(-5,5, length.out = k),
x = list(seq(-15,15,length.out = n))
) %>%
unnest(x) %>%
mutate(y = dnorm(x, mean, 3))
# see pointwise intervals...
df %>%
group_by(x) %>%
median_qi(y, .width = c(.5)) %>%
ggplot(aes(x = x, y = y)) +
geom_lineribbon(aes(ymin = .lower, ymax = .upper)) +
geom_line(aes(group = .draw), alpha=0.15, data = df) +
scale_fill_brewer() +
ggtitle("50% pointwise intervals with point_interval()") +
theme_ggdist()
# ... compare them to curvewise intervals
df %>%
group_by(x) %>%
curve_interval(y, .width = c(.5)) %>%
ggplot(aes(x = x, y = y)) +
geom_lineribbon(aes(ymin = .lower, ymax = .upper)) +
geom_line(aes(group = .draw), alpha=0.15, data = df) +
scale_fill_brewer() +
ggtitle("50% curvewise intervals with curve_interval()") +
theme_ggdist()
# }
Run the code above in your browser using DataLab