knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
r badger::badge_cran_download("fwildclusterboot", "grand-total", "blue")
r badger::badge_cran_download("fwildclusterboot", "last-month", "green")
The {fwildclusterboot}
package implements multiple fast wild cluster bootstrap algorithms as developed in Roodman et al (2019) and MacKinnon, Nielsen & Webb (2022).
Via the JuliaConnectoR, {fwildclusterboot}
further ports functionality of WildBootTests.jl - which provides an even faster implementation of the wild cluster bootstrap for OLS and supports the WRE bootstrap for IV and tests of multiple joint hypotheses.
The package's central function is boottest()
. It allows to test univariate hypotheses using a wild cluster bootstrap at extreme speed: via the 'fast' algorithm, it is possible to run a wild cluster bootstrap with $B = 100.000$ iterations in less than a second!
library(ggplot2) df <- readRDS("C:/Users/alexa/Dropbox/R package development/fwildclusterboot develop/benchmarks/r_comparions.rds") df$B <- factor(df$B, levels = c("10K", "100K")) df$N_G <- factor(df$N_G, levels = c("N_G = 20", "N_G = 50", "N_G = 100", "N_G = 500", "N_G = 1000")) df$`boot algo` <- df$type
ggplot(data = df, aes(x = B, y = time, color = `boot algo`)) + facet_wrap(~N_G, nrow = 1) + geom_point() + scale_y_continuous(trans='log10') + labs(title = "Benchmarks", caption = "N = 10_000, k = 20 covariates and one cluster of dimension N_G (3 iterations each, median runtime is plotted).")+ #theme_bw() + xlab("Bootstrap iterations") + ylab("time in seconds, log scale") + theme_bw()
{fwildclusterboot}
supports the following features:
Additional features are provided through WildBootTests.jl
:
{fwildclusterboot}
supports the following models:
lm
(from stats), fixest
(from fixest), felm
from (lfe)ivreg
(from ivreg). You can install compiled versions of{fwildclusterboot}
from CRAN (compiled), R-universe (compiled) or github by following one of the steps below:
# from CRAN install.packages("fwildclusterboot") # from r-universe (windows & mac, compiled R > 4.0 required) install.packages('fwildclusterboot', repos ='https://s3alfisc.r-universe.dev') # dev version from github # note: installation requires Rtools library(devtools) install_github("s3alfisc/fwildclusterboot")
boottest()
functionFor a longer introduction to {fwildclusterboot}
, take a look at the vignette.
library(fwildclusterboot) # set seed via dqset.seed for engine = "R" & Rademacher, Webb & Normal weights dqrng::dqset.seed(2352342) # set 'familiar' seed for all other algorithms and weight types set.seed(23325) data(voters) # fit the model via fixest::feols(), lfe::felm() or stats::lm() lm_fit <- lm(proposition_vote ~ treatment + log_income + as.factor(Q1_immigration) + as.factor(Q2_defense), data = voters) # bootstrap inference via boottest() lm_boot <- boottest(lm_fit, clustid = c("group_id1"), B = 9999, param = "treatment") summary(lm_boot)
If you are in R
, you can simply run the following command to get the BibTeX citation for {fwildclusterboot}
:
citation("fwildclusterboot")
Alternatively, if you prefer to cite the "Fast & Wild" paper by Roodman et al, it would be great if you mentioned {fwildclusterboot}
in a footnote =) !
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.