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

ETWFE on Baker.dta #2

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

ETWFE on Baker.dta #2

erinlbritton opened this issue Feb 21, 2022 · 0 comments

Comments

@erinlbritton
Copy link

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

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

gen dinf = (d==0) // d-infinity = never-treated cohort
gen d86 = (gvar==1986)
gen d92 = (gvar==1992)
gen d98 = (gvar==1998)
gen d04 = (gvar==2004)

* gen t dummies
foreach t of num 1980/2009 {
	gen t`t' = (t==`t')
}

* leave out last treated cohort; no never treated units
reg Y c.d86#c.t1986 c.d86#c.t1987 c.d86#c.t1988 c.d86#c.t1989 c.d86#c.t1990 c.d86#c.t1991 c.d86#c.t1992 c.d86#c.t1993 c.d86#c.t1994 c.d86#c.t1995 c.d86#c.t1996 c.d86#c.t1997 c.d86#c.t1998 c.d86#c.t1999 c.d86#c.t2000 c.d86#c.t2001 c.d86#c.t2002 c.d86#c.t2003 c.d86#c.t2004 c.d86#c.t2005 c.d86#c.t2006 c.d86#c.t2007 c.d86#c.t2008 c.d86#c.t2009 ///
	c.d92#c.t1992 c.d92#c.t1993 c.d92#c.t1994 c.d92#c.t1995 c.d92#c.t1996 c.d92#c.t1997 c.d92#c.t1998 c.d92#c.t1999 c.d92#c.t2000 c.d92#c.t2001 c.d92#c.t2002 c.d92#c.t2003 c.d92#c.t2004 c.d92#c.t2005 c.d92#c.t2006 c.d92#c.t2007 c.d92#c.t2008 c.d92#c.t2009 ///
	c.d98#c.t1998 c.d98#c.t1999 c.d98#c.t2000 c.d98#c.t2001 c.d98#c.t2002 c.d98#c.t2003 c.d98#c.t2004 c.d98#c.t2005 c.d98#c.t2006 c.d98#c.t2007 c.d98#c.t2008 c.d98#c.t2009 ///
	d86 d92 d98 i.t, cluster(i)
	
