bootCI calculates five different confidence intervals from bootstrap samples: see details:
bootCIlogit calculates corrections on the logit scale and back-transforms.
the statistic estimated from the original sample
a vector of bootstrap statistics.
a (single!) confidence interval to estimate.
Let t = true value of the statistic,
t0 = estimate of t based on the original sample,
bt = bootstrap estimates.
If bootstrap sampling introduces no bias, E[mean(bt)] = t0, otherwise BS bias = mean(bt) - t0.
Assuming that the original sampling causes the same bias as the bootstrap sampling, we write: mean(bt) - t0 = t0 - t, and hence calculate a bias-corrected estimate, t1 = 2 x t0 - mean(bt).
The percentiles CI, “perc”, gives quantiles of the bootstrap values, interpolated if necessary. However, in general, the bootstrap estimates are biased, so “perc” should be corrected.
“basic” is a bias-corrected version of “perc”, analogous to t1: 2 x t0 -
“norm” gives tail cutoffs for a normal distribution with mean = t1 and sd = sd(bt).
These three are equivalent to the confidence intervals returned by
boot::boot.ci. “basic” and “norm” are appropriate if you are using the bias-corrected estimator, t1. If you use the uncorrected estimator, t0, you should use “basic0” or “norm0”:
perc - mean(bt) + t0.
“norm0” gives tail cutoffs as before, but with mean = t0 instead of t1.
The "logit" versions perform the corrections on the logit scale and then back transform. This would be appropriate for probabilities or proportions.
A named matrix with 2 columns for lower and upper limits and a row for each type of estimate. Values will be NA if the bootstrap sample is too small (after removing NAs) for estimation: 40 is the minimum for a 95% confidence interval, 200 for 99% (though for stable estimates you need at least 999 bootstrap estimates, preferably 10,000).
boot.ci in package
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# Generate some sample data: set.seed(123) dat <- runif(20) t0 <- sd(dat) # and 999 nonparametric bootstrap estimates: bootmat <- matrix(sample(dat, 20*999, replace=TRUE), 20, 999) bt <- apply(bootmat, 2, sd) mean(bt) mean(bt) - t0 # bootstrap bias bootCI(t0, bt) bootCIlogit(t0, bt) bootCI(t0, bt, conf=0.05) # Which of these 5% CIs include the point estimate, t0? bootCI(t0, bt, conf=0.05) < t0 # Should be "TRUE FALSE"