代码拉取完成,页面将自动刷新
同步操作将从 连享会/did2s_stata 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
********************************************************************************
* Example with simulated data
********************************************************************************
use https://github.com/kylebutts/did2s_stata/raw/main/data/df_hom.dta, clear
* net install did2s, from("https://raw.githubusercontent.com/kylebutts/did2s_stata/main/ado/") replace
do ado/did2s.ado
********************************************************************************
* Static
********************************************************************************
** Manual 2SDiD (with incorrect standard errors)
* Step 1: Manually
reg dep_var i.unit i.year if treat == 0, nocons
* Step 2: Regress transformed outcome onto treatment status for all units
predict adj, residuals
reg adj i.treat, vce(cluster state) nocons
** 2SDiD with correct se's
did2s dep_var, first_stage(i.unit i.year) treat_formula(i.treat) treat_var(treat) cluster(state)
* Example esttab
esttab, nobaselevels se
********************************************************************************
* Event Study
********************************************************************************
* factors can't be negative
gen rel_year_shift = rel_year + 20
replace rel_year_shift = 100 if rel_year_shift == .
did2s dep_var, first_stage(i.unit i.year) treat_formula(b100.rel_year_shift) treat_var(treat) cluster(state)
********************************************************************************
* Castle Doctrine
********************************************************************************
use https://github.com/scunning1975/mixtape/raw/master/castle.dta, clear
* Covariates
global demo blackm_15_24 whitem_15_24 blackm_25_44 whitem_25_44
global spending l_exp_subsidy l_exp_pubwelfare
global xvar l_police unemployrt poverty l_income l_prisoner l_lagprisoner $demo $spending
* No Covariates
did2s l_homicide [aweight=popwt], first_stage(i.sid i.year) treat_formula(i.post) treat_var(post) cluster(sid)
* Covariates
did2s l_homicide [aweight=popwt], first_stage(i.sid i.year $xvar) treat_formula(i.post) treat_var(post) cluster(sid)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。