bootEst: Functions to generate bootstrap estimates of overlap

View source: R/bootEst.R

bootstrap functionsR Documentation

Functions to generate bootstrap estimates of overlap


bootstrap takes two sets of times of observations and calculates bootstrap estimates of the chosen estimator of overlap. Alternatively, bootstrap estimates can be calculated in a 2-stage process: (1) create a matrix of bootstrap samples for each data set, using resample; (2) pass these matrices to bootEst to obtain the bootstrap estimates.

A vector of bootstrap estimates can then be used to produce confidence intervals with bootCI.


bootstrap(A, B, nb, smooth=TRUE, kmax=3, adjust=NA, n.grid=128,
    type=c("Dhat1", "Dhat4", "Dhat5"), cores=1)

resample(x, nb, smooth = TRUE, kmax = 3, adjust = 1, n.grid = 512)

bootEst(Amat, Bmat, kmax = 3, adjust=c(0.8, 1, 4), n.grid = 128,
      type=c("all", "Dhat1", "Dhat4", "Dhat5"), cores=1)


A, B

vectors of times of observations of two different species in radians, ie. scaled to [0, 2\pi].


the number of bootstrap samples required


if TRUE, smoothed bootstrap samples are produced.


maximum value of k for optimal bandwidth estimation.


bandwidth adjustment. If adjust=NA in bootstrap, adjust will be set to 0.8 for type="Dhat1", 1 for type="Dhat4" and 4 for type="Dhat5".


number of points at which to estimate density for comparison between species; smaller values give lower precision but run faster in bootstraps.


the name of the estimator to use, or "all" to produce all three estimates. See overlapEst for recommendations on which to use.


the number of cores to use for parallel processing. If NA, all but one of the available cores will used. Parallel processing may take longer than serial processing if the bootstrap runs quickly.


a numeric vector of time-of-capture data in radians, ie. on [0, 2\pi] scale

Amat, Bmat

matrices of resampled data for each species produced by resample; see Value below.


The function bootstrap returns a vector of bootstrap estimates. If estimation fails for a bootstrap sample, the corresponding value will be NA.

The function resample returns a numeric matrix with each column corresponding to a bootstrap sample. Times are in radians. It may return a matrix of NAs if smooth = TRUE and bandwidth estimation fails.

Function bootEst with type = "all" returns a numeric matrix with three columns, one for each estimator of overlap, otherwise a vector of bootstrap estimates.


Mike Meredith, including code by Martin Ridout.


Ridout & Linkie (2009) Estimating overlap of daily activity patterns from camera trap data. Journal of Agricultural, Biological, and Environmental Statistics 14:322-337

See Also



est <- overlapEst(tigerObs, pigObs, type="Dhat4")

boots <- bootstrap(tigerObs, pigObs, 99, type="Dhat4", cores=1)
bootCI(est, boots)

# alternatively:
tigSim <- resample(tigerObs, 99)
pigSim <- resample(pigObs, 99)
boots <- bootEst(tigSim, pigSim, type="Dhat4", cores=1)

overlap documentation built on May 29, 2024, 8:31 a.m.