Hi there,
I've been trying to use margins to estimate the pre- and post-treatment trends in a difference-in-differences model on a state-level intervention using data from several years and states. I have run into a bit of a quirk with margins, and am curious as to whether anyone has an insight into it.
Given the following regression,
where treat is an indicator for treatment status, and time is an indicator for pre/post treatment period, and did is an interaction term between the two, I have used margins like this:
The third line gives a difference-in-differences estimate that is close to, but not the same as the coefficient in the original regression—which it should be. I don't trust the results from the other two lines because of this, either. This issue is solved when I code it instead
This wouldn't be an issue at all, except in my preferred regression I use state and quarter-year fixed effects and omit the main effects treat and time from the regression, so using the latter coding scheme for margins doesn't work.
Does anyone know why this happens, and if there's any way around it? I'd love to be able to present regression-adjusted pre- and post-treatment means using my fixed effects model. Thanks!
I've been trying to use margins to estimate the pre- and post-treatment trends in a difference-in-differences model on a state-level intervention using data from several years and states. I have run into a bit of a quirk with margins, and am curious as to whether anyone has an insight into it.
Given the following regression,
Code:
regress outcome did treat time
Code:
margins, over(treat time) margins, over(treat time) pwcompare margins, over(r.treat r.time)
Code:
margins treat, over(time) margins treat, over(time) pwcompare margins r.treat, over(r.time)
Does anyone know why this happens, and if there's any way around it? I'd love to be able to present regression-adjusted pre- and post-treatment means using my fixed effects model. Thanks!
Comment