R/confidence_interval_from_normal_distribution.R

Defines functions confidence_interval_from_normal_distribution

Documented in confidence_interval_from_normal_distribution

#' Compute confidence interval from normal distribution
#' @param vec Numeric vector from which confidence interval will be derived
#' @param level Numeric of the confidence level in decimal format
#' @author Alexander Kheirallah ([email protected])
#' @export 


confidence_interval_from_normal_distribution = function(vec,level=0.95){
  z = z_score_for_standard_normal_where_area_is_equally_split_from_mean(area=level)
  m = mean(vec)
  st.dev = sd(vec)
  n = length(vec)
  
  err = z*st.dev/sqrt(n)
  o = c(m - err, m + err)
  names(o) = c("lower","upper")
  o
}
msxakk89/dat documentation built on April 3, 2020, 5:39 p.m.