kylebutts / did2s

Two-stage Difference-in-Differences package following Gardner (2021)
http://kylebutts.github.io/did2s
Other
96 stars 22 forks source link

Check Sun and Abraham code #11

Closed kylebutts closed 2 years ago

kylebutts commented 2 years ago

A few people have found weird results, so I might be coding it up wrong in event_study

TobiasMy commented 2 years ago

Does the event study for Sun and Abraham behave correctly now? Running this code from the documentation in the latest version (did2s_0.5.0) compiled from Github:

data(df_het, package = "did2s") out = event_study( data = df_het, yname = "dep_var", idname = "unit", tname = "year", gname = "g" ) plot_event_study(out) Produces this result:

did2s df_het event_study results

The Sun and Abraham facet indeed appears identical to the output from:

fixest_sunab <- feols(fml= dep_var ~ 1 + sunab(cohort=g, period=year, ref.c=0, ref.p=-1), data=df_het) iplot(fixest_sunab) However, this seems to be very off compared to all other event studies. While the general direction here is still correct, in my personal application the direction of effect was reversed compared to all other event studie. I just want to make sure this is indeed the expected outcome and not a bug after the recent change.

kylebutts commented 2 years ago

Hi @TobiasMy, I'm not sure why it's so much noisier than the other estimators. Unless I'm mistaken, that's the proper syntax for sunab. I'm sorry I can't be of more help.

TobiasMy commented 2 years ago

Just one more note I forgot in my initial comment: The output included in the event_study documentation (shown below) seemed to show a Sun and Abraham event study much more in line with all the rest which initially sparked my doubts.

grafik

Anyway. I wanted to thank you for this great package, it is of enormous help to me! Cheers!

kylebutts commented 2 years ago

Thanks @TobiasMy. I'm looking into this. I'll try to get an answer soon.

kylebutts commented 2 years ago

@TobiasMy Okay, so I was doing the sunab code wrong facepalm

It should be all fixed now!

TobiasMy commented 2 years ago

Thanks a ton @kylebutts! Seems like I fell into the same trap when trying to figure out how sunab worked from the vignette. I had just assumed that the fixed effects would automatically be taken care of and did not need to be specified extra. Adding such an FE example to the sunab vignette would certainly help prevent future users making this mistake. Thanks again for investigating this issue.

kylebutts commented 2 years ago

It's fixed in the documentation now: https://github.com/lrberge/fixest/issues/287