Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extended TWFE #1

Open
erinlbritton opened this issue Feb 18, 2022 · 0 comments
Open

Extended TWFE #1

erinlbritton opened this issue Feb 18, 2022 · 0 comments

Comments

@erinlbritton
Copy link

Here's how to estimate treatment effects using extended TWFE (Wooldridge, 2021):

* gen time-varying treatment indicator
gen w = D // time-varying treatment indicator

tab w t // should be 35 units treated at t=7 and 35 treated at t=11

* gen ever-treated cohort indicators
egen d = max(w), by(i)
sort i t

gen dinf = (d==0) // d-infinity = never-treated cohort
gen d7 = (Ei==7)
gen d11 = (Ei==11)

* gen t dummies
foreach t in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 {
	gen t`t' = (t==`t')
}

* estimate TE using Wooldridge ETWFE
* TEs vary by entry cohort and time period:
reg Y c.d7#c.t7 c.d7#c.t8 c.d7#c.t9 c.d7#c.t10 c.d7#c.t11 c.d7#c.t12 c.d7#c.t13 c.d7#c.t14 c.d7#c.t15 ///
	c.d11#c.t11 c.d11#c.t12 c.d11#c.t13 c.d11#c.t14 c.d11#c.t15 ///
	d7 d11 i.t, cluster(i)

* ATTs by cohort
lincom (c.d7#c.t7+c.d7#c.t8+c.d7#c.t9+c.d7#c.t10+c.d7#c.t11+c.d7#c.t12+c.d7#c.t13+c.d7#c.t14+c.d7#c.t15)/9 // ATT(g=7)
lincom (c.d11#c.t11+c.d11#c.t12+c.d11#c.t13+c.d11#c.t14+c.d11#c.t15)/5 // ATT(g=11)

* ATTs by event-time
lincom (c.d7#c.t7+c.d11#c.t11)/2 // 1 period since event
lincom (c.d7#c.t8+c.d11#c.t12)/2 // 2 periods since event
lincom (c.d7#c.t9+c.d11#c.t13)/2 // 3 periods since event
lincom (c.d7#c.t10+c.d11#c.t14)/2 // 4 periods since event
lincom (c.d7#c.t11+c.d11#c.t15)/2 // 5 periods since event
lincom (c.d7#c.t12) // 6 periods since event
lincom (c.d7#c.t13) // 7 periods since event
lincom (c.d7#c.t14) // 8 periods since event
lincom (c.d7#c.t15) // 9 periods since event

* compare to CS
csdid Y, ivar(i) time(t) gvar(gvar) notyet
estat group
estat event
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant