Skip to contents

Bootstrap Estimation

Usage

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

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?

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.

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()

Author

N. Frerebeau

Examples

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

## Shannon diversity index
(h <- heterogeneity(cantabria, method = "shannon"))
#> [1] 3.269200 2.955298 2.491683 2.485604 2.329187

## Bootstrap resampling
bootstrap(h)
#>                  original     mean       bias      error    lower    upper
#> Altamira         3.269200 3.139008 -0.1301918 0.07044865 3.266819 3.544856
#> Cueto de la Mina 2.955298 2.744694 -0.2106038 0.11460412 2.966575 3.404584
#> El Juyo          2.491683 2.302322 -0.1893606 0.14657175 2.415142 2.993302
#> El Cierro        2.485604 2.260329 -0.2252754 0.13479341 2.476020 3.000243
#> La Paloma        2.329187 2.051730 -0.2774570 0.15293792 2.337163 2.935415

bootstrap(h, f = summary)
#>                      Min.  1st Qu.   Median     Mean  3rd Qu.     Max.
#> Altamira         2.911128 3.084787 3.136897 3.134423 3.181722 3.326409
#> Cueto de la Mina 2.318821 2.671353 2.755515 2.746748 2.823744 3.054519
#> El Juyo          1.760411 2.209904 2.308700 2.295862 2.394331 2.665208
#> El Cierro        1.759043 2.182456 2.275418 2.263906 2.354635 2.582577
#> La Paloma        1.454629 1.959569 2.057366 2.054326 2.160130 2.412210

quant <- function(x) quantile(x, probs = c(0.05, 0.95))
bootstrap(h, f = quant)
#>                        5%      95%
#> Altamira         3.018216 3.241602
#> Cueto de la Mina 2.558999 2.912483
#> El Juyo          2.055695 2.506495
#> El Cierro        2.027663 2.456533
#> La Paloma        1.798488 2.283687