knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(fwildclusterboot) library(fixest) set.seed(34345) dqrng::dqset.seed(123) data(voters)
boottest()
supports multiple features of the advanced formula syntax of the fixest
package, as e.g. multiple estimations.
feols_fit <- feols(proposition_vote ~ i(treatment, ideology1) , data = voters ) boot1 <- boottest(feols_fit, B = 9999, param = "treatment::0:ideology1", clustid = "group_id1" ) boot1
It is possible to loop through different regression specifications. For example, to run boottest()
over a fixest_multi
object created via the sw()
function:
feols_fits <- fixest::feols( proposition_vote ~ treatment | sw(Q1_immigration, Q2_defense), data = voters ) boot2 <- lapply( feols_fits, \(x) boottest( x, B = 999, param = "treatment", clustid = "group_id1") ) boot2
Similarly, it is possible to loop over objects of fixest_multi
created by subset
functionality:
voters$split <- sample(1:2, nrow(voters), TRUE) feols_fits <- fixest::feols( proposition_vote ~ treatment, split = ~split, data = voters ) boot3 <- lapply( feols_fits, \(x) boottest( x, B = 999, param = "treatment", clustid = "group_id1" ) ) boot3
And of course it is also possible to combine multiple "syntactic sugar" features of fixest
:
feols_fits <- fixest::feols( proposition_vote ~ treatment | sw(Q1_immigration, Q2_defense), split = ~split, data = voters ) boot4 <- lapply( feols_fits, \(x) boottest( x, B = 999, param = "treatment", clustid = "group_id1" ) ) boot4
As a rule of thumb, every transformation of fixed effects is not supported. This includes interaction via ^
and varying slopes syntax via var1[var2]
. If you try this, you should receive an error message, and if not, please open an issue on github =) .
Fixed effect interactions via ^
lead to an error. Fixing this is on my backlog but currently not highest priortiy. Send me a message if this causes you large headaches!
feols_fit2 <- feols(proposition_vote ~ treatment | Q1_immigration^Q2_defense, data = voters ) # leads to an error boot1 <- boottest(feols_fit2, B = 9999, param = "treatment", clustid = "group_id1" ) # Error in `check_boottest_args_plus()` at fwildclusterboot/R/boottest_fixest.R:514:2: # ! Advanced formula notation in fixest / fixest via ^ to interact # fixed effects is currently not supported in boottest().
Relatedly, varying slopes fixed effects syntax is not supported:
feols_fit3 <- feols(proposition_vote ~ treatment | Q1_immigration[log_income], data = voters ) # leads to an error boot <- boottest(feols_fit3, B = 9999, param = "treatment", clustid = "group_id1" ) # Error in `check_boottest_args_plus()` at fwildclusterboot/R/boottest_fixest.R:514:2: # ! Varying slopes in fixest / fixest via [] to interact # fixed effects is currently not supported in boottest().
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.