A very fast implementation of the basic nonparametric bootstrap for obtaining confidence limits for the population mean without assuming normality.

ci_mean_boot(
  y,
  conf_level = 0.95,
  repetitions = 2000,
  na.rm = TRUE,
  resampled_means = FALSE,
  return_df = TRUE
)

Arguments

y

(numeric) A numeric vector from which NAs will be removed automatically.

conf_level

(number) Confidence level. Number from 0 to 1. Default 0.95.

repetitions

(integer) Number of bootstrap resamples.

na.rm

(logical) If TRUE (default), missing values (NA's) are removed automatically.

resampled_means

(logical) If TRUE, the vector of bootstrapped means will be returned as the resampled_means attribute of the returned object.

return_df

(logical) If TRUE (default), result is returned as a data frame. If FALSE - as a matrix.

Value

An object (data frame or matrix) with a point estimate and confidence interval of mean.

Details

The function is based on code of function Hmisc::smean.cl.boot() from package Hmisc.

Examples

set.seed(111555) ci_mean_boot(1:60)
#> mean lower upper conf_level repetitions #> 1 30.5 26.01625 34.66667 0.95 2000
set.seed(999555) y <- rnorm(35, 10, 5) ci_mean_boot(y)
#> mean lower upper conf_level repetitions #> 1 10.40422 8.87088 11.84408 0.95 2000