R/mcmc.sum.R

Defines functions mcmc.sum

Documented in mcmc.sum

#' Calculate summaries from an MCMC run
#' 
#' @param mcmc a data frame with MCMCtree's output 
#' 
#' @details 
#' The data frame should have headers and should contain the output from the 
#' mcmc.txt file generated by MCMCtree.
#' 
#' @return 
#' A data frame with the mean, median, and 95% CI of times
#'
#' @export
mcmc.sum <- function(mcmc) {
  ti <- grep("t_", names(mcmc))
  median <- apply(mcmc[,ti], 2, median)
  mean <- apply(mcmc[,ti], 2, mean)
  ci025 <- apply(mcmc[,ti], 2, quantile, probs=.025)
  ci975 <- apply(mcmc[,ti], 2, quantile, probs=.975)
  
  return(data.frame(median=median, mean=mean, ci025=ci025, ci975=ci975))
}
dosreislab/mcmc3r documentation built on March 29, 2024, 6:45 p.m.