Learn R Programming

tabula (version 3.3.0)

bootstrap: Bootstrap Estimation

Description

Bootstrap Estimation

Usage

# S4 method for DiversityIndex
bootstrap(
  object,
  n = 1000,
  f = NULL,
  level = 0.95,
  interval = c("basic", "normal", "percentiles"),
  seed = NULL,
  rare = FALSE
)

Value

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

matrix

with the following columns:

original

The observed value.

mean

The bootstrap estimate of mean.

bias

The bootstrap estimate of bias.

error

The bootstrap estimate of standard error.

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 values computed from the n replications.

Arguments

object

An R object (typically a DiversityIndex object).

n

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

f

A function that takes a single numeric vector (the bootstrap estimates) 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 arkhe::confidence_bootstrap()). Any unambiguous substring can be given. Only used if f is NULL.

seed

An object specifying if and how the random number generator should be initialized (see stats::simulate()).

rare

A logical scalar: should the sample be drawn from an uniform distribution with replacement instead of a multinomial distribution?

Author

N. Frerebeau

Details

n random samples are drawn, each with the same sample size as in the original sample and with class probabilities proportional to the original abundances.

Note that the mean of the bootstrapped samples will often be much lower than the observed value. Bootstrapping results must be interpreted with great care.

See Also

Other resampling methods: jackknife()

Examples

Run this code
## Data from Conkey 1980, Kintigh 1989
data("cantabria")

## Shannon diversity index
(h <- heterogeneity(cantabria, method = "shannon"))

## Bootstrap resampling
bootstrap(h)

bootstrap(h, f = summary)

quant <- function(x) quantile(x, probs = c(0.05, 0.95))
bootstrap(h, f = quant)

Run the code above in your browser using DataLab