Learn R Programming

asbio (version 0.2-1)

bootstrap: A simple function for bootstrapping

Description

The function serves as a simplified alternative to the function boot from the library boot.

Usage

bootstrap(data, statistic, R, matrix = FALSE)

Arguments

data
Raw data to be bootstrapped. A vector or quantitative data or a matrix if matrix =TRUE.
statistic
A function whose output is a statistic (e.g. a sample mean). The function must have only one argument, a call to data.
R
The number of bootstrap iterations.
matrix
A logical statement. If matrix = TRUE then rows in the matrix are sampled as multivariate observations.

Value

  • Returns a bootstrap distribution of a statistic.

Details

With bootstrapping we sample with replacement from a dataset of size n with n samples R times. At each of the R iterations a statistical summary can be created resulting in a bootstrap distribution of statistics.

References

Manly, B. F. J. (1997) Randomization and Monte Carlo methods in biology, 2nd edition. Chapman and Hall, London.

See Also

boot

Examples

Run this code
library(vegan)
data(varespec)
# A partial set of observations from a single plot for a Scandinavian moss/vascular plant/lichen survey.
site18<-data.frame(t(varespec[1,][1:20]))

#Shannon-Weiner diversity
SW<-function(data){
d<-data[data!=0]
p<-d/sum(d)
-1*sum(p*log(p))
}

bootstrap(site18[,1],SW,R=1000,matrix=FALSE)

Run the code above in your browser using DataLab