Skip to contents

The fwildclusterboot package provides a native R implementation of the fast wild cluster bootstrap algorithm developed in Roodman et al (2019) for regression objects in R.

It also ports functionality of WildBootTests.jl to R via the JuliaConnectoR.

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!

fwildclusterboot supports the following features:

  • The wild bootstrap for OLS (Wu 1986).
  • The wild cluster bootstrap for OLS (Cameron, Gelbach & Miller 2008, Roodman et al, 2019)
  • The subcluster bootstrap (MacKinnon and Webb 2018).
  • Confidence intervals formed by inverting the test and iteratively searching for bounds.
  • Multiway clustering.
  • One-way fixed effects.

Additional features are provided through WildBootTests.jl:

  • The Wild Restricted Efficient bootstrap (WRE) for IV/2SLS/LIML (Davidson & MacKinnon, 2010).
  • Arbitrary and multiple linear hypotheses in the parameters.

fwildclusterboot supports the following models:

  • OLS: lm (from stats), fixest (from fixest), felm from (lfe)
  • IV: ivreg (from ivreg).

The boottest() function

For a longer introduction to fwildclusterboot, take a look at the vignette.


# set seed via dqset.seed for boot_algo = "R" & Rademacher, Webb & Normal weights
# set 'familiar' seed for all other algorithms and weight types 


# 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", seed = 1)
#> boottest.lm(object = lm_fit, param = "treatment", B = 9999, clustid = c("group_id1"), 
#>     seed = 1)
#>  Hypothesis: 1*treatment = 0
#>  Observations: 300
#>   Bootstr. Type: rademacher
#>  Clustering: 1-way
#>  Confidence Sets: 95%
#>  Number of Clusters: 40
#>              term estimate statistic p.value conf.low conf.high
#> 1 1*treatment = 0    0.079     3.983       0     0.04     0.118


You can install compiled versions offwildclusterboot from CRAN and the development version from R-universe (compiled) or github by following one of the steps below:

# from CRAN 
# from r-universe (windows & mac, compiled R > 4.0 required)
install.packages('fwildclusterboot', repos ='')
# dev version from github
# note: installation requires Rtools

To run WildBootTests.jl through fwildclusterboot, Julia and WildBootTests.jl need to be installed.

You can install Julia by following the steps described on the official Julia homepage. WildBootTests.jl can then be installed via Julia’s package management system.

To help you connect Julia and R via the JuliaConnectoR and to install WildBootTests.jl from within R, you can alternatively use the JuliaConnectoR.utils package.

connect_julia_r() # instructions to connect Julia and R
install_julia_packages("WildBootTests.jl") # install WildBootTests.jl
set_julia_nthreads() # instructions to set nthreads for Julia