*ATTs by cohort
lincom (c.d86#c.t1986+c.d86#c.t1987+c.d86#c.t1988+c.d86#c.t1989+c.d86#c.t1990+c.d86#c.t1991+c.d86#c.t1992+c.d86#c.t1993+c.d86#c.t1994+c.d86#c.t1995+c.d86#c.t1996+c.d86#c.t1997+c.d86#c.t1998+c.d86#c.t1999+c.d86#c.t2000+c.d86#c.t2001+c.d86#c.t2002+c.d86#c.t2003)/18
lincom (c.d92#c.t1992+c.d92#c.t1993+c.d92#c.t1994+c.d92#c.t1995+c.d92#c.t1996+c.d92#c.t1997+c.d92#c.t1998+c.d92#c.t1999+c.d92#c.t2000+c.d92#c.t2001+c.d92#c.t2002+c.d92#c.t2003)/12
lincom (c.d98#c.t1998+c.d98#c.t1999+c.d98#c.t2000+c.d98#c.t2001+c.d98#c.t2002+c.d98#c.t2003)/6

*ATTs by event-time
lincom (c.d86#c.t1986+c.d92#c.t1992+c.d98#c.t1998)/3  // 0
lincom (c.d86#c.t1987+c.d92#c.t1993+c.d98#c.t1999)/3  // 1
lincom (c.d86#c.t1988+c.d92#c.t1994+c.d98#c.t2000)/3  // 2
lincom (c.d86#c.t1989+c.d92#c.t1995+c.d98#c.t2001)/3  // 3
lincom (c.d86#c.t1990+c.d92#c.t1996+c.d98#c.t2002)/3  // 4
lincom (c.d86#c.t1991+c.d92#c.t1997+c.d98#c.t2003)/3  // 5
lincom (c.d86#c.t1992+c.d92#c.t1998)/2  // 6
lincom (c.d86#c.t1993+c.d92#c.t1999)/2  // 7
lincom (c.d86#c.t1994+c.d92#c.t2000)/2  // 8
lincom (c.d86#c.t1995+c.d92#c.t2001)/2  // 9
lincom (c.d86#c.t1996+c.d92#c.t2002)/2  // 10 
lincom (c.d86#c.t1997+c.d92#c.t2003)/2  // 11
lincom (c.d86#c.t1998)  // 12
lincom (c.d86#c.t1999)  // 13 
lincom (c.d86#c.t2000)  // 14
lincom (c.d86#c.t2001)  // 15
lincom (c.d86#c.t2002)  // 16
lincom (c.d86#c.t2003)  // 17

* pretrends; left out first period for each cohort: c.d86#c.t1980 c.d92#c.t1980 c.d98#c.t1980
reg Y c.d86#c.t1986 c.d86#c.t1987 c.d86#c.t1988 c.d86#c.t1989 c.d86#c.t1990 c.d86#c.t1991 c.d86#c.t1992 c.d86#c.t1993 c.d86#c.t1994 c.d86#c.t1995 c.d86#c.t1996 c.d86#c.t1997 c.d86#c.t1998 c.d86#c.t1999 c.d86#c.t2000 c.d86#c.t2001 c.d86#c.t2002 c.d86#c.t2003 c.d86#c.t2004 c.d86#c.t2005 c.d86#c.t2006 c.d86#c.t2007 c.d86#c.t2008 c.d86#c.t2009 ///
	c.d92#c.t1992 c.d92#c.t1993 c.d92#c.t1994 c.d92#c.t1995 c.d92#c.t1996 c.d92#c.t1997 c.d92#c.t1998 c.d92#c.t1999 c.d92#c.t2000 c.d92#c.t2001 c.d92#c.t2002 c.d92#c.t2003 c.d92#c.t2004 c.d92#c.t2005 c.d92#c.t2006 c.d92#c.t2007 c.d92#c.t2008 c.d92#c.t2009 ///
	c.d98#c.t1998 c.d98#c.t1999 c.d98#c.t2000 c.d98#c.t2001 c.d98#c.t2002 c.d98#c.t2003 c.d98#c.t2004 c.d98#c.t2005 c.d98#c.t2006 c.d98#c.t2007 c.d98#c.t2008 c.d98#c.t2009 ///
	c.d86#c.t1981 c.d86#c.t1982 c.d86#c.t1983 c.d86#c.t1984 c.d86#c.t1985 /// // pretrends
	c.d92#c.t1981 c.d92#c.t1982 c.d92#c.t1983 c.d92#c.t1984 c.d92#c.t1985 c.d92#c.t1986 c.d92#c.t1987 c.d92#c.t1988 c.d92#c.t1989 c.d92#c.t1990 c.d92#c.t1991 ///
	c.d98#c.t1981 c.d98#c.t1982 c.d98#c.t1983 c.d98#c.t1984 c.d98#c.t1985 c.d98#c.t1986 c.d98#c.t1987 c.d98#c.t1988 c.d98#c.t1989 c.d98#c.t1990 c.d98#c.t1991 c.d98#c.t1992 c.d98#c.t1993 c.d98#c.t1994 c.d98#c.t1995 c.d98#c.t1996 c.d98#c.t1997 /// 
	d86 d92 d98 i.t, cluster(i)

lincom (c.d86#c.t1985+c.d92#c.t1991+c.d98#c.t1997)/3 // -1
lincom (c.d86#c.t1984+c.d92#c.t1990+c.d98#c.t1996)/3 // -2
lincom (c.d86#c.t1983+c.d92#c.t1989+c.d98#c.t1995)/3 // -3
lincom (c.d86#c.t1982+c.d92#c.t1988+c.d98#c.t1994)/3 // -4
lincom (c.d86#c.t1981+c.d92#c.t1987+c.d98#c.t1993)/3 // -5
lincom (c.d92#c.t1986+c.d98#c.t1992)/2 // -6
lincom (c.d92#c.t1985+c.d98#c.t1991)/2 // -7
lincom (c.d92#c.t1984+c.d98#c.t1990)/2 // -8
lincom (c.d92#c.t1983+c.d98#c.t1989)/2 // -9
lincom (c.d92#c.t1982+c.d98#c.t1988)/2 // -10
lincom (c.d92#c.t1981+c.d98#c.t1987)/2 // -11
lincom (c.d98#c.t1986) // -12
lincom (c.d98#c.t1985) // -13
lincom (c.d98#c.t1984) // -14
lincom (c.d98#c.t1983) // -15
lincom (c.d98#c.t1982) // -16
lincom (c.d98#c.t1981) // -17

I am terrible at plotting in Stata, so I just took the ATTs from my Stata log and plotted them in R (for comparison with Scott Cunningham's substack post:
Baker.dta with ETWFE

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