Closed ecrjak closed 1 year ago
Hi, boottest calls Formula::Formula internally. What happens if you specify your models via Formula::Formula instead of stats::Formula? I can't debug right now as not close to a laptop unfortunately.
Using for.reg <- Formula::Formula(proposition_vote ~ treatment + ideology1 + log_income | Q1_immigration)
produces the error message Error in is.name(callee) && length(object) > 20 : 'length = 2' in coercion to 'logical(1)'
It still creates for.reg
but when I use this in boottest
, I get the same error message as in my initial post Error in x$formula : object of type 'symbol' is not subsettable
without creating boot1
.
Thanks, I'll take a closer look this weekend! :)
Hi. Just wanted to quickly check if there are already any updates :)
Sorry, it was a busy week and when I had time, some other projects took priority. Will take a look tomorrow though!
Sorry, just wanted to quickly follow up on this again...
Hi @ecrjak ,
I just took a look: the problem arises in model_matrix.felm.
library("lfe")
data(voters)
for.reg <- formula(proposition_vote ~ treatment + ideology1 + log_income | Q1_immigration)
felm_fit <- felm(for.reg, data = voters)
model.matrix(felm_fit)
lfe:::model.matrix.felm(felm_fit)
Both stats::model_matrix
and lfe::model.matrix.felm
produce this error & I currently don't know best solve it within fwildclusterboot
.
Basically, what happens is that model.matrix
tries to access lfe_fit$call$formula
, which returns for.reg
, which is not a proper formula.
But if you specify your model as
lfe_fit <- felm(formula = for.reg, data = voters)
#lfe_fit$call$formula <- for.reg
boot1 <- boottest(feols_fit,
B = 9999,
param = "treatment",
clustid = "group_id1"
)
i.e. if you name the formula argument, then boottest runs through, at least for me =) I hope that will work for you as well!
Last, I wanted to point you to the formidable fixest
package, which does the same job as lfe
but, in many ways, better (in case you are not yet aware of it).
library(fixest)
feols_fit <- feols(for.reg, data = voters)
boot1 <- boottest(feols_fit,
B = 9999,
param = "treatment",
clustid = "group_id1"
)
summary(boot1)
Is there a patricular reason for which you need to stick with lfe
? The package is no longer developed and only maintained so that it remains on CRAN, and fixest
really is superb (and works well with fwildclusterboot
).
And sorry for the delay!
Best, Alex
Thanks so much for this! Indeed, when explicitly overwriting lfe_fit$call$formula
with the initial formula, the code runs through without any error :)
There is no particular reason for sticking with the lfe
package apart from my own laziness in re-writing the codes for many of my research projects. That said, it seems like fixest
has a lot of interesting stuff to offer and it may be worth starting the transition if lfe
is no longer developed as you say. Thanks for the nudge!
I am encountering issues when running
boottest
afterfelm
but only if I supply theformula
argument indirectly via a formula object (which I do rather frequently in my workflow). When doing so I get an error message sayingError in x$formula : object of type 'symbol' is not subsettable
Here is an illustration using the example from the reference manual. Note that
felm
accepts both versions whereasboottest
doesn't:This works:
This doesn't work:
Thanks a lot in advance for any help!