resample: Resample

resampleR Documentation

Resample

Description

Simulates observations from a multinomial distribution.

Usage

resample(object, ...)

## S4 method for signature '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.

do

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

n

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

size

A non-negative integer specifying the sample size.

f

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

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.

Author(s)

N. Frerebeau

See Also

stats::rmultinom()

Other resampling methods: bootstrap(), jackknife()

Examples

## Sample observations from a multinomial distribution
x <- sample(1:100, 50, TRUE)
resample(x, do = median, n = 100)

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

tesselle/tabula documentation built on March 4, 2024, 4:41 a.m.