
Wild bootstrap for linear regression with heteroskedasticity
Source:R/bootstrap_methods.R
wild_bootstrap.RdMultiplies the residuals by random weights (Rademacher or Mammen)
and refits OLS. sandwich::vcovBS implements the standard
wild bootstrap variance-covariance and
fwildclusterboot::boottest adds cluster-wild
p-values; both are cross-referenced here. The inline
implementation is retained because rmorie's API returns the
resampled coefficient distribution (not just a vcov), which is
what downstream MRM analyses consume.
Usage
wild_bootstrap(
y,
X,
statistic_idx = 2L,
n_boot = 999L,
ci_level = 0.95,
weight_distribution = "rademacher",
seed = 42L
)See also
sandwich::vcovBS, fwildclusterboot::boottest,
morie_did_wild_cluster_bootstrap().
Examples
set.seed(1)
X <- cbind(1, rnorm(50)); y <- drop(X %*% c(1, 2)) + rnorm(50)
str(wild_bootstrap(y, X, n_boot = 199L), max.level = 1)
#> List of 11
#> $ estimate : num 1.95
#> $ se : num 0.172
#> $ ci_lower : num 1.67
#> $ ci_upper : num 2.31
#> $ bias : num 0.0126
#> $ n_boot : int 199
#> $ method : chr "wild"
#> $ ci_method : chr "percentile"
#> $ boot_distribution: num [1:199] 1.94 1.6 1.91 1.91 2.01 ...
#> $ original_estimate: num 1.95
#> $ acceleration : num 0
#> - attr(*, "class")= chr [1:2] "morie_bootstrap_result" "list"