Description Usage Arguments Value Examples
Compute and plot coverage of CI for different confidence level. Useful for fake data check.
1 2 3 4 5 6 7 8 9 10 11 12 13 | compute_coverage(
post_samples,
truth,
CI = seq(0, 1, 0.05),
type = c("eti", "hdi")
)
plot_coverage(
post_samples,
truth,
CI = seq(0, 1, 0.05),
type = c("eti", "hdi")
)
|
post_samples |
Matrix of posterior samples. Rows represent a sample and columns represent variables. |
truth |
Vector of true parameter values (should be the same length as the number of columns in |
CI |
Vector of confidence levels. |
type |
Type of confidence intervals: either "eti" (equal-tailed intervals) or "hdi" (highest density intervals). |
compute_coverage
returns a Dataframe containing coverage (and 95% uncertainty interval for the coverage) for different confidence level (nominal coverage).
plot_coverage
returns a ggplot of the coverage as the function of the nominal coverage with 95% uncertainty interval.
1 2 3 4 5 6 7 | N <- 100
N_post <- 1e3
truth <- rep(0, N)
post_samples <- sapply(rnorm(N, 0, 1), function(x) {rnorm(N_post, x, 1)})
compute_coverage(post_samples, truth)
plot_coverage(post_samples, truth)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.