Convenience wrapper for calculating bootstrap confidence intervals for univariate and bivariate statistics.

BootCI(x, y = NULL, FUN, ..., bci.method = c("norm", "basic", "stud", "perc", "bca"),
       conf.level = 0.95, sides = c("two.sided", "left", "right"), R = 999)

Arguments

x

a (non-empty) numeric vector of data values.

y

NULL (default) or a vector with compatible dimensions to x, when a bivariate statistic is used.

FUN

the function to be used

bci.method

A vector of character strings representing the type of intervals required. The value should be any subset of the values "norm", "basic", "stud", "perc", "bca", as it is passed on as method to boot.ci.

conf.level

confidence level of the interval.

sides

a character string specifying the side of the confidence interval, must be one of "two.sided" (default), "left" or "right". You can specify just the initial letter. "left" would be analogue to a hypothesis of "greater" in a t.test.

...

further arguments are passed to the function FUN.

R

The number of bootstrap replicates. Usually this will be a single positive integer. For importance resampling, some resamples may use one set of weights and others use a different set of weights. In this case R would be a vector of integers where each component gives the number of resamples from each of the rows of weights.

Value

a named numeric vector with 3 elements:

est

the specific estimate, as calculated by FUN

lwr.ci

lower bound of the confidence interval

upr.ci

upper bound of the confidence interval

Author

Andri Signorell <andri@signorell.net>

See also

Examples

set.seed(1984)
BootCI(d.pizza$temperature, FUN=mean, na.rm=TRUE, bci.method="basic")
#>     mean   lwr.ci   upr.ci 
#> 47.93667 47.37436 48.49182 
BootCI(d.pizza$temperature, FUN=mean, trim=0.1, na.rm=TRUE, bci.method="basic")
#>     mean   lwr.ci   upr.ci 
#> 48.98024 48.39139 49.58832 

BootCI(d.pizza$temperature, FUN=Skew, na.rm=TRUE, bci.method="basic")
#>       Skew     lwr.ci     upr.ci 
#> -0.8418683 -0.9426134 -0.7522838 

BootCI(d.pizza$operator, d.pizza$area, FUN=CramerV)
#>    CramerV     lwr.ci     upr.ci 
#> 0.08670047 0.04138136 0.11738513 

spearman <- function(x,y) cor(x, y, method="spearman", use="p")
BootCI(d.pizza$temperature, d.pizza$delivery_min, FUN=spearman)
#>   spearman     lwr.ci     upr.ci 
#> -0.5734425 -0.6181943 -0.5275981