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,
  legend.loc = "topright", plot.qq = FALSE,
  x.name = deparse(substitute(x)), ...)

## 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 mean.

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 TRUE, plot the histogrom of the bootstrap distribution.

legend.loc

where to place the legend on the histogram. Default is "topright". Other options include "topleft", "bottomleft" and "bottomright".

plot.qq

Logical value. If TRUE, create a normal quantile-quantile plot of the bootstrap distribution.

x.name

Label for variable name

formula

a formula y ~ g where y is a numeric vector and g a factor variable with two levels. If g is a binary numeric vector, it will be coerced to a factor variable. For a single numeric variable, formula may also be ~ y.

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)

Author(s)

Laura Chihara

References

Tim Hesterberg's website http://www.timhesterberg.net/bootstrap

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)

#same as above using formula syntax
boot(len ~ supp, data = ToothGrowth)


[Package CarletonStats version 2.0 Index]