grantmcdermott / etwfe

Extended two-way fixed effects
https://grantmcdermott.com/etwfe/
Other
50 stars 11 forks source link

Heterogeneous Treatment Effects #16

Closed frederickluser closed 1 year ago

frederickluser commented 1 year ago

Dear Grant,

I implemented now the heterogeneous treatment effects I mentioned in issue #13.

Interacting the treatment with a time-constant covariate allows estimating the effect separately for multiple groups, for example, women and men (see the image below).

I use this now in my research, and maybe you find it interesting to include in your package.

All the best, Frederic

es

frederickluser commented 1 year ago

Dear Grant,

I implemented all your requested changes and ran the check function locally on my computer. I received no errors, warnings, or notes.

Additionally, I added the option to run a hypothesis test for the heterogeneous effects in the emfx file. Maybe you like this option.

grantmcdermott commented 1 year ago

Super, thanks Frederik. I appreciate you bearing with me and think we're close now. I have three more requests and then will merge after a final check:

LMK if anything is unclear, or if you'd like to discuss any of these requests. Thanks!

frederickluser commented 1 year ago

Thank you for your feedback, Grant. Regarding your points:

Final point - I found a way to get rid of the [1] index in emfx. I think it's less error-prone like this.

grantmcdermott commented 1 year ago

This is great. I have a couple tweaks that I'd like to make on the backend, but happy to merge as-is. Many thanks for the nice contribution!

grantmcdermott commented 1 year ago

HU that emfx now autodetects whether to estimate het. TEs based on whether xvar is detected as an attribute of the underlying emfx object. Users can override this behavior with the new "by_xvar" argument. See #21.

frederickluser commented 1 year ago

very nice!

frederickluser commented 1 year ago

A related thought - if the user enters a continuous xvar (which is fine), marginaleffects should evaluate at a meaningful value of xvar, e.g., the mean.

You think this might be something so think about?

grantmcdermott commented 1 year ago

A related thought - if the user enters a continuous xvar (which is fine), marginaleffects should evaluate at a meaningful value of xvar, e.g., the mean.

Sounds like a good idea. But I'm not sure I'll have the bandwidth to incorporate before the next CRAN submission. I'm hoping to do today or tomorrow, since the current version is error'ing out as a result of the upstream marginaleffects 0.9.0 changes (fixed in this dev version). But please feel free to raise another issue/PR if you have an implementation plan.