How can I determine the confidence/credibility intervals for the posterior estimates of a multi-parameter model?
I can get the confidence interval for each parameter separately.
(Currently using bayestestR
, but I don't mind using something else)
library(dplyr)
library(ggplot2)
library(bayestestR)
N <- 10000
#Posterior samples (random example)
p1 <- rnorm(N)
p2 <- p1 + rnorm(N)
df_post <- tibble(p1,p2)
describe_posterior(
df_post,
centrality = "median",
test = c("p_direction", "p_significance")
)
##Yields:
# Summary of Posterior Distribution
#
# Parameter | Median | 95% CI | pd | ps
# -----------------------------------------------------
# p1 | 0.02 | [-1.85, 2.08] | 50.64% | 0.46
# p2 | -2.24e-03 | [-2.82, 2.78] | 50.04% | 0.47
and I can generate a plot with the points and 2D contours, which gives me a visual indication of the posterior distribution (though I have no idea what % each contour represents):
ggplot(df_post, aes(x=p1, y=p2)) +
geom_density_2d(size=1) +
geom_point(size=0.1)
My question is, How can I actually compute (and/or plot) the two dimensional X% credibility interval?