boot {CarletonStats} | R Documentation |
Bootstrap
Description
Bootstrap a single variable or a grouped variable
Usage
boot(x, ...)
## Default S3 method:
boot(
x,
group = NULL,
statistic = mean,
conf.level = 0.95,
B = 10000,
plot.hist = TRUE,
plot.qq = FALSE,
x.name = deparse(substitute(x)),
xlab = NULL,
ylab = NULL,
title = NULL,
seed = NULL,
...
)
## S3 method for class 'formula'
boot(formula, data, subset, ...)
Arguments
x |
a numeric vector |
... |
further arguments to be passed to or from methods. |
group |
an optional grouping variable (vector), usually a factor variable. If it is a binary numeric variable, it will be coerced to a factor. |
statistic |
function that computes the statistic of interest. Default is the
|
conf.level |
confidence level for the bootstrap percentile interval. Default is 95%. |
B |
number of times to resample (positive integer greater than 2). |
plot.hist |
logical value. If |
plot.qq |
Logical value. If |
x.name |
Label for variable name |
xlab |
an optional character string for the x-axis label |
ylab |
an optional character string for the y-axis label |
title |
an optional character string giving the plot title |
seed |
optional argument to |
formula |
a formula |
data |
a data frame that contains the variables given in the formula. |
subset |
an optional expression indicating what observations to use. |
Details
Perform a bootstrap of a statistic applied to a single variable, or to the
difference of the statistic computed on two samples (using the grouping
variable). If x
is a binary vector of 0's and 1's and the function is
the mean, then the statistic of interest is the proportion.
Observations with missing values are removed.
Value
A vector with the resampled statistics is returned invisibly.
Methods (by class)
-
boot(default)
: Bootstrap a single variable or a grouped variable -
boot(formula)
: Bootstrap a single variable or a grouped variable
Author(s)
Laura Chihara
References
Tim Hesterberg's website https://www.timhesterberg.net/bootstrap-and-resampling
Examples
#ToothGrowth data (supplied by R)
#bootstrap mean of a single numeric variable
boot(ToothGrowth$len)
#bootstrap difference in mean of tooth length for two groups.
boot(ToothGrowth$len, ToothGrowth$supp, B = 1000)
#same as above using formula syntax
boot(len ~ supp, data = ToothGrowth, B = 1000)