#' Credible Set
#'
#' @param alpha a p-vector, posterior probabilities
#' @param rho level
#'
#' @return A credible set
#' @export
CredibleSet <- function(alpha, rho = 0.95) {
p <- length(alpha)
order_dec <- order(alpha, decreasing = T)
S <- 0
for (i in 1:p) {
index <- order_dec[i]
S <- S + alpha[index]
if (S >= rho) {
break
}
}
index <- order_dec[1:i]
return(index)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.