ddtiming is a Stata command that implements a decomposition of a difference-in-differences (DD) estimator with variation in treatment timing, based on Goodman-Bacon (2018). The two-way fixed effects DD model is a weighted average of all possible two-group/two period DD estimators. The command generates a scatterplot of 2x2 DD estimates and their associated weights.
To install the command, either type
or alternatively type
net describe ddtiming, from(https://tgoldring.com/code/) net install ddtiming
net install ddtiming, from(https://tgoldring.com/code/)
ddtiming in action using the same example as in Goodman-Bacon (2018). Download and load a dataset with the timing of no-fault divorce laws and female suicide rates (Stevenson & Wolfers, 2018) by typing
For comparison, estimate a two-way fixed effects DD model of female suicide on no-fault divorce reforms:
net get ddtiming use nofault_divorce.dta
Apply the DD decomposition theorem in Goodman-Bacon (2018) to the two-way fixed effects DD model:
areg asmrs treat i.year, a(state) robust
You should see the following output and scatterplot:
ddtiming asmrs treat, i(state) t(year)
The scatterplot replicates Figure 6 in Goodman-Bacon (2018). Additionally, we can add options to the command to modify the look of the scatterplot:
This command demonstrates the use of
ddtiming asmrs treat, i(state) t(year) ddline(lwidth(thick)) /// ylabel(-30(10)30) legend(order(3 4 1 2)) savegraph(nfd.jpg) /// savedata(nfd) replace
ddtiming's options (
savedata) and twoway options (
legend). For descriptions of all options and additional help, type
Goodman-Bacon, Andrew. 2018. "Difference-in-differences with variation in treatment timing". Working paper.
Stevenson, Betsey and Justin Wolfers. 2006. "Bargaining in the Shadow of the Law: Divorce Laws and Family Distress". The Quarterly Journal of Economics 121(1): 267-288.