Skip to content

Instantly share code, notes, and snippets.

Created June 23, 2021 01:27
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
* name:
* author: scott cunningham (baylor) using kyle butts (colorado) ado
* description: estimate treatment effects using 2sDiD
* date: June 2, 2021
net install did2s, replace from("")
net install cleanplots, replace from("")
* ssc install did2s
* load data
use, clear
set scheme cleanplots
** Static specification and population weights
** Begin TWFE specification.
xi: xtreg l_homicide i.year post [aweight=popwt], fe vce(cluster sid)
** Begin Manual 2SDiD
* Step 1: Manually (note standard errors are off)
reg l_homicide i.sid i.year [aweight=popwt] if post == 0
* Step 2: Regress transformed outcome onto treatment status for all units
predict adj, residuals
reg adj [aweight=popwt], vce(cluster sid) nocons
* .075
** Begin Butts' did2s ado file
did2s l_homicide [aweight=popwt], first_stage(i.sid i.year) second_stage( treatment(post) cluster(sid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment