xtevent
is a Stata package to estimate linear panel event-study models. It includes three commands: xtevent
for estimation; xteventplot
to create event-study plots and; xteventtest
for post-estimation hypotheses testing.
Version 3.1.0 (07jul2024):
Version 3.0.0 (23feb2024):
nominus1label
to nonormlabel
: #152Version 2.2.0 (15mar2023):
cohort
and control_cohort
to obtain estimates using Sun and Abraham's (2021) method.repeatedcs
option and get_unit_time_effects
command to estimate event-studies in repeated cross-section settings.noestimate
option to savek()
to generate event-time dummies without estimating the regression model.reghdfe
.Version 2.1.1 (12aug2022):
Version 2.1.0 (1aug2022):
diffavg
option to xtevent
to obtain the difference between the average post-event and pre-event coefficient estimates. textboxoption
option to xteventplot
to specify characteristics for displaying the p-values of the pre-trend and leveling-off tests.Version 2.0.0 (24jun2022):
nonstaggered
has been depreciated. The default option is now not to impute missing values or endpoints. You should now choose any of the imputation rules in the impute
option. To get results using imputation consistent with staggered adoption, as in version 1.0.0 you should use impute(stag)
.trend
allows for trend adjustment by either OLS or GMM.ssc install xtevent
To update from an older version:
adoupdate xtevent, update
github
command:First, install the github
command:
net install github, from("https://haghish.github.io/github/")
Then execute:
cap github uninstall xtevent
github install JMSLab/xtevent
The github
command will also install all the necessary dependencies.
If you have an older version and want to update:
github update xtevent
net
:cap ado uninstall xtevent
net install xtevent, from("https://raw.githubusercontent.com/JMSLab/xtevent/master")
help xtevent
Using xtevent 3.1.0
*** setup
webuse nlswork, clear
* year variable has many missing observations
* Create a time variable that ignores the gaps
by idcode (year): gen time=_n
xtset idcode time
*Generate a policy variable that follows staggered adoption
by idcode (time): gen union2=sum(union)
replace union2=1 if union2>1
order time union union2, after(year)
*** Examples
*Estimate a basic event study with clustered standard errors
*Impute the policy variable assuming no unobserved changes
xtevent ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure , ///
pol(union2) w(3) cluster(idcode) impute(nuchange)
*Omit unit and time fixed effects
*Impute the policy variable verifying staggered adoption
xtevent ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure , ///
pol(union2) w(3) cluster(idcode) nofe note impute(stag)
* Bring back unit and time fixed effects
*Adjust for a pre-trend by estimating a linear trend by GMM
xtevent ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure , ///
pol(union2) w(3) cluster(idcode) trend(-2, method(gmm)) ///
impute(stag)
*Freyaldenhoven, Hansen and Shapiro (2019) estimator with proxy variables
xtevent ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure , ///
pol(union2) w(3) vce(cluster idcode) proxy(wks_work) ///
impute(stag)
*reghdfe and two-way clustering
xtevent ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure , ///
pol(union2) w(3) impute(stag) cluster(idcode year) reghdfe ///
proxy(wks_work)
*Sun and Abraham (2021) Estimator
xtevent ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure, ///
policyvar(union2) window(3) impute(stag) vce(cluster idcode) ///
reghdfe sunabraham
*** Setup
webuse nlswork, clear
* year variable has many missing observations
* Create a time variable that ignores the gaps
by idcode (year): gen time=_n
xtset idcode time
*** Examples
*Basic event study with clustered standard errors
*Impute the policy variable assuming no unobserved changes
xtevent ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure , ///
pol(union) w(3) cluster(idcode) impute(nuchange)
* Simple plot
xteventplot
*Plot smoothest path in confidence region
xteventplot, smpath(line)
*Freyaldenhoven, Hansen and Shapiro (2019) estimator with proxy variables
xtevent ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure , ///
pol(union) w(3) vce(cluster idcode) impute(nuchange) ///
proxy(wks_work)
*Dependent variable, proxy variable, and overlay plots
xteventplot, y
xteventplot, proxy
xteventplot, overlay(iv)
xteventplot
*** setup
webuse nlswork, clear
xtset idcode year
*** examples
*Basic event study with clustered standard errors.
*Impute the policy variable assuming no unobserved changes
xtevent ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure , ///
pol(union) w(3) cluster(idcode) impute(nuchange)
*Test some coefficients to be equal to 0 jointly
xteventtest, coefs(1 2)
*Test that the sum of all pre-event coefficients is equal to 0
xteventtest, allpre cumul
*Test whether the coefficients before the event follow a linear trend
xteventtest, linpretrend
*Tests that the coefficients for the earliest 2 periods before the event are equal to 0
xteventtest, overidpre(2)
Our YouTube channel, Linear Panel Event-Study Design, contains a video series discussing xtevent
and the accompanying paper, Visualization, Identification, and Estimation in the Panel Event-Study Design.
Simon Freyaldenhoven, Christian Hansen, Jorge Pérez Pérez, and Jesse M. Shapiro. "Visualization, Identification, and Estimation in the Linear Panel Event-Study Design." NBER Working Paper No. 29170, August 2021; forthcoming in Advances in Economics and Econometrics: Twelfth World Congress.
Simon Freyaldenhoven, Christian Hansen, Jorge Pérez Pérez, Jesse M. Shapiro, and Constantino Carreto. "xtevent: Estimation and Visualization in the Linear Panel Event-Study Design." Article to accompany Stata package, July 2024.