bootstrap: Generate bootstrap replicates

Description Usage Arguments References See Also Examples

View source: R/bootstrap.R

Description

Generate nonparametric bootstrap samples. In addition to the the ordinary bootstrap, it supports weights, the Bayesian bootstrap, and sub- or super-sampling.

Usage

1
bootstrap(n, times = 1L, weights = NULL, bayes = FALSE, size = n)

Arguments

n

A positive, scalar integer representing the number of observations (items to choose from).

times

A positive, scalar integer representing the number of bootstrap samples to draw.

weights

A numeric vector with observation level weights.

bayes

A scalar logical, indicating whether to use the Bayesian bootstrap.

size

The number of observations in each output sample.

References

See Also

The boot function boot::boot() which is the canonical R bootstrap implementation. The modelr function modelr::bootstrap(), rsample function rsample::bootstraps provide similar implementations specialized to data frames.

Examples

1
2
3
4
5
6
7
8
9
# ordinary non-parametric bootstrap
bootstrap(20, 5)

# Bayesian bootstrap
bootstrap(20, 5, bayes = TRUE)

# weighted bootstrap
w <- c(rep(5, 5), rep(1, 15))
bootstrap(20, 5, weights = w / sum(w))

jrnold/ramsleep documentation built on May 29, 2019, 11:43 a.m.