kylebutts / did2s

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

Revamped vignette #5

Closed grantmcdermott closed 3 years ago

grantmcdermott commented 3 years ago

Here's a revamped vignette that fixes typos and dead links, as well as simplifies some of the plotting etc. I'm using fixest::iplot() for the latter to underscore the fixest link. I hope you don't mind, but I dropped your bespoke ggplot2 theme, since that requires several extra packages and I think all of that stuff gets in the way of emphasising the main did2s features.

grantmcdermott commented 3 years ago

FWIW, I'm not sure that you want to do this here, but easy enough to add Sun Abraham to the TWFE comparison too. Admittedly, you'd probably want to think a bit more about colours then...

sa = feols(dep_var ~ sunab(g, year) | unit, df_het, cluster=~state)
iplot(list(es, twfe, sa), 
      sep = 0.1, 
      ref.line = -0.5,
      col = c("steelblue", "#82b446", "#7570B3"),
      xlab = "Relative time to treatment",
      main = "Event study: Staggered treatment (comparison)")
# Add the true effects
points(-20:20, true_effects, pch = 0, col = "#b44682")
# Legend
legend("topleft", col = c("steelblue", "#b44682", "#82b446", "#7570B3"), pch = c(20, 0, 17, 15), 
       legend = c("Two-stage estimate", "True effect", "TWFE", "Sun-Abraham"))