-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can I wild cluster bootstrap this? =) #10
Comments
Hi Alex. Sorry for the super slow response. I've been on vacation and then straight into work travel... I think you're intuition is correct and everything should pass through correctly. However, I must confess, that I haven't thought about this passed reading your comment and the time it's taken to type up this response. I'll let you test (simulate) and decide when is best to close/update ;-) |
Hi Grant, thanks for your feedback! No worries about the delay, I hope you had a relaxing vacation =) I will close this for now and will update you once I manage to implement support for the wcb and etwfe + have some simulations at hand that look promising! |
Hi all! Checking into this issue to see if there was any progress. I tried doing this myself but got an error. |
Hi @jtorcasso - I have never looked into this in more detail. But it should definitely be possible, and if I understand everything correctly, implementing support for the wild cluster bootstrap / In principle, there are two options how to add support for wild cluster bootstrapping to |
Also, just to point this out again - if the Sun-Abrams method is also appropriate for your use case, boot_aggregate does support the wcb for |
Ok, I took a quick look at this, there are (at least) two issues:
|
Actually, here is a hacky preliminary solution, in five steps, which works without the PR to
library(etwfe)
library(fixest)
library(fwildclusterboot)
data("mpdta", package="did")
head(mpdta)
mod = etwfe(
fml = lemp ~ lpop,
tvar = year,
gvar = first.treat,
data = mpdta,
se = "hetero"
)
# get it from assigning a global var data_etwfe <<- data in `etwfe()`
data_etwfe
# get formulas, write one part formula, varying slopes as var1 / var2
mod$fml_all
# new formula
fml <- lemp ~ .Dtreat:i(first.treat, i.year, ref = 0, ref2 = 2003)/lpop_dm + first.treat + first.treat/lpop + year + year/lpop
# fit model
fit <- feols(fml, data_etwfe, cluster ~ countyreal, ssc = ssc(adj = FALSE, fixef.K = "none"))
#aggregate
agg <- aggregate(
fit,
c("ATT"="^.Dtreat:first.treat::[0-9]{4}:year::[0-9]{4}$")
)
agg
# Estimate Std. Error t value Pr(>|t|)
# ATT 0.09483085 0.02676169 3.54353 0.000431911
boot_aggregate(
fit,
c("ATT"="^.Dtreat:first.treat::[0-9]{4}:year::[0-9]{4}$"),
B = 999,
boot_ssc = ssc(adj = FALSE),
clustid = ~countyreal
)
# Estimate t value Pr(>|t|) [0.025% 0.975%]
# [1,] 0.09483085 3.547078 0 0.04099321 0.1487666 t-stats, pvalue and confidence interval of Keep in mind that none of this is properly tested, that fixed effect varying slopes syntax does not work (wrong results), and that there is a bug for |
Hi Grant,
Thanks for sharing this package - it looks really cool! Naturally, I am wondering if I can wild (cluster) bootstrap this. =)
After taking a very brief (really very, very brief) glance at both code and the Wooldridge paper, my very topline understanding of the estimation procedure is that$\bar{x}_{1}$ is an estimated mean and therefore has a sampling variance for which one has to correct inference for).
etwfe
implements a linear regression / glm with a set of interacted covariates and a few estimated properties (e.g. equation 5.7 in the Wooldridge paper attached below, whereAfter estimating the 'full' model, one then computes marginal effects, e.g. for the effect on a specific cohort, you compute the marginal effect for a given cohort. If we assume that there are$C$ cohorts, for linear models, inference for all $C$ 'cohort effects' should then boil down to C linear multi-parameter tests of the form $R_{c}'\beta_{c} = r$ vs $R_{c}'\beta_{c} \neq r$ , where $R_{c}$ is a vector of dimension $k_{c}$ , with $k_{c}$ denoting all regression parameters that depend on cohort $c$ ?
Here's a quick formulaic example to (hopefully) clarify:
We estimate a linear model
via OLS.
We then compute the average marginal effect at the mean for$X_{1}$ as
Inference for the marginal effect then follows a standard$R\beta = r$ schema, where $R = [1, \bar{X}_{2}]$ , $\beta = [\beta_1, \beta_2]$ and $r = 0$ .
Do I get this right? If inference can be squeezed into the$R\beta = r$ schema, it will be fairly straightforward to make $\bar{x}_{1}$ is a noiseless estimate of $x_1$ .
fwildclusterboot
work withetwfe
- but only under the assumption thatBest, Alex
The text was updated successfully, but these errors were encountered: