bootMean | R Documentation |
Finds mean of a vector, with bootstrapped confidence bounds.
bootMean(x, num.boot = 1000, conf.level = 0.95, seed = 12, ...)
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 |
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
.
A list with elements
obs.mean |
mean |
ci |
bootstraped confidence interval |
n |
number of bootstrap samples used |
Aline Talhouk, Derek Chiu
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.