Learn R Programming

⚠️There's a newer version (0.13.0) of this package.Take me there.

fwildclusterboot

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 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.

library(fwildclusterboot)

# set seed via dqset.seed for boot_algo = "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", seed = 1)
summary(lm_boot)
#> 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

Installation

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 
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")

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.

devtools::install_github("s3alfisc/JuliaConnectoR.utils")
library(JuliaConnectoR.utils)
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

Copy Link

Version

Install

install.packages('fwildclusterboot')

Monthly Downloads

109

Version

0.9

License

GPL-3

Maintainer

Alexander Fischer

Last Published

June 10th, 2022

Functions in fwildclusterboot (0.9)

cpp_get_nb_threads

Get maximum number of threads on hardware for open mp support
mboottest.lm

Fast wild cluster bootstrap inference of joint hypotheses for object of class lm
mboottest.fixest

Fast wild cluster bootstrap inference for joint hypotheses for object of class fixest
model_matrix

enhanced model.matrix functionalities
model_matrix.felm

Enhanced model.matrix for objects of type felm
boottest.ivreg

Fast wild cluster bootstrap inference for object of class lm
create_data

Simulate Data
boot_ssc

set the small sample correction factor applied in boottest()
boottest.fixest

Fast wild cluster bootstrap inference for object of class fixest
mboottest

Arbitrary Linear Hypothesis Testing for Regression Models via Wald-Tests
mboottest.felm

Fast wild cluster bootstrap inference for joint hypotheses for object of class felm
get_seed

creates an integer based on the global random seed set via set.seed() for using set.seed() for controlling rcpp's seed, see this blog post http://rorynolan.rbind.io/2018/09/30/rcsetseed/
model_matrix.lm

Enhanced model.matrix for objects of type lm
get_bootstrap_pvalue

get bootstrapped p-value based on bootstrapped t-stats
model_matrix.fixest

Enhanced model.matrix for objects of type fixest
boottest

Fast wild cluster bootstrap inference
boottest.lm

Fast wild cluster bootstrap inference for object of class lm
get_ssc

Compute small sample adjustment factors
summary.boottest

S3 method to summarize objects of class boottest
setBoottest_boot_algo

Sets the bootstrap algo to be run via boottest() and waldboottest()
glance.boottest

S3 method to glance at objects of class boottest
tidy.boottest

S3 method to summarize objects of class boottest into tidy data.frame
summary.mboottest

S3 method to summarize objects of class mboottest
voters

Random example data set
boot_algo2

Fast wild cluster bootstrap algorithm
boot_algo1

Fast wild cluster bootstrap algorithm
.onLoad

setting options for nthreads when package is loaded
eigenMapMatMult

Matrix Multiplication via Eigen
plot.boottest

Plot the bootstrap distribution of t-statistics
preprocess2

Fast wild cluster bootstrap inference
tidy.mboottest

S3 method to summarize objects of class mboottest into tidy data.frame
to_integer

Transform vectors of all types safely to integer vectors
boottest.felm

Fast wild cluster bootstrap inference for object of class felm