BCaPercentiles
Description
BCaPercentiles computes a bias-corrected and accelerated (BCa) confidence interval from a bootstrap distribution, the statistic of the original sample(s) and its leave-one-out jackknife values. It returns the interval as a two-row column. It holds the BCa calculation shared by BootCI and BootCompareCI, which differ only in how they compute the jackknife values. Degenerate cases (e.g. every bootstrap value on one side of the original statistic) are left to the caller to catch.
Used by: BootCI, BootCompareCI
Source Code
BCaPercentiles = LAMBDA(
stats, // bootstrap distribution of the statistic
thetaHat, // statistic computed on the original sample(s)
thetaJack, // leave-one-out jackknife pseudo-values of the statistic
[alpha], // total tail probability for the CI (default 0.05 = 95% CI)
LET(
alpha, IF(ISOMITTED(alpha), 0.05, alpha),
B, COUNT(stats),
p0, SUM(--(stats < thetaHat)) / B,
z0, NORM.S.INV(p0), // bias-correction; errors if p0 is 0 or 1 (degenerate case)
thetaBar, AVERAGE(thetaJack),
denom, 6 * SUM((thetaBar - thetaJack) ^ 2) ^ 1.5,
// if the jackknife estimates show no variation, fall back to no acceleration
a, IF(denom = 0, 0, SUM((thetaBar - thetaJack) ^ 3) / denom),
zLo, NORM.S.INV(alpha / 2),
zHi, NORM.S.INV(1 - alpha / 2),
a_1, NORM.S.DIST(z0 + (z0 + zLo) / (1 - a * (z0 + zLo)), TRUE),
a_2, NORM.S.DIST(z0 + (z0 + zHi) / (1 - a * (z0 + zHi)), TRUE),
VSTACK(PERCENTILE.INC(stats, a_1), PERCENTILE.INC(stats, a_2))
)
);