Learn R Programming

arkhe (version 1.11.0)

bootstrap: Nonparametric Bootstrap Estimation

Description

Samples randomly from the elements of object with replacement.

Usage

bootstrap(object, ...)

# S4 method for numeric bootstrap( object, do, n, ..., f = NULL, level = 0.95, interval = c("basic", "normal", "percentiles") )

Value

If f is NULL (the default), bootstrap() returns a named numeric

vector with the following elements:

original

The observed value of do applied to object.

mean

The bootstrap estimate of mean of do.

bias

The bootstrap estimate of bias of do.

error

The bootstrap estimate of standard error of do.

lower

The lower limit of the bootstrap confidence interval at level.

upper

The upper limit of the bootstrap confidence interval at level

If f is a function, bootstrap() returns the result of f applied to the n values of do.

Arguments

object

A numeric vector.

...

Extra arguments to be passed to do.

do

A function that takes object as an argument and returns a single numeric value.

n

A non-negative integer giving the number of bootstrap replications.

f

A function that takes a single numeric vector (the result of do) as argument.

level

A length-one numeric vector giving the confidence level. Must be a single number between \(0\) and \(1\). Only used if f is NULL.

interval

A character string giving the type of confidence interval to be returned. It must be one "basic" (the default), "normal" or "percentiles" (see confidence_bootstrap()). Any unambiguous substring can be given. Only used if f is NULL.

Author

N. Frerebeau

References

Davison, A. C. & Hinkley, D. V. (1997). Bootstrap Methods and Their Application. Cambridge Series on Statistical and Probabilistic Mathematics. Cambridge: Cambridge University Press.

See Also

confidence_bootstrap()

Other resampling methods: jackknife(), resample_multinomial(), resample_uniform()

Examples

Run this code
x <- rnorm(20)

## Bootstrap
bootstrap(x, do = mean, n = 100)

## Estimate the 25th and 95th percentiles
quant <- function(x) { quantile(x, probs = c(0.25, 0.75)) }
bootstrap(x, n = 100, do = mean, f = quant)

## Get the n bootstrap estimates
(z <- bootstrap(x, n = 100, do = mean, f = function(x) { x }))

## Basic bootstrap confidence interval
confidence_bootstrap(z, level = 0.95, type = "basic", t0 = mean(x))

Run the code above in your browser using DataLab