I am exploring -csdid- (user written by FernandoRios as an alternative to TWFE under non-staggered timing. According to my understanding if treatment is given at the same time, the standard DiD and CSDID should give similar results.
I tried csdid and didregress with some (publicly available) example datasets, and in most cases, the results from the two procedures were not the same. Could someone help me understand why this is happening? Pls let me know if my code is incorrect. Following is my code.
I tried csdid and didregress with some (publicly available) example datasets, and in most cases, the results from the two procedures were not the same. Could someone help me understand why this is happening? Pls let me know if my code is incorrect. Following is my code.
Code:
cap ssc install drdid cap ssc install csdid * Example 1 use "https://dss.princeton.edu/training/Panel101.dta", clear gen time = 0 replace time = 1 if year>=1994 gen treated = 0 replace treated = 1 if country>4 gen did = time*treated didregress (y) (did), group(country) time(year) *replicating with reghdfe for faster estimation reghdfe y did i.country i.year gen gvar=1994 if treated==1 replace gvar=0 if treated==0 csdid y, gvar(gvar) time(year) estat simple //results not same *Example 2 use "https://www.stata-press.com/data/r19/hospdd", clear bysort hospital (month):egen evertreated= max(procedure) gen after=1 if month>=4 replace after=0 if month<4 gen did=after*ever didregress (satis) (did), group(hospital) time(month) gen gvar=4 if evertreated==1 replace gvar=0 if evertreated==0 csdid satis, gvar(gvar) time(month) estat simple // results quite similar *Example 3 use "http://www.princeton.edu/~otorres/WDI.dta", clear gen after = (year >= 2009) if !missing(year) merge m:1 country using "http://www.princeton.edu/~otorres/Treated.dta", gen(merge1) replace treated = 0 if treated == . gen did = after * treated encode country, gen(country1) didregress (gdppc) (did), group(country1) time(year) gen gvar=2009 if treated==1 replace gvar=0 if treated==0 csdid gdppc, gvar(gvar) time(year) estat simple *retried with long option csdid gdppc, gvar(gvar) time(year) long estat simple
Comment