Title

evstudydd - estimate event studies in D-i-D settings using the reghdfe or ppmlhdfe packages.
evstudydd produces all the point estimates and standard errors, together with a time indicator, and saves them in a .dta file, which can then be merged or appended with other files to produce more flexible graphs.

Syntax

evstudydd Y t [if] [in], treated(name) shocktime(string) period(string) cluster(string) fe(string) name(string) [weight(name)] [controls(string)] [estimator(string)]

Y outcome variable

t variable for calendar period

Description

evstudydd produces the event study for any D-i-D setting, generates variables for the point estimates, standard errors, and time indicators, and saves these three variables in a .dta file.

Options

treated(name): Specifies the cross-sectional variable that identifies the treated group. This variable should be time-invariant. This is a required option.

shocktime(string): Specifies the time of reference used for the event study. It can either be a variable in your dataset that records the time where the shock happens, or you can directly enter a value. evstudydd can accommodate staggered treatment provided that the variable you use contains different time of treatment for different units.
The variable should be time invariant within each unit. The interaction of treated and shocktime gives the D-i-D variable. shocktime is a required option.

period(string): Specifies the window to use for the event study. It should contain two values (e.g., 3 and 3) that will determine the time t-j and t+k of the event study (where t is the time of the shock as specified by the option shocktime(string)). The outcome will be an event study that produces j+1 coefficients in the pre-shock period and k+1 coefficients in the post-shock period. The extra time before and after the shock ensures that if the working sample has a longer time span around the shock than the window specified, the event study will include a dummy ``all the years prior to t-j'' and a dummy ``all the years after t+k.'' period is a required option.

cluster(string): Specifies the level at which standard errors should be clustered. This is a required option.

fe(string): Specifies the variables that will be included as fixed effects (FE) in the absorb() part of reghdfe or ppmlhdfe. This is a required option. Let id be the variable identifying units (treated or not) and t the time period variable. Writing fe(id t) yields the standard D-i-D (two-way FE) model. You can include fewer FEs: for example, only period FE by writing fe(t). You can also include more FEs, or interactions: for example, assume that all units id can be assigned to a variable called geography, then you can write fe(id geography#t).

name(string): Specifies the name of the file where the point estimates, standard errors, and time indicators are saved after the event study is conducted. The name of the variables are B for point estimates, SE for standard errors, and time for time indicators. This is a required option. You can include the .dta extension in the command, but if not, the command will automatically add it. Thus, writing name("example.dta") and name("example") is equivalent. You can specify a full path. For example: name("/Users/janedoe/project/example"). You can also use globals. For example, after defining global folder "/Users/janedoe/project", you can write name("$folder/example").

weight(name): Specifies the variable that will be used to weight the regression. This is not a required option. If not specified, the command automatically assumes that the regression is equally weighted. Weights can only be used with the reghdfe package.

controls(string): List of continuous time-varying controls. This is not a required option.

estimator(string): Estimator used in the regression. It is either the reghdfe or the ppmlhdfe package. Default is reghdfe. Thus, if not specified, the command uses reghdfe. Writing estimator(reghdfe) or estimator(ols) uses the reghdfe package. Writing estimator(ppmlhdfe) or estimator(poisson) uses the ppmlhdfe package. This is not a required option.

Example

1) D-i-D estimation for three periods before and after the shock. The outcome is the variable Y. The variable for the calendar period is year. Treated units are identified by the variable treat. The time of the shock is identified by the variable yrshock. Standard errors are clustered at the id level. Units and year fixed effects are included. The output file is called example.dta. Here the packaged used is reghdfe because the option estimator is not specified. The regression is equally weighted because the option weights is not specified.

evstudydd Y year, treated(treat) shocktime(yrshock) period(3 3) cluster(id) fe(id year) name("example")

2) Same but here the regression is weighted by the variable w.

evstudydd Y year, treated(treat) shocktime(yrshock) period(3 3) cluster(id) fe(id year) name("example") weight(w)

3) Same but include time-varying controls. The age of the unit, for example.

evstudydd Y year, treated(treat) shocktime(yrshock) period(3 3) cluster(id) fe(id year) name("example") weight(w) controls(age)

4) Assume that all units id can be assigned to a variable called geography. D-i-D estimation for 6 periods before and 5 after the shock. The outcome is the variable Y. The variable for the calendar period is t. Treated units are identified by the variable treat. The time of the shock is identified by the variable tshock. Standard errors are clustered at the id level. Unit and geography by year fixed effects are included. The output file is called example.dta. Here the regression is equally weighted because the option weights is not specified.

evstudydd Y t, treated(treat) shocktime(tshock) period(6 5) cluster(id) fe(id geography#year) name("example")

5) Same but use the ppmlhdfe package. Here the regression is equally weighted because the option estimator(ppmlhdfe) is used (remember that ppmlhdfe does not accept analytical weights). Writing estimator(ppmlhdfe) or estimator(poisson) here is equivalent.

evstudydd Y t, treated(treat) shocktime(tshock) period(6 5) cluster(id) fe(id geography#year) name("example") estimator(ppmlhdfe)

6) Same but specify the reghdfe package instead. Here the regression is equally weighted because the option weights is not specified. Writing estimator(reghdfe) or estimator(ols) here is equivalent.

evstudydd Y t, treated(treat) shocktime(tshock) period(6 5) cluster(id) fe(id geography#year) name("example") estimator(reghdfe)

Authors

Adrien Matray (adrien.matray@gmail.com), Pablo E. Rodriguez (pablo6@mit.edu)

Comments

Send any suggestions or feedback to Adrien Matray (adrien.matray@gmail.com).