s3alfisc / fwildclusterboot

Fast Wild Cluster Bootstrap Inference for Regression Models / OLS in R. Additionally, R port to WildBootTests.jl via the JuliaConnectoR.
https://s3alfisc.github.io/fwildclusterboot/
GNU General Public License v3.0
22 stars 4 forks source link

Individual event study confidence intervals #78

Closed lparisi94 closed 1 year ago

lparisi94 commented 1 year ago

Hello Alex,

First of all thanks for helping develop all these cool R packages!

I have just one small question, is it possible to use this package to wild cluster my standard errors in an event study?

For example, I'm using the following code:

pre_twfe = feols(log_rate ~ i(stimetotreatment, treatment_group, ref = -1) | scode + year, weights = ~population, data = guns)

I would like to get the correct confidence intervals for each estimate individually. Is this possible?

Any help would be highly appreciated! Thank you.

Best,

Luka

s3alfisc commented 1 year ago

Hi Luka,

Thanks for the nice words :) I'm super sorry I did not respond earlier, somehow github did not notify my about your question (at least the app didn't, which I checked over the weekend).

In general yes, this should be possible. You would have to do the following:

Note that I have recently added support for fixest's sunab() estimator, you can find the documentation here.

I hope this helps! Maybe I should add a dedicated vignette that runs through fwildclusterboot's DiD support? Do you think that would be helpful?

Best, Alex

lparisi94 commented 1 year ago

Hello Alex,

No worries, thank you for replying and for the useful code and suggestions. The code works, but as you said I can't seem to find an easy way to plot these coefficients - do you maybe have any further tips for that?

Finally, I am not using the Sun & Abraham estimator in my work. My idea is to use the simple twfe (through feols) and compare my findings with the Callaway and Sant'anna DD estimator. A dedicated vignette would sound helpful!

Thank you again!

Best,

Luka

s3alfisc commented 1 year ago

Unfortunately I don't have an ad hoc solution ad hand - you might have to code it up yourself, e.g. with ggplot2::geom_errorbar() for the confidence intervals. I'll think about this a bit. Maybe you can take some inspiration from the plot_event_study() function from did2s? For getting confidence intervals out of an object of type boottest, you can simply use the confint() extractor method.

lparisi94 commented 1 year ago

Thank you for all of your good suggestions and help. I will try to implement this and if I have any additional problems I will let you know.

Thanks again!

L.