This function calculates a credible interval of the specified width from a vector of MCMC draws.
credibleInterval(draws, width)
A named list containing three elements:
width: The specified width of the credible interval.
lower_bound: The lower bound of the credible interval.
upper_bound: The upper bound of the credible interval.
A numeric vector containing MCMC draws.
A numeric value between 0 and 1 specifying the desired width of the credible interval.
The function calculates the lower and upper bounds of the credible interval using the quantile function based on the specified width.
# Generate example draws
draws <- rnorm(1000)
# Calculate 95% credible interval
credibleInterval(draws, width = 0.95)
Run the code above in your browser using DataLab