Bootstrapping is a widely applicable technique for statistical estimation, especially in the absence of closed-form solutions.
- Bootstrapping statistics with different sampling methods:
- Random resampling with replacement (the
boot_basic
bootstrap) - Random weighted resampling with replacement (the
boot_weight
bootstrap) - Balanced random resampling, reducing the bias (the
boot_balanced
bootstrap) - Exact resampling, iterating through all unique samples (the
boot_exact
, deterministic bootstrap, suited only for small samples sizes)
- Random resampling with replacement (the
- Confidence intervals:
- Basic (the
ci_basic
method) - Percentile (the
ci_perc
method) - Normal distribution (the
ci_normal
method) - Bias-corrected and accelerated (BCa) (the
ci_bca
method)
- Basic (the
This example illustrates the basic usage and cornerstone functions of the package. More elaborate cases are covered in the documentation notebooks.
using Bootstrap
Our observations r
are sampled from a standard normal distribution.
r = randn(50);
Let’s bootstrap the standard deviation (std
) of our data, based on 1000
resamples and with different bootstrapping approaches.
n_boot = 1000;
## basic bootstrap
bs1 = boot_basic(r, std, n_boot);
## balanced bootstrap
bs2 = boot_balanced(r, std, n_boot);
We can explore the properties of the bootstrapped samples, for example estimated bias and standard error of our statistic.
bias(bs1)
se(bs1)
Further, we can estimate confidence intervals for our statistic of interest, based on the bootstrapped samples.
## 95% confidence intervals
cil = 0.95;
## basic CI
bci1 = ci_basic(bs1, cil);
## percentile CI
bci2 = ci_perc(bs1, cil);
## BCa CI
bci3 = ci_bca(bs1, cil);
interval(bci1)
The bootstrapping wikipdia article is a comprehensive summary of the topic. An extensive description of the bootstrap is the focus of the book ‘Davison and Hinkley (1997): Bootstrap Methods and Their Application. Cambridge University Press’. Most of the methodology covered in the book is implemented in the boot package for the R programming language.