-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathREADME.Rmd
129 lines (96 loc) · 5.99 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
---
output: github_document
editor_options:
chunk_output_type: console
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# fwildclusterboot
<img src="man/figures/logo.png" width="200px" align="right" />
<!-- badges: start -->
<!-- [![packageversion](https://img.shields.io/badge/Package%20version-`r version`-orange.svg?style=flat-square)](commits/master) -->
[![Status at rOpenSci Software Peer Review](https://badges.ropensci.org/546_status.svg)](https://github.com/ropensci/software-review/issues/546)
[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![CRAN status](https://www.r-pkg.org/badges/version/fwildclusterboot)](https://CRAN.R-project.org/package=fwildclusterboot)
![runiverse-package](https://s3alfisc.r-universe.dev/badges/fwildclusterboot)
[![R-CMD-check](https://github.com/s3alfisc/fwildclusterboot/workflows/R-CMD-check/badge.svg)](https://github.com/s3alfisc/fwildclusterboot/actions)
[![Codecov test coverage](https://codecov.io/gh/s3alfisc/fwildclusterboot/branch/master/graph/badge.svg)](https://app.codecov.io/gh/s3alfisc/fwildclusterboot?branch=master)
`r badger::badge_cran_download("fwildclusterboot", "grand-total", "blue")`
`r badger::badge_cran_download("fwildclusterboot", "last-month", "green")`
<!-- badges: end -->
The `{fwildclusterboot}` package implements multiple fast wild cluster bootstrap algorithms as developed in [Roodman et al (2019)](https://econpapers.repec.org/paper/qedwpaper/1406.htm) and [MacKinnon, Nielsen & Webb (2022)](https://www.econ.queensu.ca/sites/econ.queensu.ca/files/wpaper/qed_wp_1485.pdf).
Via the [JuliaConnectoR](https://CRAN.R-project.org/package=JuliaConnectoR), `{fwildclusterboot}` further ports functionality of [WildBootTests.jl](https://github.com/droodman/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!
```{r, fig.width=10, fig.height=3, echo = FALSE, warning = FALSE, message = FALSE}
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
```
```{r, fig.width=10, fig.height=3, echo = FALSE, warning = FALSE, message = FALSE}
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:
+ The wild bootstrap for OLS (Wu 1986).
+ The wild cluster bootstrap for OLS (Cameron, Gelbach & Miller 2008, Roodman et al, 2019).
+ Multiple new versions of the wild cluster bootstrap as described in MacKinnon, Nielsen & Webb (2022), including the WCR13 (WCR-V), WCR31 (WCR-S), WCR33 (WCR-B), WCU13 (WCU-V), WCU31 (WCU-S) and WCU33 (WCU-B).
+ 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`:
+ Highly optimized versions of the '11' and '31' wild cluster bootstrap variants
+ A highly optimized version of the Wild Restricted Efficient bootstrap (WRE) for IV/2SLS/LIML [(Davidson & MacKinnon, 2010)](https://www.tandfonline.com/doi/abs/10.1198/jbes.2009.07221).
+ 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).
### Installation
You can install compiled versions of`{fwildclusterboot}` from CRAN (compiled), R-universe (compiled) or github by following one of the steps below:
```{r, eval = FALSE}
# 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")
```
### The `boottest()` function
For a longer introduction to `{fwildclusterboot}`, take a look at the [vignette](https://s3alfisc.github.io/fwildclusterboot/articles/fwildclusterboot.html).
```{r, warning = FALSE, message = FALSE}
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)
```
## Citation
If you are in `R`, you can simply run the following command to get the BibTeX citation for `{fwildclusterboot}`:
```{r, warning = FALSE, message = FALSE}
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 =) !