fwildclusterboot 0.8
CRAN release: 2022-04-18
Two new bootstrap algorithms: ‘WildBootTests.jl’ and ‘R-lean’
boot_algo = ‘WildBootTests.jl’
-
fwildclusterboot
now supports calling WildBootTests.jl, which is a very fast Julia implementation of the wild cluster bootstrap algorithm. To do so, a new function argument is introduced,boot_algo
, through which it is possible to control the executed bootstrap algorithm.
# load data set voters included in fwildclusterboot
data(voters)
# estimate the regression model via lm
lm_fit <- lm(proposition_vote ~ treatment + ideology1 + log_income + Q1_immigration , data = voters)
boot_lm <- boottest(
lm_fit,
clustid = "group_id1",
param = "treatment",
B = 9999,
boot_algo = "WildBootTests.jl"
)
WildBootTests.jl is (after compilation) orders of magnitudes faster than
fwildclusterboot's
native R implementation, and speed gains are particularly pronounced for large problems with a large number of clusters and many bootstrap iterations.Furthermore,
WildBootTests.jl
supports a range of models and tests that were previously not supported byfwildclusterboot
: most importantly a) wild cluster bootstrap tests of multiple joint hypotheses and b) the WRE bootstrap by Davidson & MacKinnon for instrumental variables estimation. On top of the cake … the WRE is really fast.
library(ivreg)
data("SchoolingReturns", package = "ivreg")
# drop all NA values from SchoolingReturns
SchoolingReturns <- SchoolingReturns[rowMeans(sapply(SchoolingReturns, is.na)) == 0,]
ivreg_fit <- ivreg(log(wage) ~ education + age + ethnicity + smsa + south + parents14 |
nearcollege + age + ethnicity + smsa + south + parents14, data = SchoolingReturns)
boot_ivreg <- boottest(
object = ivreg_fit,
B = 999,
param = "education",
clustid = "kww",
type = "mammen",
impose_null = TRUE
)
generics::tidy(boot_ivreg)
# term estimate statistic p.value conf.low conf.high
# 1 1*education = 0 0.0638822 1.043969 0.2482482 -0.03152655 0.2128746
For guidance on how to install and run
WildBooTests.jl
, have a look at the associated article.Also, note that running the wild cluster bootstrap through
WildBootTests.jl
is often very memory-efficient.
boot_algo = ‘R-lean’
A key limitation of the vectorized ‘fast’ cluster bootstrap algorithm as implemented in fwildclusterboot
is that it is very memory-demanding. For ‘larger’ problems, running boottest()
might lead to out-of-memory errors. To offer an alternative, boottest()
now ships a ‘new’ rcpp- and loop-based implementation of the wild cluster bootstrap (the ‘wild2’ algorithm in Roodman et al).
boot_lm <- boottest(
lm_fit,
clustid = "group_id1",
param = "treatment",
B = 9999,
boot_algo = "R-lean"
)
Heteroskeadstic Wild Bootstrap
It is now possible to run boottest()
without specifying a clustid
function argument. In this case, boottest()
runs a heteroskedasticity-robust wild bootstrap (HC1), which is implemented in c++.
boot_hc1 <- boottest(lm_fit, param = "treatment", B = 9999)
summary(boot_hc1)
boottest()
function argument beta0
deprecated
For consistency with WildBootTests.jl
, the boottest()
function argument beta0
is now replaced by a new function argument, r
.
Frühjahrsputz
I have spent some time to clean up fwildclusterboot's
internals, which should now hopefully be more readable and easier to maintain.
Testing
fwildclusterboot
is now pre-dominantly tested against WildBootTests.jl
. Tests that depend on Julia are by default not run on CRAN, but are regularly run on Mac, Windows and Linux via github actions.
fwildclusterboot 0.6
Bug fix: for one-sided hypotheses for the WRU bootstrap (if impose_null = FALSE), the returned p-values were incorrect - they were reported as ‘p’, but should have been ‘1-p’. E.g. if the reported p-values was reported as 0.4, it should have been reported as 0.6.
A new function argument
ssc
gives more control over the small sample adjustments made withinboottest()
. It closely mirrors thessc
argument infixest
. The only difference is thatfwildclusterboot::boot_ssc()'s
fixef.K
argument currently has only one option,'none'
, which means that the fixed effect parameters are discarded when calculating the number of estimated parameters k. The default argument ofboot_ssc()
areadj = TRUE, fixef.K = "none", cluster.adj = TRUE
andcluster.df = "conventional"
. In fixest, thecluster.df
argument is"min"
by default. Prior to v 0.6, by default, no small sample adjustments regarding the sample size N and the number of estimated parameters k were applied. The changes in v0.6 may slightly affect the output ofboottest()
. For exact reproducibility of previous results, setadj = FALSE
. Settingadj = TRUE
will not affect p-values and confidence intervals for oneway clustering, but the internally calculated t-stat, which is divided by $\sqrt{(N-k)/(N-1)}$. For twoway clustering, it might affect the number and order of invalid bootstrapped t-statistics (due to non-positive definite covariance matrices) and, through this channel, affect bootstrapped inferential parameters.Testing: unit tests are now run on github actions against wildboottestjlr, which is a JuliaConnectoR based wrapper around WildBootTests.jl, a Julia implementation of the fast wild cluster bootstrap algorithm.
Additionally, minor speed tweaks.
fwildclusterboot 0.5.1
CRAN release: 2021-11-06
- Fixes a bug with Mammen weights introduced in version 0.5 -> switch back to
sample()
function. To guarantee reproducibilty with Mammen weights, either a seed needs to be specified inboottest()
or a global seed needs to be set viaset.seed()
. - Deletes some unnecessary computations from boot_algo2() -> speed improvements
- For B = 2^(#number of clusters), Rademacher weights should have been enumerated - instead, they were drawn randomly and enumeration only occured for B > 2^(#number of clusters). Now, enumeration occurs if B >= 2^(#number of clusters).
fwildclusterboot 0.5
CRAN release: 2021-11-03
- Version 0.5 fixes an error for the bootstrap with weighted least squares introduced with version 0.4. All unit tests that compare fwildclusterboot with weighted least squares results from boottest.stata pass. In particular, enumerated cases pass with exact equality (in such cases, the bootstrap weights matrices are exactly identical in both R and Stata).
-
boottest()
now stops iffixest::feols()
deletes non-NA values (e.g. singleton fixed effects deletion) and asks the user to delete such rows prior to estimation viafeols()
&boottest()
. Currently,boottest()'s
pre-processing cannot handle such deletions - this remains future work. - To align
fwildclusterboot
with Stata’s boottest command (Roodman et al, 2019), Mammen weights are no longer enumerated infwildclusterboot::boottest()
. -
boottest()
no longer sets an internal seed (previously set.seed(1)) if no seed is provided as a function argument. - Sampling of the bootstrap weights is now powered by the
dqrng
package, which speeds up the creation of the bootstrap weights matrix. To set a “global” seed, one now has use thedqset.seed()
function from thedqrng package
, which is added as a dependency.
fwildclusterboot 0.3.7
CRAN release: 2021-09-14
- Bug fix: the output of
boottest()
varied depending on the class of the input fixed effects for regressions both vialfe::felm()
andfixest::feols()
. This bug occurred becauseboottest()
does not work with a pre-processed model.frame object from eitherfelm()
orfeols()
but works with the original input data. While bothfelm()
andfeols()
change non-factor fixed effects variables to factors internally,boottest()
did not check but implicitely assumed that all fixed effects used in the regression models are indeed factors in the original data set. As a consequence, if one or more fixed effects were e.g. numeric,boottest()
would produce incorrect results without throwing an error. With version 0.3.7,boottest()
checks internally if all variables in the original data set which are used as fixed effects are factor variables and if not, changes them to factors. Thanks for timotheedotc for raising the issue on github, which can be found here: https://github.com/s3alfisc/fwildclusterboot/issues/14. - Some tests have been added that compare output from
boottest()
with the wild cluster bootstrap implemented viaclusterSEs
.
fwildclusterboot 0.3.6
CRAN release: 2021-08-01
- Bug fix regarding suggested packages and CRAN: see github issue #12. Added
if(requireNamespace("pkgname"))
statements for suggested packages in the vignettes, examples and tests. Note that unit tests will now only execute on CRAN if bothfixest
andlfe
can be installed on the OS.
fwildclusterboot 0.3.5
CRAN release: 2021-06-20
Bug fix: For Rademacher and Mammen weights and cases where (2^ number of clusters) < # boostrap iterations, (deterministic ) full enumeration should have been employed for sampling the bootstrap weights. Full enumeration means the following: for e.g. 6 numbers of clusters, only 2^6 = 64 unique draws from either the Rademacher or Mammen distributions exists. Therefore,
boottest()
overwrites the user-provided number of bootstrap iterations to B = (2^ number of clusters) if a larger number is chosen. The bug now occured because the bootstrap weights were drawn randomly with replacement instead of using full enumeration. Note: full enumeration was introduced with version 0.3.3. Thanks to fschoner for finding the bug! see github issue #11Bug fix: A small bug has been fixed related to missing values in the cluster variables.
By default,
boottest()
now sets an internal seed if no seed is provided by the user via theseed
function argument.Several improvements to the documentation.
fwildclusterboot 0.3.4
CRAN release: 2021-05-01
- Fix CRAN errors caused by a small bug in the vignette
fwildclusterboot 0.3.3
CRAN release: 2021-04-12
- implements full enumeration for Rademacher and Mammen Weights if 2k < B, where k is the number of clusters and B the number of bootstrap iterations
fwildclusterboot 0.3.1
CRAN release: 2021-02-16
- A
glance.boottest()
method was added, which enables the use of themodelsummary
package withfwildclusterboot
. - The
tidy.boottest()
method is no longer exported. You can still access it viafwildclusterboot:::tidy.boottest()
or by loading thegenerics
package vialibrary(generics)
.
fwildclusterboot 0.3.0
- Additional performance improvements through parallelization. By default,
boottest()
uses half the available threads for parallel execution. The number of threads can be set via thenthreads
function argument. - Additional function arguments for
boottest()
- the user can now set the tolerance and maximum number of iterations for the calculation of confidence intervals. By default,tol = 1e-6
andmaxiter = 10
. - The package no longer depends on
data.table
andfabricatr
- both are now only suggested. Further, the package now comes with an example data set ‘voters’.