• resample() simulate observations from a multinomial distribution.

• bootstrap() generate bootstrap estimations of a statistic.

• jackknife() generate jackknife estimations of a statistic.

## Usage

resample(object, ...)

bootstrap(object, ...)

jackknife(object, ...)

# S4 method for DiversityIndex
bootstrap(object, n = 1000, f = NULL)

# S4 method for DiversityIndex
jackknife(object)

# S4 method for numeric
resample(object, do, n, size = sum(object), ..., f = NULL)

## Arguments

object

A numeric vector of count data (absolute frequencies).

...

Extra arguments passed to do.

n

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

f

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

do

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

size

A non-negative integer specifying the sample size.

## Value

If f is NULL, resample() returns the n values of do. Else, returns the result of f applied to the n values of do.

If f is NULL, bootstrap() and jackknife() return a data.frame

with the following elements (else, returns the result of f applied to the n values of do) :

original

The observed value of do applied to object.

mean

The bootstrap/jackknife estimate of mean of do.

bias

The bootstrap/jackknife estimate of bias of do.

error

The boostrap/jackknife estimate of standard error of do.

stats::rmultinom()

N. Frerebeau

## Examples

## Sample observations from a multinomial distribution
x <- sample(1:100, 50, TRUE)
resample(x, do = median, n = 100)
#>   [1] 49.0 51.5 52.5 47.5 51.5 49.5 47.5 49.0 52.5 54.5 46.5 52.0 50.5 47.5 53.5
#>  [16] 50.0 50.5 48.0 46.5 50.0 49.0 51.0 47.5 51.5 50.0 50.0 48.0 50.5 52.5 53.5
#>  [31] 51.0 52.0 51.5 45.5 48.5 49.0 50.5 51.5 51.0 48.5 56.0 49.0 49.5 51.5 51.5
#>  [46] 52.5 48.0 49.0 51.0 50.0 50.0 52.5 49.0 50.5 49.0 49.5 49.5 50.0 53.5 51.0
#>  [61] 51.0 55.5 57.0 52.5 48.5 50.5 51.5 49.0 57.0 48.5 47.5 53.5 54.0 51.0 45.0
#>  [76] 48.0 46.5 51.5 51.0 48.5 47.5 52.0 48.5 51.5 48.5 49.0 48.0 49.5 50.0 51.5
#>  [91] 55.5 50.0 53.0 47.5 55.0 50.0 50.0 49.0 55.0 46.5

## Estimate the 25th, 50th and 95th percentiles
quant <- function(x) { quantile(x, probs = c(0.25, 0.50, 0.75)) }
resample(x, n = 100, do = median, f = quant)
#>    25%    50%    75%
#> 49.000 50.500 51.625