Hi,
I need your help. I seek to do a mediation analysis via the gsem command in Stata 14. What I try to manage is to get Stata to output odds ratios instead of unstandardized coefficients. This easily works for my main model via estat eform, but not for the “manually”, post-estimated direct, indirect and total effects.
The syntax of the main model is:
gsem (isced -> ph, family(bernoulli) link(logit)) (isced -> mh, family(bernoulli) link(logit)) (isced -> schm_wö30d, family(bernoulli) link(logit)) (isced -> schlber_wö30d, family(bernoulli) link(logit)) (ph -> schm_wö30d, family(bernoulli) link(logit)) (ph -> schlber_wö30d, family(bernoulli) link(logit)) (mh -> schm_wö30d, family(bernoulli) link(logit)) (mh -> schlber_wö30d, family(bernoulli) link(logit)) [pweight = gewichtung], nocapslatent
[Explanation: isced=educational level (ordinal, 3 groups: low, medium, high); ph=physical health (binary: 0, 1); mh=mental health (binary: 0, 1); schm_wö30d=weekly anagesics use (binary: 0, 1), schlber_wö30d=weekly sedatives use (binary: 0, 1)]
In order to test if ph and/or mh has a mediating effect on the relation between isced and schm_wö30d or schlber_wö30d, I “manually” calculated direct, indirect and total effects via nlcom, as you can see in the following:
***ph -> schm_wö30d***
*direct effect
nlcom _b[schm_wö30d:isced]
*indirect effect
nlcom _b[schm_wö30d:ph]*_b[ph:isced]
*total effect
nlcom _b[schm_wö30d:isced]+_b[schm_wö30d:ph]*_b[ph:isced]+_b[schm_wö30d:mh]*_b[mh:isced]
***ph -> schlber_wö30d***
*direct effect
nlcom _b[schlber_wö30d:isced]
*indirect effect
nlcom _b[schlber_wö30d:ph]*_b[ph:isced]
*total effect
nlcom _b[schlber_wö30d:isced]+_b[schlber_wö30d:ph]*_b[ph:isced]+_b[schlber_wö30d:mh]*_b[mh:isced]
***mh -> schm_wö30d***
*direct effect
nlcom _b[schm_wö30d:isced]
*indirect effect
nlcom _b[schm_wö30d:mh]*_b[mh:isced]
*total effect
nlcom _b[schm_wö30d:isced]+_b[schm_wö30d:mh]*_b[mh:isced]+_b[schm_wö30d:ph]*_b[ph:isced]
***mh -> schlber_wö30d***
*direct effect
nlcom _b[schlber_wö30d:isced]
*indirect effect
nlcom _b[schlber_wö30d:mh]*_b[mh:isced]
*total effect
nlcom _b[schlber_wö30d:isced]+_b[schlber_wö30d:mh]*_b[mh:isced]+_b[schlber_wö30d:ph]*_b[ph:isced]
According to the estat eform command, I now seek to transform the coefficients which I produced via nlcom from unstandardized coefficients to odds ratios.
I tried to solve this via injecting exp(…) into the nlcom command (e.g. nlcom exp(_b[schm_wö30d:ph]*_b[ph:isced])), but unfortunately this seems to be the wrong way (p-values and ci’s of direct effects differ from those in the main model)…
Is there a way to correctly transform the coefficients from unstandardized to odds ratios (or to output OR’s directly)?
Or is there a better way to do this mediation analysis in Stata, e.g. via the svy-prefix?
Many many thanks in advance for your help!
I need your help. I seek to do a mediation analysis via the gsem command in Stata 14. What I try to manage is to get Stata to output odds ratios instead of unstandardized coefficients. This easily works for my main model via estat eform, but not for the “manually”, post-estimated direct, indirect and total effects.
The syntax of the main model is:
gsem (isced -> ph, family(bernoulli) link(logit)) (isced -> mh, family(bernoulli) link(logit)) (isced -> schm_wö30d, family(bernoulli) link(logit)) (isced -> schlber_wö30d, family(bernoulli) link(logit)) (ph -> schm_wö30d, family(bernoulli) link(logit)) (ph -> schlber_wö30d, family(bernoulli) link(logit)) (mh -> schm_wö30d, family(bernoulli) link(logit)) (mh -> schlber_wö30d, family(bernoulli) link(logit)) [pweight = gewichtung], nocapslatent
[Explanation: isced=educational level (ordinal, 3 groups: low, medium, high); ph=physical health (binary: 0, 1); mh=mental health (binary: 0, 1); schm_wö30d=weekly anagesics use (binary: 0, 1), schlber_wö30d=weekly sedatives use (binary: 0, 1)]
In order to test if ph and/or mh has a mediating effect on the relation between isced and schm_wö30d or schlber_wö30d, I “manually” calculated direct, indirect and total effects via nlcom, as you can see in the following:
***ph -> schm_wö30d***
*direct effect
nlcom _b[schm_wö30d:isced]
*indirect effect
nlcom _b[schm_wö30d:ph]*_b[ph:isced]
*total effect
nlcom _b[schm_wö30d:isced]+_b[schm_wö30d:ph]*_b[ph:isced]+_b[schm_wö30d:mh]*_b[mh:isced]
***ph -> schlber_wö30d***
*direct effect
nlcom _b[schlber_wö30d:isced]
*indirect effect
nlcom _b[schlber_wö30d:ph]*_b[ph:isced]
*total effect
nlcom _b[schlber_wö30d:isced]+_b[schlber_wö30d:ph]*_b[ph:isced]+_b[schlber_wö30d:mh]*_b[mh:isced]
***mh -> schm_wö30d***
*direct effect
nlcom _b[schm_wö30d:isced]
*indirect effect
nlcom _b[schm_wö30d:mh]*_b[mh:isced]
*total effect
nlcom _b[schm_wö30d:isced]+_b[schm_wö30d:mh]*_b[mh:isced]+_b[schm_wö30d:ph]*_b[ph:isced]
***mh -> schlber_wö30d***
*direct effect
nlcom _b[schlber_wö30d:isced]
*indirect effect
nlcom _b[schlber_wö30d:mh]*_b[mh:isced]
*total effect
nlcom _b[schlber_wö30d:isced]+_b[schlber_wö30d:mh]*_b[mh:isced]+_b[schlber_wö30d:ph]*_b[ph:isced]
According to the estat eform command, I now seek to transform the coefficients which I produced via nlcom from unstandardized coefficients to odds ratios.
I tried to solve this via injecting exp(…) into the nlcom command (e.g. nlcom exp(_b[schm_wö30d:ph]*_b[ph:isced])), but unfortunately this seems to be the wrong way (p-values and ci’s of direct effects differ from those in the main model)…
Is there a way to correctly transform the coefficients from unstandardized to odds ratios (or to output OR’s directly)?
Or is there a better way to do this mediation analysis in Stata, e.g. via the svy-prefix?
Many many thanks in advance for your help!
Comment