Samples randomly from the elements of object
with replacement.
Usage
# S4 method for DiversityIndex
bootstrap(object, n = 1000, f = NULL)
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 result ofdo
) as argument.
Value
If f
is NULL
(the default), bootstrap()
returns a named numeric
vector with the following elements:
original
The observed value of
do
applied toobject
.mean
The bootstrap estimate of mean of
do
.bias
The bootstrap estimate of bias of
do
.error
he bootstrap estimate of standard error of
do
.
If f
is a function
, bootstrap()
returns the result of f
applied to
the n
values of do
.
See also
Other resampling methods:
jackknife_diversity
,
resample()
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, f = NULL)
#> original mean bias error
#> Altamira 3.269200 3.281415 0.012215108 0.08094605
#> Cueto de la Mina 2.955298 2.976502 0.021203835 0.14867535
#> El Juyo 2.491683 2.533877 0.042194118 0.19348027
#> El Cierro 2.485604 2.492820 0.007216276 0.21902418
#> La Paloma 2.329187 2.322210 -0.006976781 0.26597814
bootstrap(h, f = summary)
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> Altamira 2.980130 3.227869 3.285167 3.278950 3.332218 3.526771
#> Cueto de la Mina 2.379574 2.877482 2.974412 2.969057 3.075389 3.376285
#> El Juyo 1.364750 2.402382 2.550036 2.532691 2.673939 3.090122
#> El Cierro 1.349792 2.341877 2.485570 2.472341 2.624417 3.106595
#> La Paloma 1.329661 2.176777 2.345239 2.323145 2.493576 2.986485
quant <- function(x) quantile(x, probs = c(0.25, 0.50))
bootstrap(h, f = quant)
#> 25% 50%
#> Altamira 3.218863 3.279698
#> Cueto de la Mina 2.878694 2.981459
#> El Juyo 2.406119 2.541281
#> El Cierro 2.353266 2.509887
#> La Paloma 2.143952 2.331598
## Jackknife resampling
jackknife(h)
#> original mean bias error
#> Altamira 3.269200 3.246457 -0.9779158 0.08145529
#> Cueto de la Mina 2.955298 2.932856 -0.9649994 0.15907033
#> El Juyo 2.491683 2.469588 -0.9500688 0.19670002
#> El Cierro 2.485604 2.462723 -0.9838709 0.22195573
#> La Paloma 2.329187 2.305876 -1.0023704 0.25266291
bootstrap(h, f = summary)
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> Altamira 2.907398 3.227045 3.285983 3.280298 3.334200 3.475782
#> Cueto de la Mina 2.422481 2.887438 2.982113 2.980356 3.077014 3.442116
#> El Juyo 1.718474 2.400674 2.534033 2.520185 2.659175 3.121564
#> El Cierro 1.524290 2.347204 2.498433 2.487297 2.647794 3.099865
#> La Paloma 1.098612 2.163956 2.347580 2.319130 2.506859 2.916372