Hi all,
I am new to using the margins in Stata and non linear models for a difference-in differences analysis. I need help to verify I am using margins correctly and how to interpret margins results in this context. I have two groups (treatment and control) and three periods (pre,post1, and post2)
Code:
qui: svy, subpop(analytic2): twopm nvis_psychamb i.treat##i.period $xvar, firstpart(logit) secondpart(glm, f(gamma) link(log)) baselevels
eststo px :margins i.treat#i.period, subpop(analytic2) coeflegend post
nlcom (pre : _b[0.treat#0.period]) ///
(post1: _b[0.treat#1.period]) ///
(post2: _b[0.treat#2.period]) ///
(d1: _b[0.treat#1.period] - _b[0.treat#0.period]) ///
(d2: _b[0.treat#2.period] - _b[0.treat#0.period]) ///
, post
eststo pn1
est restore px
nlcom (pre : _b[1.treat#0.period]) ///
(post1: _b[1.treat#1.period]) ///
(post2: _b[1.treat#2.period]) ///
(d1: _b[1.treat#1.period] - _b[1.treat#0.period]) ///
(d2: _b[1.treat#2.period] - _b[1.treat#0.period]) ///
, post
eststo pn2
est restore px
nlcom (DD1: (_b[1.treat#1.period] - _b[1.treat#0bn.period]) - (_b[0bn.treat#1.period] - _b[0bn.treat#0bn.period]) ) ///
(DD2: (_b[1.treat#2.period] - _b[1.treat#0bn.period]) - (_b[0bn.treat#2.period] - _b[0bn.treat#0bn.period]) ) ///
, post
eststo pn3
esttab pn1 pn2 pn3, b(3) ci(3) ///
mtitles("Control" "Treatment" " ")
Here is my Stata output
I am new to using the margins in Stata and non linear models for a difference-in differences analysis. I need help to verify I am using margins correctly and how to interpret margins results in this context. I have two groups (treatment and control) and three periods (pre,post1, and post2)
Code:
qui: svy, subpop(analytic2): twopm nvis_psychamb i.treat##i.period $xvar, firstpart(logit) secondpart(glm, f(gamma) link(log)) baselevels
eststo px :margins i.treat#i.period, subpop(analytic2) coeflegend post
nlcom (pre : _b[0.treat#0.period]) ///
(post1: _b[0.treat#1.period]) ///
(post2: _b[0.treat#2.period]) ///
(d1: _b[0.treat#1.period] - _b[0.treat#0.period]) ///
(d2: _b[0.treat#2.period] - _b[0.treat#0.period]) ///
, post
eststo pn1
est restore px
nlcom (pre : _b[1.treat#0.period]) ///
(post1: _b[1.treat#1.period]) ///
(post2: _b[1.treat#2.period]) ///
(d1: _b[1.treat#1.period] - _b[1.treat#0.period]) ///
(d2: _b[1.treat#2.period] - _b[1.treat#0.period]) ///
, post
eststo pn2
est restore px
nlcom (DD1: (_b[1.treat#1.period] - _b[1.treat#0bn.period]) - (_b[0bn.treat#1.period] - _b[0bn.treat#0bn.period]) ) ///
(DD2: (_b[1.treat#2.period] - _b[1.treat#0bn.period]) - (_b[0bn.treat#2.period] - _b[0bn.treat#0bn.period]) ) ///
, post
eststo pn3
esttab pn1 pn2 pn3, b(3) ci(3) ///
mtitles("Control" "Treatment" " ")
Here is my Stata output