*! version 1.0.4 16sep2022

Title

bacondecomp -- shows a Bacon decomposition of difference-in-differences estimation with variation in treatment timing

Syntax

bacondecomp
varlist [if] [in] [weight]
[, options]

where varlist is

outcome treatment_indicator [controls]

gropt(string) options to pass to graph command

stub(string) specify a prefix for variables to be created holding decomp results

ddetail option for more detailed decomposition (allowed without weights or controls)

other options options to pass to xtreg command

Description

bacondecomp implements a Bacon 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
difference-in-difference estimates and their associated weights. The data must
be xtset and the variable list must include an outcome as the first item,
and a treatment that can only turn from zero to one during the time period examined as its second item.

bacondecomp by default produces a graph for all comparisons and shows up to three types of two-group/two period comparisons,
which differ by control group: (1) Timing groups, or groups whose treatment stated at different times can serve as each other's
controls groups in two ways: those treated later serves as the control
group for an earlier treatment group and those treated earlier serve as the
control group for the later group; (2) Always treated, a group treated prior to the
start of the analysis serves as the control group; and (3) Never treated, a group which never receives the
treatment serves as the control group. Also shown are the component due to variation in controls across
always treated and never treated groups, and the "within" residual component.

Without weights or controls, and with the ddetail option specified,
bacondecomp shows up to four types of two-group/two period comparisons,
which differ by control group: (1) A group treated later serves as the control
group for an earlier treatment group; (2) A group treated earlier serves as the
control group for a later treatment group; (3) A group which never receives the
treatment serves as the control group; and (4) A group treated prior to the
start of the analysis serves as the control group.

Detail on Options

msymbols(symbolstylelist) specifies an ordered list of symbols for each
DD comparison type.

mcolors(colorstylelist) specifies an ordered list of colors for each
DD comparison type.

msizes(markersizestylelist) specifies an ordered list of sizes for each
DD comparison type.

ddline(linesuboptions) allows added line suboptions to be passed to the
line that shows the (overall) two-way fixed effects DD estimate.

noline removes the added line showing the (overall) two-way fixed effects
DD estimate.

gropt (twoway_options): can be used to control the graph titles,
legends, axes,
added lines and text,
regions, name,
aspect ratio, etc.

xtreg options: Any unrecognized options added to bacondecomp are appended to the end
of the xtreg commands which generate estimates.

Real-World Example

Load data that replicates Stevenson and Wolfers' (2006) analysis of
no-fault divorce reforms and female suicide.

. use http://pped.org/bacon_example.dta, clear

Estimate a two-way fixed effect DD model of female suicide on no-fault
divorce reforms.

. xtreg asmrs post pcinc asmrh cases i.year, fe robust

Apply the DD decomposition theorem in Goodman-Bacon (2018) to the two-way
fixed effects DD model.

. bacondecomp asmrs post pcinc asmrh cases, stub(Bacon_) robust

Request the detailed decomposition of the DD model.

. bacondecomp asmrs post pcinc asmrh cases, ddetail

Simulated Example

Create fake data that illustrates problems with heterogeneous time-varying treatment effects.

. clear

. range i 1 4 4

. expand 10

. sort i

. g id=_n

. expand 10

. bys id: g t=_n

. g ttime=(i==1)*(-2)+(i==2)*3+(i==3)*5+(i==4)*15

. g d=(t>ttime)

. g te=(10-i)*(t-ttime)*d

. set seed 214215

. drawnorm x e

. g y=te+t+x+e

. xtset id t

. xtreg y d i.t if inlist(i,2,3) & t>3, i(id) fe

. xtreg y d i.t if inlist(i,2,3) & t<6, i(id) fe

. ba y d, stub(b_) ddetail nograph

. ba y d x, stub(bx_) ddetail nograph

. l b_T b_C b_B b_cgroup if !mi(b_T)

. l bx_T bx_C bx_B bx_cgroup if !mi(bx_T)

Saved Results

bacondecomp saves the following in e():

Matrix

e(b) overall difference-in-difference estimate

e(V) variance estimate of overall difference-in-difference estimate

e(dd) estimates for timing group comparisons

e(wt) weights for timing group comparisons

e(sumdd) summary of timing group comparisons by group (aggregate effect and weight)

References

Goodman-Bacon, Andrew. 2018.
"Differences-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.

Authors

Andrew Goodman-Bacon

andrew.j.goodman-bacon@vanderbilt.edu

Thomas Goldring

thomasgoldring@gmail.com

Austin Nichols

austinnichols@gmail.com

Citation of bacondecomp

bacondecomp is not an official Stata command. It is a free contribution
to the research community, like a paper. Please cite it as such:

Goodman-Bacon, Andrew, Thomas Goldring, and Austin Nichols. 2019.
bacondecomp: Stata module for Decomposing difference-in-differences estimation with variation in treatment timing.
https://ideas.repec.org/c/boc/bocode/s458676.html

Contact for support

Austin Nichols
Washington, DC, USA
austinnichols@gmail.com

Also see

Manual: [U] 23 Estimation and post-estimation commands

[R] areg

[R] xtreg

On-line: help for xtivreg2, xtoverid