bcallaway11 / did

Difference in Differences with Multiple Periods, website: https://bcallaway11.github.io/did
298 stars 95 forks source link

More flexible aggregations of effects? Allow for ranges? For simultaneous restrictions on groups and times? #97

Open jtorcasso opened 2 years ago

jtorcasso commented 2 years ago

There's already a lot of flexibility in the package for aggregating the individual 2x2 ATT(g,t)s. But I know I'd find it useful to give the user a little bit more control over the overall average.

Ranges: Is there a way to specify a range over which you'd like the overall average? For instance, in event time, if you wanted to get the average impact for only event times 6 through 12. You may want to do this if you expect there to be a ramp up period where the treatment effect increases until stabilizing at event time 6. While you may want to stop at 12 to avoid changing the composition of your cohorts too much in event time.

Simultaneous restrictions: Suppose I want an overall average for the earlier treated groups, say g < 10, AND I want to restrict to a particular event time range, or calendar time range.

How to do this: perhaps the easiest way is to have a new function that allows overall aggregations, where the user can supply up to two vectors, choosing among groups, calendar times, or event times.

bcallaway11 commented 2 years ago

Yes, I am really interested in these sorts of issues --- i.e., making code generic enough that users can (fairly easily) come up with their own application-specific solutions.

This is not exactly what you are asking for, but we have made a lot of progress on writing generic code:

With regard to your specific comment, while it would not be super user-friendly at the moment, it should be possible to implement quite general custom aggregation schemes. In particular, att_gt returns the influence function for the estimated ATT(g,t)'s, which means that you can often pretty easily come up with a custom aggregation. One example is #58.

I'm going to leave this open and tag this as a possible enhancement going forward.

jtorcasso commented 2 years ago

Thanks for the pointers! For a workaround, I ended up modifying the compute.aggte function. For the dynamic effects, I changed the line epos <- eseq >= 0 to epos <- eseq >= overall_min_e & eseq <= overall_max_e, after defining new parameter options overall_min_e and overall_max_e.