*! version 4.0 November 15, 2023

Title

eventdd -- Estimate panel event study models and generate event study plots

Syntax

eventdd
depvar [indepvars]
[if] [in]
[weight],
timevar(varname)
[options]

Main
timevar(varname) Specifies the standardized time variable relative to the event of interest. This is required.

over(varname) Indicates that multiple event studies should be estimated and plotted, where a separate event study is plotted over each level
of the variable indicated. The indicated variable must be discrete (either string or numeric), and can take greater than two levels. Resulting graphs will be combined in a single plot.

ci(type, ...) Specifies the type of graph for confidence intervals: rarea (with area shading),
rcap (with capped spikes) or rline (with lines), and also the graphing options: twoway rarea for rarea (eg area), twoway rcap
for rcap (eg line) or twoway rline for rline (eg connect) which should be passed to the resulting event study graph. rcap is the default graph type.
If multiple event studies are produced using the over() option, and separate options are desired
for each set of confidence intervals on each event study
this can be requested using g1(), g2(), and so forth to pass options, with values corresponding to orderd levels of the variable indicated in the over() option.

jitter(#) Only for use if over() is specified. Allows for each event study to be slightly shifted on
graphical output to avoid super-imposition. Scalar value between 0 and 1 provided in jitter indicates the distance on the horizontal axis to shift each event study.

baseline(#) Specifies the baseline period relative to the moment of the event of interest; the default is -1.

level(#) Set confidence level; default is level(95).

accum Accumulates periods beyond indicated leads and lags into a final coefficient/confidence interval.

leads(#) Specifies the number of leads which should be included. This is required when specifying the accum, keepbal or inrange options, otherwise all possible lags will be plotted.

lags(#) Specifies the number of lags which should be included. This is required when specifying the accum, keepbal or inrange options, otherwise all possible lags will be plotted.

noend Requests that end points are suppressed from graphs. This is only available if specifying the accum option.

keepbal(varname) Indicates that only units which are balanced in the panel should be kept, where varname indicates the panel variable (eg state).

method(type, [absorb(absvars)] * ...) Specifies the estimation method: ols (with Stata's regress command), fe (with Stata's xtreg, fe command) or hdfe (with the user-written reghdfe command),
and also any additional estimation options and vce options which should be passed to the event study model, (eg robust or clustered sandwich estimator of variance). The absorb(absvars) sub-option is only required when specifying the hdfe option. ols is the default estimation method.

wboot Requests that confidence intervals be estimated by wild bootstrap. This requires the user-written boottest command. This may not be combined with the hdfe option.

wboot_op(string) Specifies any options for wild bootstrap estimation, (eg seed(), bootcluster()). These will be passed to the boottest command. In the case of using the level option, this should only be specified in the main command syntax. nograph option is already specified.

balanced Requests that only balanced periods in which all units have data be shown in the plot.

inrange Requests that only specified periods in leads and lags be shown in the plot.

noline Requests that line at -1 on the x-axis is suppressed from graphs.

graph_op(string) Specifies any general options in twoway options which should be passed to the resulting event study graph, (eg title, axis, labels, legends).

coef_op(string) Specifies any options for coefficients in scatter which should be passed to the resulting event study graph, (eg marker).
If multiple event studies are produced using the over() option, and separate options are desired
for each set of coefficients on each event study
this can be requested using g1(), g2(), and so forth to pass options, with values corresponding to orderd levels of the variable indicated in the over() option.

endpoints_op(string) Specifies any options for end points coefficients in scatter which should be passed to the resulting event study graph, (eg marker). This is only available if specifying the accum option.

keepdummies Generate dummies of leads and lags. Required save the data before using or data in memory would be lost. This option is necessary to perform joint significance tests using wild or score bootstrap
with the postestimation commands.

The regression variables specified as indepvars may contain
time-series operators and factor variables.

This command requires the user-written ado matsort available from the SSC.

Description

eventdd estimates a panel event study corresponding to a difference-in-difference style model
where a series of lag and lead coefficients and confidence intervals are estimated and plotted.
These lag and lead coefficients are all relative to the passage of an event of interest, which can
occur at different moments in different units of the panel. The estimated model is of the general
format:

y_st = Alpha + Lead^K_st * BetaK + ... + Lead^2_st * Beta2 + Lag^0_st * gamma0 + ... Lag^L_st * gammaL + mu_s + lambda_t + u_st (1)

where y_st is an outcome of interest for state s and time t, and a series of K
Leads and L Lags are considered relative to the event of interest. Fixed effects for state and
time are included as mu_s and lambda_t respectively.

The command requires that the basic model be specified without leads and lags, and a variable
should be indicated in timevar() which defines the standardized version of the time until
the event, with missing values for units in which the event never occurs (pure control units).
The command generates the estimation results and a graph documenting the coefficients and confidence
intervals on all indicated leads and lags. By default, the command uses as a baseline time period
-1 (one year prior to the event of interest) and estimates event study models using Stata's
regress command. However the command can also specify that estimation should proceed
using xtreg or reghdfe (if installed). Similarly, if specified, inference in
eventdd can be based on wild bootstrapped confidence intervals using the boottest command
(if installed).

eventdd provides a useful check of parallel pre-trends in the context of a
difference-in-differences (DD) estimator. Broader discussion of these models are provided in
Angrist and Pischke (2009, section 5.2), Freyaldenhoven et al,. (2019), and Goodman-Bacon
(2018) (among many other references). The paper by Clarke and Tapia (2021) accompanies this
command. Examples of use are given in the "Examples" section below, as well as in Clarke
and Tapia (2021).

Options

Main

timevar(varname) is a required option. The time variable specified should contain a standardized
value, where 0 corresponds to the time period in which the event of interest occurs for a given unit,
-1 refers to one year prior to the event, 1 refers to one year following the event, and so forth.
The timevar specified must increase sequentially from the longest lead (K) to the longest lag (L),
with at least some observations covering each time period in between. If this is not the case,
the timevar can be restandardized so this is the case, or the accum option can be used to
limit leads and lags beyond certain points.
For any units in which the event does not occur (pure controls), this variable should contain missing
values.

over(varname) Allows for the estimation and plotting of multiple event studies on a
single plot. Event studies are estimated separately and plotted for each level of the variable
indicated in over(). This variable must be categorical (in either string or numeric
formats), but can take more than two levels,
and event studies will be plotted for each level. Output for each model will be provided, and
graphical results are combined on a single plot.

ci(type, ...) Specifies the type of graph for the confidence intervals. The types available are rarea for an interval with area shading (see twoway rarea),
rcap for an interval with capped spikes (see twoway rcap) and rline for an interval with lines (see twoway rline). Only one type can be specified and all intervals will be the same type.
The appearance can be modified with the inclusion of any graphing option for the confidence intervals permitted in rarea,
rcap or rline depending on the type of CI indicated; including area options,
line options and connect options, respectively. This does not allow the use of the general options such as titles and legends, which should be specified in the graph_op() option. If not specified,
a standard rcap graphical output will be provided.
If over() has been specified, options for separate confidence intervals for each graph can be
passed using g1(), g2() and so forth. For example, if separate colours are desired for
two event studies over a variable specified in over() this can be achieve with: ci(rarea, g1(color(gs12%30)) g2(color(gs12%50)))

jitter(#) Allows for event studies to be slightly shifted on the horizontal axis when multiple
models are presented in a single plot. Jitter can take values between 0 and 1, and all coefficients and
confidence intervals will be shifted by the units indicated. This option should only be used in
combination with over().

baseline(#) Specifies the reference period for the event study, which is a baseline omitted category to which all other periods should be compared in the event study output. By default this value is set at -1.

level(#) Specifies the confidence level, as a percentage, for confidence intervals. The default is level(95) or as set by set level. This sets the levels for confidence intervals in regression output, as well as the event study plot and returned matrices.
This will also be passed to boottest if wild clustered confidence intervals are requested.

accum Specifies that all periods beyond some specified values should be accumulated into final points. For example if accum is specified and leads(#) and lags(#) are both set equal to 10,
a single coefficient will be displayed in regressions
and graphical output capturing 10 or more periods prior/post reform. If accum is not specified, all possible leads and lags will be included in models and graphical output.

leads(#) Indicates the maximum amount of post-event periods to consider in the event study. This must be specified if either accum, keepbal or inrange are also specified. Only integer values are permitted.

lags(#) Indicates the maximum amount of pre-event periods to consider in the event study. This must be specified if either accum, keepbal or inrange are also specified. Only integer values are permitted.

noend Requests that accumulative end points are not shown on graphical output when the accum option is specified.

keepbal(varname) Specifies that only units which are balanced in the panel should be kept for estimation. Here varname indicates the panel variable (eg state) which indicates units.
In this case "balance" refers to balance over calendar time. An alternative option (balanced),
discussed below, allows for only balanced leads and lags relative to treatment to be considered in graphical output.

method(type, [absorb(absvars)] * ...) Specifies the method of estimation for the event study model underlying graphical output. ols requests that the model should be estimated by OLS using Stata's regress command,
fe requests that the model should be estimated by fixed-effects (within) estimation, using Stata's xtreg, fe command, and hdfe requests that the model should be estimated using the user-written reghdfe command (if installed).
* represents any other estimation options included and permitted by regress, xtreg, or reghdfe that will be passed to the specified estimation command. This allows for the inclusion of clustered standard errors or other variance estimators (see vce options).
For ols, unit-specific fixed effects and time-specific fixed effects must be included in the indepvars indicated in the command syntax. For fe unit-specific fixed effects should not be included in the indepvars indicated but time-specific fixed effects still need to be.
Finally, for hdfe the absorb(absvars) option should also be specified to indicate which fixed effects should be controlled in the regression (refer to reghdfe (if installed) for additional details) and any fixed effects
indicated in absorb(absvars) should not be included in
the indepvars indicated. hdfe cannot be used in combination with the wboot option. ols is the default estimation method.

wboot Indicates that inference in the event study plot produced by the command should be
based on wild cluster bootstrapped confidence intervals. This requires the user-written boottest
command (if installed). This option may not be combined with the hdfe estimation option.

wboot_op(string) Allows for the inclusion of any other wild bootstrap option permitted in boottest,
including seed(#) to set the seed for simulation based calculations and replicate the confidence intervals,
and bootclust(varname) to specify which
variable(s) to cluster the wild boostrap upon, among others. When setting the level (which is 95 by default), this
should be indicated in the level option of the command, and this will be passed to wboot_op(). nograph option is already specified.

balanced Requests that only "balanced" leads and lags are plotted. This will produce a
graph only showing leads and lags for which each treated unit has data, and as such, all
coefficients plotted will be based on all units in the data. While only balanced leads and lags
will be plotted, all units and time periods will be included in the estimation of the event study.

inrange Requests that only the specified leads and lags are plotted. While only leads and lags indicated
in leads(#) and lags(#) will be plotted, all units and time periods will be included in the estimation of the event study.

noline Requests that the line before the event on the x-axis is not shown on graphical output.

graph_op(string) Allows for the inclusion of any other general graphing option permitted in twoway_options,
including title_options, added_lines_options, axis_label_options, among others. This also allows
for the use of alternative labels for graph axes. If not specified, a standard graphical output will be provided.

coef_op(string) Allows for the inclusion of any graphing option for the coefficients permitted in scatter including
marker_options, marker_label_options, among others. This does not allow the use of the general options of graph_op().
If not specified, a standard graphical output will be provided.
If over() has been specified, options for separate coefficients for each graph can be
passed using g1(), g2() and so forth. For example, if separate symbols are desired for
two event studies over a variable specified in over() this can be achieve with: coef_op(g1(ms(Sh)) g2(ms(Oh)))

endpoints_op(string) Allows for the inclusion of any graphing option for the end points coefficients permitted in scatter
including marker_options, marker_label_options, among others. This is only available if specifying the accum option and
does not allow the use of the general options of graph_op(). If not specified, a standard graphical output will be provided.

keepdummies Requests that the dummy variables of all leads and lags used in the estimation be included in the database.
Required save the data before using or data in memory would be lost. This option is necessary to perform joint significance tests using wild or score bootstrap with the postestimation commands.

Examples: single-event study

Load data that replicates Stevenson and Wolfers' (2006) analysis of no-fault divorce reforms and female suicide, circulated with the bacondecomp command.

. webuse set www.damianclarke.net/stata/

. webuse bacon_example.dta, clear

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

. xtreg asmrs post pcinc asmrh cases i.year, fe cluster(stfips)

Generate standarized event-time variable giving time until passage of event for each state

. gen timeToTreat = year - _nfd

Generate the event study plot associated to DD model of female suicide on no-fault divorce reforms with all periods.

. eventdd asmrs pcinc asmrh cases i.year, timevar(timeToTreat) method(fe, cluster(stfips)) graph_op(ytitle("Suicides per 1m Women") xlabel(-20(5)25))

Generate the event study plot associated to DD model of female suicide on no-fault divorce reforms with all periods but only showing balanced periods in plot.

. eventdd asmrs pcinc asmrh cases i.year, timevar(timeToTreat) method(fe, cluster(stfips)) balanced graph_op(ytitle("Suicides per 1m Women"))

Generate the event study plot associated to DD model of female suicide on no-fault divorce reforms only using balanced observations in the specified period.

. eventdd asmrs pcinc asmrh cases i.year, timevar(timeToTreat) method(fe, cluster(stfips)) keepbal(stfips) leads(6) lags(14) graph_op(ytitle("Suicides per 1m Women"))

Examples: multiple event-studies

Load data that replicates Bhalotra et al.'s (2023) analysis of the passage of parliamentary gender quotas on rates of maternal mortality.

. webuse set www.damianclarke.net/stata/

. webuse quota_example.dta, clear

Generate variables indicating GDP in bottom quartile, and year of quotar adoption.

. sum lngdp, d

. gen GDPp25 = lngdp<r(p25)

. gen timeToTreat = year-quotaYear

Estimate event study stratifying by whether or not countries are in bottom quartile of GDP per capita.

. eventdd lnmmrt i.year, timevar(timeToTreat) method(hdfe, absorb(country) cluster(country)) lags(10) leads(10) accum over(GDPp25) jitter(0.2) graph_op(legend(pos(6) order(2 "GDP {&ge} 25p" 5 "GDP < 25p" 1 "95% CI") rows(1)))

Stored results

eventdd stores the following in e():

Scalars

e(baseline) baseline period specified

e(level) confidence level

Macros

e(cmd) eventdd

e(cmdline) command as typed

e(depvar) name of dependent variable

e(wtype) weight type

e(clustvar) name of cluster variable

e(vce) vcetype specified in vce()

e(vcetype) title used to label Std. Err.

Matrices

e(b) coefficient vector

e(V) variance-covariance matrix of the estimators

e(leads) all event leads, their lower bound, the point estimate, and their upper bound

e(lags) all event lags, their lower bound, the point estimate, and their upper bound

e(V_leads_lags) variance-covariance matrix of leads and lags estimators

In the case that over() is specified and multiple event-studies are produced, instead of the matrices indicated above, a set of matrices named as below are returned for each level # of the variable indicated in over:

Matrices

e(b_g#) coefficient vector

e(V_g#) variance-covariance matrix of the estimators

e(leads_g#) all event leads, their lower bound, the point estimate, and their upper bound

e(lags_g#) all event lags, their lower bound, the point estimate, and their upper bound

e(V_leads_lags_g#) variance-covariance matrix of leads and lags estimators

e(group_id) Table providing correspondence between the levels of the variable indicated in over() to group numbers indicated as # in matrices above.

Postestimation commands

The following postestimation commands are of special interest after eventdd:

Command Description

estat leads Joint significance test for leads

estat lags Joint significance test for lags

estat eventdd Joint significance test for leads and lags

Options Description

wboot Joint significance test using boottest command. Requires specifying the keepdummies option in eventdd. nograph option is already specified in boottest.

* Specifies any additional options which should be passed to the joint significance test. Options should be permitted by test or boottest (if specifying the wboot option).

Examples: post-estimation commands

Load data and generate standarized event-time variable.

. webuse set www.damianclarke.net/stata/

. webuse bacon_example.dta, clear

. gen timeToTreat = year - _nfd

Save data in a temporary file before using keepdummies option (also can use save command)

. tempfile example

. save "`example'", replace

Generate the event study plot associated to DD model of female suicide on no-fault divorce reforms with all periods and keepdummies option.

. eventdd asmrs pcinc asmrh cases i.year, timevar(timeToTreat) method(fe, cluster(stfips)) keepdummies graph_op(ytitle("Suicides per 1m Women") xlabel(-20(5)25))

Test the joint significance for leads and lags.

. estat eventdd

Test the joint significance for leads and lags using wild bootstrap.

. estat eventdd, wboot seed(1303)

References

Angrist, Joshua and Jörn-Steffen Pischke. 2009. "Mostly Harmless Econometrics: An Empiricist's Companion".
Princeton University Press.

Bhalotra, Sonia, Damian Clarke, Joseph Gomes and Atheendar Venkataramani. 2023. "Maternal Mortality and Women's Political Power".
Journal of the European Economic Association 21(5):2172–2208.

Clarke, Damian and Kathya Tapia. 2021. "Implementing the Panel Event Study".
Stata Journal 21(4):853–884.

Freyaldenhoven, Simon, Christian Hansen, and Jesse M. Shapiro. 2019. "Pre-event Trends in
the Panel Event-Study Design". American Economic Review 109(9):3307-38.

Goodman-Bacon, Andrew. 2018. "Difference-in-Differences with Variation in Treatment Timing".
National Bureau of Economic Research Working Paper 25018.

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.

Author

Damian Clarke, Universidad de Chile.
Email dclarke@fen.uchile.cl

Kathya Tapia, University of California, Davis.
Email kattapia@ucdavis.edu

See Also

Related commands:

regress
xtset
xtreg
reghdfe (if installed) ssc install reghdfe (to install this command)
boottest (if installed) ssc install boottest (to install this command)
matsort (if installed) ssc install matsort (to install this command)
twoway_options