Journal of Econometrics · 2021 · 10.1016/j.jeconom.2020.09.006
Estimating dynamic treatment effects in event studies with heterogeneous treatment effects
Liyang Sun; Sarah Abraham
Review history
Received 7 Aug 2020 → revised → accepted 1.6 months later; online 2.7 months after acceptance.
Received: 7 Aug 2020Revised: 22 Sep 2020Accepted: 24 Sep 2020First online: 16 Dec 2020
Received → accepted. Journal of Econometrics, papers printed 2020–2022: median 16.3 months (middle half 12.9–20.9), 44 papers measured. This paper: 1.6 months, shorter than the median.
Acceptance → first online. Journal of Econometrics, papers printed 2020–2022: median 1.8 months (middle half 1.0–3.2), 45 papers with an online date. This paper: 2.7 months, longer than the median.
Dates as printed on the paper's first page; read from the paper's text, not from publisher metadata. Journal medians leave out: under 14 days, out of order, special issue / invited, implausible year — the same papers /review-times leaves out.
The research recipe, read from the replication code
zenodo · package
· stata, matlab
—
sample period in the code
16
keep/drop statements
0
winsorizations
4
missing-data rules
0
de-duplications
4
distinct estimations
These tiles count distinct estimations (one per command, method, inference, fixed effects and file) and keep/drop statements.
"How the code gets from data to results" below counts every estimating statement (9)
and keep/drop statements plus winsorized variables (16).
1 · Data and structure
Databases read: none detected
Panel declared as:
none
2 · How the sample is built
- drop missing data ×4
- keep value range ×4
- drop value range ×2
- keep other ×2
- keep demographic ×2
- keep time period ×1
- keep observation position ×1
Reshaping:
reshape long/wide ×1
3 · Design and validation
Identification: difference in differences, event study
DiD checks: heterogeneity robust estimator
4 · What it estimates
| Command | Method | Fixed effects absorbed | Inference | File |
|---|---|---|---|---|
|
panel fe | hhidpn | cluster by hhidpn | event_studies_hrs_hospitalization.do |
|
ols | default | event_studies_hrs_hospitalization.do | |
|
panel fe | hhidpn | default | event_studies_hrs_hospitalization.do |
|
did | hhidpn, wave | cluster by hhidpn | event_studies_hrs_replication.do |
5 · What it tests beyond the coefficient (5 post-estimation tests:
lincom 5)
- a linear combination of coefficients
lincom r(N)/(r(N)+r(N))*evt_time_3_9 + r(N)/(r(N)+r(N))*evt_time_3_10 - a coefficient reported with its own test
lincom evt_time_2_10
6 · What it produces
0 table files and 4 figure files
(pdf 3, ? 1).
${fileloc}oop_graph.pdf${fileloc}riearn_graph.pdf${fileloc}weights_l2.pdfHow the code gets from data to results own page
5
scripts
2
input files
1
file hand-offs
0
merges
16
sample steps
9
estimations
1 · Data in — files the code reads and no script of the package writes
Other input files
2 files
HRS_long.dtaStata · read by 2 scriptsevent_studies_hrs_hospitalization.do:7
event_studies_hrs_hospitalization.do, line 7 use HRS_long.dta, clearHRS_7_11_results.xlsxExcelevent_studies_figs_tables.do:43
event_studies_figs_tables.do, line 43 import excel "${fileloc}HRS_7_11_results.xlsx", clear sheet("oop_raw") firstrow
2 · The file pipeline — which script writes which file that a later script reads
5 scripts, in the order the README lists them (README.txt);
1 hand-offs through 1 intermediate files; 6 files written and never read back (outputs).
-
1.
cal_weights.msetup file sourced by 2 scripts -
2.
event_studies_hrs_hospitalization.donamed in README.txt reads 1 input file · 7 estimationswriteshrs_wave_7_11_l2.csv→ read byevent_studies_figs_tables.dowrites (not read again):HRS_SumStats_under59.csv,hrs_wave_7_11_f1.csv,hrs_wave_7_11_rel_time_normalized.csv,hrs_wave_7_11_riearn_rel_time_normalized.csv -
3.
event_studies_hrs_replication.donamed in README.txt reads 1 input file · 2 estimations -
4.
event_studies_figs_tables.donamed in README.txt reads 1 input file ·reads whatevent_studies_hrs_hospitalization.dowrote -
5.
event_studies_weight_simulations.mnamed in README.txtwrites (not read again):catt_weights_mu_0.xls,catt_weights_mu_m2.xls
3 · Merges — 0 joins
No merges recorded.
4 · The sample — 16 keep/drop steps, 0 variables winsorized or trimmed
Filters, by kind
time period ×1
- keep if
evt_time==-1event_studies_hrs_hospitalization.do:53
event_studies_hrs_hospitalization.do, line 53 keep if evt_time==-1
value ranges ×6
- drop if
wave < 7event_studies_hrs_hospitalization.do:12
event_studies_hrs_hospitalization.do, line 12 drop if wave < 7 // keep a balanced sample for wave 7-11 - keep if
N == 5event_studies_hrs_hospitalization.do:14
event_studies_hrs_hospitalization.do, line 14 keep if N == 5 - keep if
wave < 11event_studies_hrs_hospitalization.do:116
event_studies_hrs_hospitalization.do, line 116 keep if wave < 11 - keep if
wave_hosp > waveevent_studies_hrs_hospitalization.do:117
event_studies_hrs_hospitalization.do, line 117 keep if wave_hosp > wave // keep only the control cohorts - drop if
wave < 7event_studies_hrs_replication.do:12
event_studies_hrs_replication.do, line 12 drop if wave < 7 // keep a balanced sample for wave 7-11 - keep if
N == 5event_studies_hrs_replication.do:14
event_studies_hrs_replication.do, line 14 keep if N == 5
demographics ×2
- keep if
age_hosp <= 59event_studies_hrs_hospitalization.do:30
event_studies_hrs_hospitalization.do, line 30 keep if age_hosp <= 59 - keep if
age_hosp <= 59event_studies_hrs_replication.do:30
event_studies_hrs_replication.do, line 30 keep if age_hosp <= 59
row position (_n, first / last row) ×1
- keep if
l<=3event_studies_figs_tables.do:12
event_studies_figs_tables.do, line 12 keep if l<=3
missing values ×4
- drop if
flag >= 0 & flag != .event_studies_hrs_hospitalization.do:17
event_studies_hrs_hospitalization.do, line 17 drop if flag >= 0 & flag != . // drop those first hospitalization happened before or during wave 7 - drop if
flag == .event_studies_hrs_hospitalization.do:18
event_studies_hrs_hospitalization.do, line 18 drop if flag == . - drop if
flag >= 0 & flag != .event_studies_hrs_replication.do:17
event_studies_hrs_replication.do, line 17 drop if flag >= 0 & flag != . // drop those first hospitalization happened before or during wave 7 - drop if
flag == .event_studies_hrs_replication.do:18
event_studies_hrs_replication.do, line 18 drop if flag == .
other conditions ×2
- keep if
ever_hospitalizedevent_studies_hrs_hospitalization.do:24
event_studies_hrs_hospitalization.do, line 24 keep if ever_hospitalized // keep a sample of individuals who were ever hospitalized wave 8-11 - keep if
ever_hospitalizedevent_studies_hrs_replication.do:24
event_studies_hrs_replication.do, line 24 keep if ever_hospitalized // keep a sample of individuals who were ever hospitalized wave 8-11
Outliers
No winsorizing or trimming recorded.
Missing values
dropped ×4
event_studies_hrs_replication.do:17
event_studies_hrs_replication.do, line 17 drop if flag >= 0 & flag != . // drop those first hospitalization happened before or during wave 7event_studies_hrs_replication.do:18
event_studies_hrs_replication.do, line 18 drop if flag == .event_studies_hrs_hospitalization.do:17
event_studies_hrs_hospitalization.do, line 17 drop if flag >= 0 & flag != . // drop those first hospitalization happened before or during wave 7event_studies_hrs_hospitalization.do:18
event_studies_hrs_hospitalization.do, line 18 drop if flag == .
5 · Key variables — what enters the models, and where the code builds it
| Variable | Used in models as | Built by |
|---|---|---|
oop_spend |
outcome in 3 | no statement builds it — a column of an input file, or made by a reshape/merge we do not trace |
flag |
outcome in 2 | flag = min(evt_time) (egen min) event_studies_hrs_hospitalization.do:16event_studies_hrs_hospitalization.do, line 16
bys hhidpn: egen flag = min(evt_time) flag = wave_hosp == `yy' & wave == `yy'+`kk' (gen) event_studies_hrs_hospitalization.do:371event_studies_hrs_hospitalization.do, line 371
gen flag = wave_hosp == `yy' & wave == `yy'+`kk' flag = wave_hosp == `yy' & wave == `yy'+`kk' (gen) event_studies_hrs_hospitalization.do:389event_studies_hrs_hospitalization.do, line 389
gen flag = wave_hosp == `yy' & wave == `yy'+`kk' +1 more statements set it |
riearnsemp |
outcome in 1 | no statement builds it — a column of an input file, or made by a reshape/merge we do not trace |
wave_hosp_1 |
outcome in 1 | no statement builds it — a column of an input file, or made by a reshape/merge we do not trace |
wave_hosp_2 |
outcome in 1 | no statement builds it — a column of an input file, or made by a reshape/merge we do not trace |
wave_hosp_3 |
outcome in 1 | no statement builds it — a column of an input file, or made by a reshape/merge we do not trace |
_Iwave_ |
regressor in 4 | no statement builds it — a column of an input file, or made by a reshape/merge we do not trace |
evt_time_3 |
regressor in 3 | no statement builds it — a column of an input file, or made by a reshape/merge we do not trace |
evt_time_7 |
regressor in 3 | no statement builds it — a column of an input file, or made by a reshape/merge we do not trace |
evt_time_2_10 |
regressor in 1 | no statement builds it — a column of an input file, or made by a reshape/merge we do not trace |
evt_time_3_10 |
regressor in 1 | no statement builds it — a column of an input file, or made by a reshape/merge we do not trace |
evt_time_3_9 |
regressor in 1 | no statement builds it — a column of an input file, or made by a reshape/merge we do not trace |
evt_time_5_10 |
regressor in 1 | no statement builds it — a column of an input file, or made by a reshape/merge we do not trace |
evt_time_5_8 |
regressor in 1 | no statement builds it — a column of an input file, or made by a reshape/merge we do not trace |
evt_time_5_9 |
regressor in 1 | no statement builds it — a column of an input file, or made by a reshape/merge we do not trace |
evt_time_6_8 |
regressor in 1 | no statement builds it — a column of an input file, or made by a reshape/merge we do not trace |
evt_time_6_9 |
regressor in 1 | no statement builds it — a column of an input file, or made by a reshape/merge we do not trace |
evt_time_7_8 |
regressor in 1 | no statement builds it — a column of an input file, or made by a reshape/merge we do not trace |
6 · Models, by the table or figure they feed — 9 estimations, 0 traced into 0 exhibits
Estimations not traced to a table or figure · 9
| Command | Outcome | Regressors | Fixed effects | Standard errors | Where |
|---|---|---|---|---|---|
reghdfepanel fe |
oop_spend |
evt_time_2-evt_time_3 evt_time_5-evt_time_8 _Iwave_*
|
hhidpn | cluster: hhidpn | event_studies_hrs_hospitalization.do:219event_studies_hrs_hospitalization.do, line 219
reghdfe oop_spend evt_time_2-evt_time_3 evt_time_5-evt_time_8 _Iwave_* if ever_hospitalized , absorb(hhidpn) cluster(hhidpn) |
regols |
wave_hosp_1 |
evt_time_3 - evt_time_7
|
— | default | event_studies_hrs_hospitalization.do:243event_studies_hrs_hospitalization.do, line 243
reg wave_hosp_1 evt_time_3 - evt_time_7 if wave < 11 , nocons |
regols |
wave_hosp_2 |
evt_time_3 - evt_time_7
|
— | default | event_studies_hrs_hospitalization.do:245event_studies_hrs_hospitalization.do, line 245
reg wave_hosp_2 evt_time_3 - evt_time_7 if wave < 11 , nocons |
regols |
wave_hosp_3 |
evt_time_3 - evt_time_7
|
— | default | event_studies_hrs_hospitalization.do:247event_studies_hrs_hospitalization.do, line 247
reg wave_hosp_3 evt_time_3 - evt_time_7 if wave < 11 , nocons |
reghdfepanel fe |
oop_spend |
evt_time_5_8 evt_time_6_8 evt_time_7_8 evt_time_3_9 evt_time_5_9 evt_time_6_9 evt_time_2_10 evt_time_3_10 evt_time_5_10 _Iwave_*
|
hhidpn | cluster: hhidpn | event_studies_hrs_hospitalization.do:273event_studies_hrs_hospitalization.do, line 273
reghdfe oop_spend $rhs_rel_year_i _Iwave_* if ever_hospitalized & wave < 11 , absorb(hhidpn) cluster(hhidpn)
as we read it (macros filled in / loop expanded):
reghdfe oop_spend evt_time_5_8 evt_time_6_8 evt_time_7_8 evt_time_3_9 evt_time_5_9 evt_time_6_9 evt_time_2_10 evt_time_3_10 evt_time_5_10 _Iwave_* if ever_hospitalized & wave < 11 , absorb(hhidpn) cluster(hhidpn) |
reghdfepanel fe |
flag |
evt_time_2-evt_time_3 evt_time_5-evt_time_8 _Iwave_*
|
hhidpn | default | event_studies_hrs_hospitalization.do:373event_studies_hrs_hospitalization.do, line 373
reghdfe flag evt_time_2-evt_time_3 evt_time_5-evt_time_8 _Iwave_* if ever_hospitalized , absorb(hhidpn) |
reghdfepanel fe |
flag |
evt_time_2-evt_time_3 evt_time_5-evt_time_8 _Iwave_*
|
hhidpn | default | event_studies_hrs_hospitalization.do:391event_studies_hrs_hospitalization.do, line 391
reghdfe flag evt_time_2-evt_time_3 evt_time_5-evt_time_8 _Iwave_* if ever_hospitalized , absorb(hhidpn) |
eventstudyinteractdid |
oop_spend |
evt_time_2-evt_time_3 evt_time_5-evt_time_7
|
hhidpn, wave | cluster: hhidpn | event_studies_hrs_replication.do:50event_studies_hrs_replication.do, line 50
eventstudyinteract oop_spend evt_time_2-evt_time_3 evt_time_5-evt_time_7 ///
if ever_hospitalized & wave < 11 , cohort(wave_hosp) absorb(hhidpn wave) ///
control_cohort(last_cohort) vce(cluster hhidpn) |
eventstudyinteractdid |
riearnsemp |
evt_time_2-evt_time_3 evt_time_5-evt_time_7
|
hhidpn, wave | cluster: hhidpn | event_studies_hrs_replication.do:54event_studies_hrs_replication.do, line 54
eventstudyinteract riearnsemp evt_time_2-evt_time_3 evt_time_5-evt_time_7 ///
if ever_hospitalized & wave < 11 , cohort(wave_hosp) absorb(hhidpn wave) ///
control_cohort(last_cohort) vce(cluster hhidpn) |
Tables and figures the code writes:
· ·
${fileloc}oop_graph.pdf event_studies_figs_tables.do:57
event_studies_figs_tables.do, line 57
graph export "${fileloc}oop_graph.pdf", replace
${fileloc}riearn_graph.pdf event_studies_figs_tables.do:71
event_studies_figs_tables.do, line 71
graph export "${fileloc}riearn_graph.pdf", replace
${fileloc}weights_l2.pdf event_studies_figs_tables.do:91
event_studies_figs_tables.do, line 91
graph export "${fileloc}weights_l2.pdf", replace
7 · Figures: how each is drawn — 1 figure in the code (command, layers, options, the file it is saved to)
line 1
| command | layers | variables | options | saved as | where |
|---|---|---|---|---|---|
twowayline
|
connected + connected + connected + connected |
y firstwave, secondwave, thirdwave, fourthwave
x y
|
xtitle Relative Wave · ytitle Weights · scheme sj · legend order(1 Weights on 1st cohort CATT 2 Weights on 2nd cohort CATT 3 Weights on 3rd cohort CATT 4 Weights on 4th cohort CATT) |
weights_l2.pdf |
event_studies_figs_tables.do:82event_studies_figs_tables.do, line 82
twoway scatter firstwave y, c(l) lpattern(solid) msize(large) m(oh) || ///
scatter secondwave y, c(l) lpattern(dot) msize(large) m(th) || ///
scatter thirdwave y, c(l) lpattern(dash) msize(large) m(dh) || … |