I am using -didregress- and -reghdfe- (ssc install) to run DID regression (Stata 17). Sample data given below (courtesy Data Hall Youtube channel)
The -did- variable is the interaction between treatment and after (time). I am trying to replicate the results from didregress and reghdfe. The following two commands give me the same result.
I am also trying to test parallel trends assumption. With -didregress- it is simple.
Can I replicate this with reghdfe? I tried
How do I "match" this with what estat ptrends gives me?
Edit: I went through the Statalist post here https://www.statalist.org/forums/for...r-trends-model but couldn't understand how to apply it to my model.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte(patient after) float after2 byte treatment int bp byte(age sleep) float did 1 -1 0 1 143 47 5 0 1 0 1 1 153 49 5 0 1 1 2 1 125 49 5 1 2 -1 0 1 153 47 5 0 2 0 1 1 146 44 7 0 2 1 2 1 130 44 7 1 3 -1 0 1 152 59 4 0 3 0 1 1 150 52 4 0 3 1 2 1 132 52 4 1 4 -1 0 1 126 59 4 0 4 0 1 1 148 50 5 0 4 1 2 1 120 50 5 1 5 -1 0 1 141 40 6 0 5 0 1 1 153 53 5 0 5 1 2 1 132 53 5 1 6 -1 0 1 162 40 6 0 6 0 1 1 153 44 6 0 6 1 2 1 120 44 6 1 7 -1 0 1 176 59 6 0 7 0 1 1 158 51 6 0 7 1 2 1 125 51 6 1 8 -1 0 1 134 59 6 0 8 0 1 1 149 56 6 0 8 1 2 1 130 56 6 1 9 -1 0 1 143 41 6 0 9 0 1 1 173 49 7 0 10 1 2 1 133 49 7 1 10 -1 0 1 136 41 6 0 11 0 1 1 165 48 4 0 11 1 2 1 135 48 4 1 11 -1 0 0 148 51 4 0 12 0 1 0 158 59 8 0 12 1 2 0 159 59 8 0 12 -1 0 0 158 51 4 0 13 0 1 0 151 47 5 0 13 1 2 0 153 47 5 0 13 -1 0 0 157 48 5 0 14 0 1 0 155 59 4 0 14 1 2 0 126 59 4 0 14 -1 0 0 131 48 5 0 15 0 1 0 153 40 6 0 15 1 2 0 162 40 6 0 15 -1 0 0 146 40 5 0 16 0 1 0 158 59 6 0 16 1 2 0 134 59 6 0 16 -1 0 0 167 40 5 0 17 0 1 0 158 41 6 0 17 1 2 0 136 41 6 0 17 -1 0 0 181 40 6 0 18 0 1 0 163 51 4 0 18 1 2 0 150 51 4 0 18 -1 0 0 139 59 6 0 19 0 1 0 154 48 5 0 19 1 2 0 168 48 5 0 19 -1 0 0 148 59 6 0 20 0 1 0 178 40 5 0 20 1 2 0 155 40 5 0 20 -1 0 0 141 41 6 0 21 0 1 0 170 59 8 0 21 1 2 0 136 59 8 0 21 -1 0 0 136 41 6 0 22 0 1 0 159 59 6 0 22 1 2 0 132 59 6 0 22 -1 0 0 162 51 4 0 23 0 1 0 164 47 4 0 23 1 2 0 160 47 4 0 end
Code:
didregress (bp) (did), group(patient) time(after2) reghdfe bp did i.after2, absorb(i.patient)
Code:
estat ptrends
Code:
reghdfe bp i.treatment##i.after2 if after<1
Edit: I went through the Statalist post here https://www.statalist.org/forums/for...r-trends-model but couldn't understand how to apply it to my model.
Comment