#' Summarize draws
#'
#' This function provides summaries of postior samples in \code{tempo_mcmc()}`
#' output. Credible interval bounds correspond to 95% equal-tailed intervals.
#'
#' @return A data frame with monitored variables as rows, and summary statistics
#' as columns. Summary statistics include miniumum (Min), 2.5\% quantile
#' (95\% CI Lower), Median, Mean, 97.5\% quantile (95\% CI Upper), and maxiumum
#' (Max).
#'
#' @param draws output from \code{tempo_mcmc()}
#' @rdname tempo_summarize
#' @export
tempo_summarize <- function(draws) {
draws_all <- do.call(rbind, draws)
summarized <- lapply(draws_all, tempo_single_summary)
do.call(rbind, summarized)
}
tempo_single_summary <- function(x) {
quantiles <- quantile(x, probs = c(0, 0.025, 0.5, 0.975, 1))
mean_of_x <- mean(x)
output <- c(quantiles[1:3], mean_of_x, quantiles[4:5])
names(output) <- c("Min", "95% CI Lower",
"Median", "Mean",
"95% CI Upper", "Max")
output
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.