| Title: | Bias Corrected Bootstrap Confidence Intervals |
|---|---|
| Description: | Computation of bootstrap confidence intervals in an almost automatic fashion as described in Efron and Narasimhan (2020, <doi:10.1080/10618600.2020.1714633>). |
| Authors: | Bradley Efron [aut], Balasubramanian Narasimhan [aut, cre] |
| Maintainer: | Balasubramanian Narasimhan <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 1.0 |
| Built: | 2026-10-16 21:49:35 UTC |
| Source: | https://github.com/bnaras/bcaboot |
Bootstrap confidence intervals depend on three elements: (a) the cumulative distribution of the bootstrap replications, (b) the bias-correction, and (c) the acceleration number that measures the rate of change in the standard deviation of the estimate as the data changes. The first two of these depend only on the bootstrap distribution, and not how it is generated: parametrically or non-parametrically. Therefore, the only difference in a parametric bca analysis would lie in the nonparametric estimation of the acceleration, often a negligible error.
Maintainer: Balasubramanian Narasimhan [email protected]
Authors:
Bradley Efron [email protected]
Useful links:
Report bugs at https://github.com/bnaras/bcaboot/issues
Creates a ggplot showing BCa and standard confidence intervals across coverage levels.
## S3 method for class 'bcaboot' autoplot(object, ...)## S3 method for class 'bcaboot' autoplot(object, ...)
object |
A |
... |
Ignored. |
A ggplot object.
## Not run: data(diabetes, package = "bcaboot") Xy <- cbind(diabetes$x, diabetes$y) rfun <- function(Xy) { y <- Xy[, 11]; X <- Xy[, 1:10] summary(lm(y ~ X))$adj.r.squared } set.seed(1234) result <- bca_nonpar(Xy, 1000, rfun, n_groups = 34, verbose = FALSE) autoplot(result) ## End(Not run)## Not run: data(diabetes, package = "bcaboot") Xy <- cbind(diabetes$x, diabetes$y) rfun <- function(Xy) { y <- Xy[, 11]; X <- Xy[, 1:10] summary(lm(y ~ X))$adj.r.squared } set.seed(1234) result <- bca_nonpar(Xy, 1000, rfun, n_groups = 34, verbose = FALSE) autoplot(result) ## End(Not run)
Computes nonparametric bias-corrected and accelerated (BCa) bootstrap
confidence intervals. Consolidates the functionality of the deprecated
bcajack, bcajack2, and bcanon functions.
bca_nonpar( x, B, func, ..., accel = c("regression", "jackknife"), conf.level = c(0.95, 0.9, 0.8, 0.68), n_groups = nrow(x), group_reps = 5, kl_fraction = 0.333, n_jack = 2, jack_groups = 12, boot_data = NULL, verbose = TRUE )bca_nonpar( x, B, func, ..., accel = c("regression", "jackknife"), conf.level = c(0.95, 0.9, 0.8, 0.68), n_groups = nrow(x), group_reps = 5, kl_fraction = 0.333, n_jack = 2, jack_groups = 12, boot_data = NULL, verbose = TRUE )
x |
An |
B |
Number of bootstrap replications (integer). |
func |
Function computing the parameter of interest.
|
... |
Additional arguments passed to |
accel |
Method for estimating acceleration:
|
conf.level |
Confidence levels for the intervals (e.g.,
|
n_groups |
Number of groups for jackknife. Default |
group_reps |
When |
kl_fraction |
Fraction of bootstrap count vectors nearest to
uniform used in the local regression. Only used with
|
n_jack |
Number of delete-d jackknife repetitions for estimating internal (Monte Carlo) standard error. Set to 0 to skip. |
jack_groups |
Number of groups per jackknife fold. |
boot_data |
Optional pre-computed bootstrap data: a list with
components |
verbose |
Logical; show progress bar during bootstrap. |
An object of class "bcaboot" with components:
9-row matrix of confidence limits (columns: bca,
jacksd, std, pct)
2-row matrix of estimates and jackknife SEs (columns:
theta, sdboot, z0, a, sdjack)
Bootstrap sample size and mean of replicates
Bias-corrected estimator and its SE
gbca diagnostic (when accel = "regression")
Efron B (1987). Better bootstrap confidence intervals. JASA 82, 171-200.
Efron B and Narasimhan B (2020). The Automatic Construction of Bootstrap Confidence Intervals. Journal of Computational and Graphical Statistics, 29(3), 608-619. doi:10.1080/10618600.2020.1714633
data(diabetes, package = "bcaboot") Xy <- cbind(diabetes$x, diabetes$y) rfun <- function(Xy) { y <- Xy[, 11] X <- Xy[, 1:10] summary(lm(y ~ X))$adj.r.squared } set.seed(1234) result <- bca_nonpar(x = Xy, B = 1000, func = rfun, n_groups = 34, verbose = FALSE) print(result)data(diabetes, package = "bcaboot") Xy <- cbind(diabetes$x, diabetes$y) rfun <- function(Xy) { y <- Xy[, 11] X <- Xy[, 1:10] summary(lm(y ~ X))$adj.r.squared } set.seed(1234) result <- bca_nonpar(x = Xy, B = 1000, func = rfun, n_groups = 34, verbose = FALSE) print(result)
Computes parametric bootstrap confidence intervals for a real-valued parameter theta in a p-parameter exponential family.
bca_par( t0, tt, bb, conf.level = c(0.95, 0.9, 0.8, 0.68), n_jack = 6, jack_groups = 10, truncation = 0.001, kl_fraction = 0.333, conf_density = FALSE, func )bca_par( t0, tt, bb, conf.level = c(0.95, 0.9, 0.8, 0.68), n_jack = 6, jack_groups = 10, truncation = 0.001, kl_fraction = 0.333, conf_density = FALSE, func )
t0 |
Observed estimate of theta, usually by maximum likelihood. |
tt |
A vector of B parametric bootstrap replications of theta. |
bb |
A B by p matrix of natural sufficient vectors, where p is the dimension of the exponential family. |
conf.level |
Confidence levels for the intervals. |
n_jack |
Number of jackknife repetitions for internal SE. Set to 0 to skip. |
jack_groups |
Number of groups per jackknife fold. |
truncation |
Truncation parameter for acceleration calculation. Can be a vector to compute acceleration at multiple levels. |
kl_fraction |
Proportion of "nearby" b vectors used in gradient estimation. |
conf_density |
Logical; if TRUE, return BCa confidence density weights. |
func |
Optional function for ABC (analytical bootstrap) limits. |
An object of class "bcaboot" with components:
9-row matrix of confidence limits
2-row matrix of estimates and jackknife SEs
Bootstrap sample size and mean of replicates
Bias-corrected estimator and its SE
ABC limits and stats (when func provided)
Confidence density weights (when requested)
Acceleration at multiple truncation levels
Efron B (1987). Better bootstrap confidence intervals. JASA 82, 171-200.
DiCiccio T and Efron B (1992). More accurate confidence intervals in exponential families. Biometrika, 231-245.
Efron B and Narasimhan B (2020). The Automatic Construction of Bootstrap Confidence Intervals. Journal of Computational and Graphical Statistics, 29(3), 608-619. doi:10.1080/10618600.2020.1714633
data(diabetes, package = "bcaboot") X <- diabetes$x y <- scale(diabetes$y, center = TRUE, scale = FALSE) lm.model <- lm(y ~ X - 1) mu.hat <- lm.model$fitted.values sigma.hat <- stats::sd(lm.model$residuals) t0 <- summary(lm.model)$adj.r.squared y.star <- sapply(mu.hat, rnorm, n = 500, sd = sigma.hat) tt <- apply(y.star, 1, function(y) summary(lm(y ~ X - 1))$adj.r.squared) b.star <- y.star %*% X set.seed(1234) bca_par(t0 = t0, tt = tt, bb = b.star)data(diabetes, package = "bcaboot") X <- diabetes$x y <- scale(diabetes$y, center = TRUE, scale = FALSE) lm.model <- lm(y ~ X - 1) mu.hat <- lm.model$fitted.values sigma.hat <- stats::sd(lm.model$residuals) t0 <- summary(lm.model)$adj.r.squared y.star <- sapply(mu.hat, rnorm, n = 500, sd = sigma.hat) tt <- apply(y.star, 1, function(y) summary(lm(y ~ X - 1))$adj.r.squared) b.star <- y.star %*% X set.seed(1234) bca_par(t0 = t0, tt = tt, bb = b.star)
The diabetes data frame has 442 rows and 3 columns. These are the
data used in the Efron et al "Least Angle Regression" paper.
This data frame contains the following columns:
x a matrix with 10 columns
y a numeric vector
x2 a matrix with 64 columns
The x matrix has been standardized to have unit L2 norm in each column and zero mean. The matrix x2 consists of x plus certain interactions.
https://web.stanford.edu/~hastie/Papers/LARS/LeastAngle_2002.pdf
Efron, Hastie, Johnstone and Tibshirani (2003) "Least Angle Regression" (with discussion) Annals of Statistics
Returns a one-row tibble summarizing the bootstrap run.
## S3 method for class 'bcaboot' glance(x, ...)## S3 method for class 'bcaboot' glance(x, ...)
x |
A |
... |
Ignored. |
A tibble with columns:
"nonpar" or "par"
Acceleration method ("regression", "jackknife", or NA)
Point estimate
Bootstrap standard error
Bias-correction constant
Acceleration constant
Jackknife standard error (if available)
Number of bootstrap replicates
Mean of bootstrap replicates
data(diabetes, package = "bcaboot") Xy <- cbind(diabetes$x, diabetes$y) rfun <- function(Xy) { y <- Xy[, 11]; X <- Xy[, 1:10] summary(lm(y ~ X))$adj.r.squared } set.seed(1234) result <- bca_nonpar(Xy, 1000, rfun, n_groups = 34, verbose = FALSE) glance(result)data(diabetes, package = "bcaboot") Xy <- cbind(diabetes$x, diabetes$y) rfun <- function(Xy) { y <- Xy[, 11]; X <- Xy[, 1:10] summary(lm(y ~ X))$adj.r.squared } set.seed(1234) result <- bca_nonpar(Xy, 1000, rfun, n_groups = 34, verbose = FALSE) glance(result)
Returns a tibble with one row per (confidence level, method) combination, following broom conventions.
## S3 method for class 'bcaboot' tidy(x, ...)## S3 method for class 'bcaboot' tidy(x, ...)
x |
A |
... |
Ignored. |
A tibble with columns:
Confidence level (e.g. 0.95)
"bca" or "standard" (or "abc" when available)
Point estimate (theta)
Lower confidence limit
Upper confidence limit
Jackknife SE of lower limit (BCa only; NA otherwise)
Jackknife SE of upper limit (BCa only; NA otherwise)
data(diabetes, package = "bcaboot") Xy <- cbind(diabetes$x, diabetes$y) rfun <- function(Xy) { y <- Xy[, 11]; X <- Xy[, 1:10] summary(lm(y ~ X))$adj.r.squared } set.seed(1234) result <- bca_nonpar(Xy, 1000, rfun, n_groups = 34, verbose = FALSE) tidy(result)data(diabetes, package = "bcaboot") Xy <- cbind(diabetes$x, diabetes$y) rfun <- function(Xy) { y <- Xy[, 11]; X <- Xy[, 1:10] summary(lm(y ~ X))$adj.r.squared } set.seed(1234) result <- bca_nonpar(Xy, 1000, rfun, n_groups = 34, verbose = FALSE) tidy(result)