Resamples observations with replacement and computes a confidence
interval via the percentile, normal, basic, BCa, or studentized
method. Delegates the resampling loop and CI computation to
boot::boot and boot::boot.ci when the boot
package is installed. Falls back to an inline implementation
otherwise so the wrapper keeps working on minimal installs.
Stratified and cluster resamples are supported in both arms.
Usage
bootstrap(
data,
statistic,
n_boot = 2000L,
ci_level = 0.95,
ci_method = "bca",
seed = 42L,
stratify = NULL,
cluster = NULL
)Arguments
- data
A numeric vector or matrix of observations.
- statistic
Function of one argument that returns a scalar.
- n_boot
Number of bootstrap replicates (default 2000).
- ci_level
Confidence level (default 0.95).
- ci_method
One of
"percentile","normal","basic","bca","studentized".- seed
Random seed.
- stratify
Optional vector of stratum labels (length n).
- cluster
Optional vector of cluster labels (length n).