I intend to do a time-varying diffindiff analysis, and I am a bit confused about how to generated a treated_start date before generating the period variable. The following is an example:
Id | Year | Billion | Event | Treated_i | Period_i | Post_extreme_it | Treated_start |
1 | 2010 | 0 | 0 | 1 | 0 | 0 | . |
1 | 2011 | 0 | 0 | 1 | 0 | 0 | . |
1 | 2012 | 3 | 1 | 1 | 1 | 1 | 2012 |
1 | 2013 | 1 | 0 | 1 | 1 | 1 | . |
1 | 2015 | 1 | 0 | 1 | 1 | 1 | . |
1 | 2016 | 2 | 1 | 1 | 1 | 1 | 2016 |
gen event = 0
replace event = 1 if extreme_type = hurricane & billion > 1
gen treated_start=.
gen period =1 if year >= treated_start
gen treated = 1 if treated_start !=.
gen Post_extreme = treated*period
Thank you so much for your help.
0 Response to generate treated_start date
Post a Comment