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
integergiving the number of bootstrap replications.- f
A
functionthat takes a single numeric vector (the bootstrap estimates) as argument.- level
A length-one
numericvector giving the confidence level. Must be a single number between \(0\) and \(1\). Only used iffisNULL.- interval
A
characterstring giving the type of confidence interval to be returned. It must be one "basic" (the default), "normal" or "percentiles" (seearkhe::confidence_bootstrap()). Any unambiguous substring can be given. Only used iffisNULL.- seed
An object specifying if and how the random number generator should be initialized (see
stats::simulate()).- rare
A
logicalscalar: 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:
originalThe observed value.
meanThe bootstrap estimate of mean.
biasThe bootstrap estimate of bias.
errorThe bootstrap estimate of standard error.
lowerThe lower limit of the bootstrap confidence interval at
level.upperThe 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()
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.136297 -0.1329029 0.0699576 3.273083 3.550118
#> Cueto de la Mina 2.955298 2.746285 -0.2090126 0.1077177 2.963122 3.384721
#> El Juyo 2.491683 2.298981 -0.1927020 0.1458626 2.423002 3.004915
#> El Cierro 2.485604 2.260329 -0.2252754 0.1347934 2.476020 3.000243
#> La Paloma 2.329187 2.051730 -0.2774570 0.1529379 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
