* name: equivalence.do
* author: scott cunningham
* description: OLS and Manual are the same

clear
capture log close

use https://github.com/scunning1975/mixtape/raw/master/castle.dta, clear
xtset sid year

drop if effyear==2005 | effyear==2007 | effyear==2008 | effyear==2009

drop 	post
gen 	post = 0
replace post = 1 if year>=2006

gen 	treat = 0
replace treat = 1 if effyear==2006

keep if year==2006 | year==2005

* Example 1: OLS regression with interactions
reg l_homicide post##treat, cluster(sid)

* Example 2: Twoway fixed effects (state and year fixed effects)
xtreg l_homicide c.treat#c.post i.year, fe vce(cluster sid)

* Example 3: Regress "long difference" onto treatment dummy
preserve
    keep sid year l_homicide prison treat
    reshape wide l_homicide prison, i(sid) j(year)
    gen diff = l_homicide2006 - l_homicide2005
    reg diff treat, vce(cluster sid)
restore