Package 'bcaboot'

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

Help Index


Automatic Construction of Bootstrap Confidence Intervals

Description

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.

Author(s)

Maintainer: Balasubramanian Narasimhan [email protected]

Authors:

See Also

Useful links:


Plot BCa bootstrap confidence intervals

Description

Creates a ggplot showing BCa and standard confidence intervals across coverage levels.

Usage

## S3 method for class 'bcaboot'
autoplot(object, ...)

Arguments

object

A bcaboot object from bca_nonpar() or bca_par().

...

Ignored.

Value

A ggplot object.

Examples

## 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)

Nonparametric BCa bootstrap confidence intervals

Description

Computes nonparametric bias-corrected and accelerated (BCa) bootstrap confidence intervals. Consolidates the functionality of the deprecated bcajack, bcajack2, and bcanon functions.

Usage

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
)

Arguments

x

An n×pn \times p data matrix. Rows are observed pp-vectors, assumed independently sampled. If p=1p = 1 then x can be a vector.

B

Number of bootstrap replications (integer).

func

Function computing the parameter of interest. func(x, ...) should return a scalar for any data matrix.

...

Additional arguments passed to func.

accel

Method for estimating acceleration: "regression" (default) uses local regression on bootstrap count vectors nearest to uniform; "jackknife" uses classical delete-one (or delete-group) jackknife influence values.

conf.level

Confidence levels for the intervals (e.g., c(0.95, 0.90, 0.80, 0.68)). Only values in ⁠(0, 1)⁠ are used.

n_groups

Number of groups for jackknife. Default nrow(x) gives delete-one jackknife. Set smaller (e.g., 20-40) to speed up computation on large datasets.

group_reps

When n_groups < nrow(x), number of random grouping repetitions to average over. Only used with accel = "jackknife".

kl_fraction

Fraction of bootstrap count vectors nearest to uniform used in the local regression. Only used with accel = "regression". Default 1/3.

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 Y (B x n count matrix), tt (bootstrap replicates), t0 (original estimate). When provided, B is ignored and no resampling is performed.

verbose

Logical; show progress bar during bootstrap.

Value

An object of class "bcaboot" with components:

limits

9-row matrix of confidence limits (columns: bca, jacksd, std, pct)

stats

2-row matrix of estimates and jackknife SEs (columns: theta, sdboot, z0, a, sdjack)

B_mean

Bootstrap sample size and mean of replicates

ustats

Bias-corrected estimator and its SE

diagnostic

gbca diagnostic (when accel = "regression")

References

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

Examples

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)

Parametric BCa bootstrap confidence intervals

Description

Computes parametric bootstrap confidence intervals for a real-valued parameter theta in a p-parameter exponential family.

Usage

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
)

Arguments

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.

Value

An object of class "bcaboot" with components:

limits

9-row matrix of confidence limits

stats

2-row matrix of estimates and jackknife SEs

B_mean

Bootstrap sample size and mean of replicates

ustats

Bias-corrected estimator and its SE

abc

ABC limits and stats (when func provided)

conf_density

Confidence density weights (when requested)

accel_matrix

Acceleration at multiple truncation levels

References

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

Examples

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)

Blood and other measurements in diabetics

Description

The diabetes data frame has 442 rows and 3 columns. These are the data used in the Efron et al "Least Angle Regression" paper.

Format

This data frame contains the following columns:

  • x a matrix with 10 columns

  • y a numeric vector

  • x2 a matrix with 64 columns

Details

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.

Source

https://web.stanford.edu/~hastie/Papers/LARS/LeastAngle_2002.pdf

References

Efron, Hastie, Johnstone and Tibshirani (2003) "Least Angle Regression" (with discussion) Annals of Statistics


Glance at a bcaboot result

Description

Returns a one-row tibble summarizing the bootstrap run.

Usage

## S3 method for class 'bcaboot'
glance(x, ...)

Arguments

x

A bcaboot object from bca_nonpar() or bca_par().

...

Ignored.

Value

A tibble with columns:

method

"nonpar" or "par"

accel

Acceleration method ("regression", "jackknife", or NA)

theta

Point estimate

sdboot

Bootstrap standard error

z0

Bias-correction constant

a

Acceleration constant

sdjack

Jackknife standard error (if available)

B

Number of bootstrap replicates

boot_mean

Mean of bootstrap replicates

Examples

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)

Tidy a bcaboot result

Description

Returns a tibble with one row per (confidence level, method) combination, following broom conventions.

Usage

## S3 method for class 'bcaboot'
tidy(x, ...)

Arguments

x

A bcaboot object from bca_nonpar() or bca_par().

...

Ignored.

Value

A tibble with columns:

conf.level

Confidence level (e.g. 0.95)

method

"bca" or "standard" (or "abc" when available)

estimate

Point estimate (theta)

conf.low

Lower confidence limit

conf.high

Upper confidence limit

jacksd.low

Jackknife SE of lower limit (BCa only; NA otherwise)

jacksd.high

Jackknife SE of upper limit (BCa only; NA otherwise)

Examples

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)