R/ci.R

Defines functions ci

Documented in ci

#' Confidence Interval
#'
#' Generate empirical confidence interval from a vector of iterations, e.g.
#' bootstrap or MCMC.
#'
#' @param x a vector of iterations.
#' @param level the significance level.
#'
#' @return Confidence bounds, a named vector of two elements.
#'
#' @note See \code{BCboot} for bootstrap bias correction.
#'
#' @importFrom stats quantile
#'
#' @export

ci <- function(x, level=0.95)
{
  alpha <- 1 - level
  lower <- alpha/2
  upper <- 1 - alpha/2

  quantile(x, probs=c(lower,upper))
}
arnima-github/arni documentation built on Oct. 28, 2023, 6:18 p.m.