Dear statalists,
I tried to use mediate command in Stata 18, and found that the results are different between mediate and paramed when I used a binary outcome and a binary mediator.
When I did the same analysis by hand with logit and postestimations, the results are same as paramed.
Why are there such differences? I guess mediate uses different aproach, but I have no idea.
There is an example:
Calculate by hand, following to the formula in Explanation in Tyler J. Vanderweele. Causal Inference: Methods for Mediation and Interaction, p29
I tried to use mediate command in Stata 18, and found that the results are different between mediate and paramed when I used a binary outcome and a binary mediator.
When I did the same analysis by hand with logit and postestimations, the results are same as paramed.
Why are there such differences? I guess mediate uses different aproach, but I have no idea.
There is an example:
Code:
use https://www.stata-press.com/data/r18/wellbeing, clear *mediate Stata 18 mediate (bwellbeing age, logit) (bbonotonin age, logit) (exercise), pomeans nde nie te estat or *paramed paramed bwellbeing, avar(exercise) mvar(bbonotonin) a0(0) a1(1) m(0) yreg(logistic) mreg(logistic) cvars(age) // results are different
Calculate by hand, following to the formula in Explanation in Tyler J. Vanderweele. Causal Inference: Methods for Mediation and Interaction, p29
Code:
*fit outcome model logit bwellbeing i.exercise##c.bbonotonin age sca theta1 = _b[1.exercise] sca theta2 = _b[bbonotonin] sca theta3 = _b[1.exercise#c.bbonotonin] sca theta4 = _b[age] *fit mediator model logit bbonotonin i.exercise age sca beta0 = _b[_cons] sca beta1 = _b[1.exercise] sca beta2 = _b[age] *define other values sca aint = 1 sca astar = 0 qui sum age sca cmean = `r(mean)' di "NDE_OR = " = (exp(theta1*aint) *(1 + exp(theta2 + theta3*aint + beta0 + beta1*astar + beta2*cmean))) / /// (exp(theta1*astar)*(1 + exp(theta2 + theta3*astar + beta0 + beta1*astar + beta2*cmean))) di "NIE_OR = " = ((1 + exp(beta0 + beta1*astar + beta2*cmean))*(1 + exp(theta2 + theta3*aint + beta0 + beta1*aint + beta2*cmean))) / /// ((1 + exp(beta0 + beta1*aint + beta2*cmean))*(1 + exp(theta2 + theta3*aint + beta0 + beta1*astar + beta2*cmean))) // results are the same as paramed
Comment