I am using -reghdfe- (ssc install) to run DID regression (Stata 17). Sample data given below:
For DID, I am using the following commands:
The treat variable identifies the regions which were given the treatment. The treatment occurred between 2018 and 2022, so I have generated treatpost as treat*(year>2018).
How can I test for parallel trends using -reghdfe-? I am unable to use didregress because my dataset is large and didregress is taking hours to work.
I posted a different query on parallel trends on https://www.statalist.org/forums/for...ss-and-reghdfe but I am still confused how to apply the solution to my real data. Specifically I am not sure why are the -evertreated- and -pretreat- variables needed. Can I just do it with:
?
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte(y1 x1) float(treat treatpost year) long _id 0 10 1 1 2022 1 0 8 1 0 2012 1 0 6 1 0 2011 1 1 16 1 0 2012 1 0 6 1 0 2018 1 0 9 1 0 2012 1 0 7 1 0 2013 1 0 5 1 0 2010 1 0 6 1 0 2018 1 1 13 1 0 2012 1 0 7 1 1 2022 1 0 9 1 0 2012 1 . 14 1 0 2018 1 0 8 1 0 2018 1 0 6 1 0 2013 1 1 14 1 0 2013 1 0 6 1 0 2018 1 0 7 1 1 2022 1 1 16 1 0 2013 1 . . 1 0 2013 1 . . 1 0 2013 1 . . 1 0 2016 1 0 8 1 1 2022 1 1 14 1 0 2010 1 1 16 1 0 2010 1 0 6 1 0 2012 1 1 12 1 1 2022 1 0 9 1 0 2010 1 . 4 1 0 2013 1 . 3 1 0 2013 1 0 10 1 1 2022 1 1 14 1 0 2018 1 0 8 1 0 2011 1 1 16 1 0 2011 1 0 10 1 1 2022 1 0 7 1 0 2011 1 0 10 1 0 2013 1 0 7 1 0 2013 1 0 8 1 1 2022 1 0 10 1 0 2013 1 1 15 1 0 2011 1 0 13 1 1 2022 1 1 15 1 0 2018 1 0 10 1 0 2011 1 0 5 1 0 2016 1 0 7 1 0 2011 1 0 13 1 0 2010 1 . . 1 0 2018 1 1 16 1 0 2012 1 . 4 1 0 2016 1 0 8 1 1 2022 1 0 5 1 0 2010 1 . 9 1 1 2022 1 0 11 1 0 2016 1 0 9 1 1 2022 1 1 12 1 0 2012 1 . . 1 0 2011 1 . . 1 0 2018 1 0 7 1 0 2011 1 0 5 1 0 2010 1 . 4 1 0 2014 1 0 16 1 0 2018 1 . . 1 0 2014 1 0 11 1 0 2016 1 . 5 1 0 2016 1 1 15 1 0 2012 1 1 14 1 0 2012 1 1 10 1 0 2012 1 . 4 1 0 2016 1 . 4 1 1 2022 1 . . 1 0 2018 1 0 9 1 0 2018 1 1 13 1 0 2011 1 . 8 1 0 2013 1 . . 1 0 2013 1 1 13 1 0 2013 1 0 10 1 1 2022 1 0 12 1 0 2011 1 0 10 1 0 2016 1 . 8 1 0 2016 1 . . 1 0 2014 1 1 16 1 0 2012 1 1 15 1 0 2013 1 1 16 1 0 2013 1 1 13 1 0 2012 1 1 15 1 0 2010 1 0 11 1 0 2018 1 . . 1 0 2016 1 . . 1 0 2013 1 . 4 1 0 2010 1 1 15 1 0 2013 1 0 7 1 0 2014 1 . 11 1 0 2013 1 0 10 1 0 2018 1 . 15 1 0 2018 1 0 13 1 0 2014 1 0 11 1 1 2022 1 1 16 1 0 2011 1 . 3 1 0 2018 1 0 5 1 0 2012 1 end
Code:
gen treatpost=treat*(year>2018) reghdfe y1 x1 treatpost i.year if year>=2014, absorb(_id) vce(cluster _id)
How can I test for parallel trends using -reghdfe-? I am unable to use didregress because my dataset is large and didregress is taking hours to work.
I posted a different query on parallel trends on https://www.statalist.org/forums/for...ss-and-reghdfe but I am still confused how to apply the solution to my real data. Specifically I am not sure why are the -evertreated- and -pretreat- variables needed. Can I just do it with:
Code:
reghdfe y1 x1 treatpost i.year if year<2014, absorb(_id) vce(cluster _id)
Comment