bootMean: Mean and bootstrap confidence interval

View source: R/bootMean.R

bootMeanR Documentation

Mean and bootstrap confidence interval

Description

Finds mean of a vector, with bootstrapped confidence bounds.

Usage

bootMean(x, num.boot = 1000, conf.level = 0.95, seed = 12, ...)

Arguments

x

a vector (or matrix)

num.boot

number of bootstrap samples. Defaults to 1000.

conf.level

confidence level.

seed

random seed for resampling

...

additional arguments to mean

Details

Takes a numeric vector and resamples with replacement num.boot times. If the input vector has any NA entries, include the argument na.rm = TRUE from mean.

Value

A list with elements

obs.mean

mean

ci

bootstraped confidence interval

n

number of bootstrap samples used

Author(s)

Aline Talhouk, Derek Chiu

Examples

## Vectors
set.seed(344)
bootMean(rnorm(100, 5, 3))
bootMean(rnorm(100, 5, 3), num.boot = 500)
bootMean(rnorm(100, 4, 3), conf.level = 0.90)

## Missing Values
set.seed(344)
s <- ifelse(rexp(100, 0.5) < 1, NA, rexp(100, 0.5))
bootMean(s)  # doesn't work
bootMean(s, na.rm = TRUE)

TalhoukLab/biostatUtil documentation built on April 14, 2025, 4:15 a.m.