Dear Statalist users,
I'm trying to estimate the mediating effect of several early life variables (e.g., birthweight standardized for gestation=bweightz, breastfeeding=bfed, etc.) through which smoking in pregnancy=smokingm may be affecting the menopause timing=early_menopause, controlling for social class at birth=bses. I'm using the IOW method described by Nguyen et al 2015 (10.1093/aje/kwu278), adopting their stata code. The method is also applied here: 10.1136/bmjopen-2018-026258 and stata code has been made available, so I've referred to this too.
My code is as follows (where the outcome is early menopause coded 0/1, the exposure is smoking in pregnancy coded 0/1, mediators - birthweight z-scores and breastfeeding coded 0/1, and social class at birth coded as 0/1 controlled for as a confounder) and n=2,450:
*IOW:
*Define a user-written program to estimate mediation parameters
capture program drop IOW
program IOW, rclass
capture drop logodds predprob inverseodds wt_iow
*Run exposure model
logit smokingm bweightz i.bfed i.bses,or
*Create inverse odds weights
predict logodds,xb
gen predprob=exp(logodds)/(1+exp(logodds))
gen inverseodds = ((1-predprob)/predprob)
gen wt_iow = 1 if smokingm==0
replace wt_iow = inverseodds if smokingm==1
*Estimate TE
glm early_menopause i.smokingm i.bses, fam(binomial) link(log) vce(robust) eform nolog base
matrix bb_total = e(b)
scalar b_total = bb_total[1,1]
return scalar b_total = bb_total[1,1]
*Estimate NDE
glm early_menopause i.smokingm i.bses [pweight=wt_iow], fam(binomial) link(log) vce(robust) eform nolog base
matrix bb_direct = e(b)
scalar b_direct = bb_direct[1,1]
return scalar b_direct = bb_direct[1,1]
*Estimate NIE
return scalar b_indirect = b_total-b_direct
end
* Request bootstrapped estimates of indirect, direct and total effects.
bootstrap r(b_indirect) r(b_direct) r(b_total), seed(32222) reps(1000) nodrop: IOW
estat bootstrap, all
This returns coefficients of 0 and omitted standard errors i.e. no bootstrap results, and I don't know why that is. I would really appreciate your help if you've had this issue too.
I'm trying to make this work using logistic regression, but will subsequently perform on imputed data and in a time to event setting (as in 10.1136/bmjopen-2018-026258). I have estimated these effects using ldecomp (Buis, M. 2010; 10.1177/1536867X1001000104), but noting the imputation and the survival setting, the method above will be more appropriate for my analysis, in my opinion.
Thanks for your help.
Kind regards,
Darina
This is the output from dataex if this could help:
I'm trying to estimate the mediating effect of several early life variables (e.g., birthweight standardized for gestation=bweightz, breastfeeding=bfed, etc.) through which smoking in pregnancy=smokingm may be affecting the menopause timing=early_menopause, controlling for social class at birth=bses. I'm using the IOW method described by Nguyen et al 2015 (10.1093/aje/kwu278), adopting their stata code. The method is also applied here: 10.1136/bmjopen-2018-026258 and stata code has been made available, so I've referred to this too.
My code is as follows (where the outcome is early menopause coded 0/1, the exposure is smoking in pregnancy coded 0/1, mediators - birthweight z-scores and breastfeeding coded 0/1, and social class at birth coded as 0/1 controlled for as a confounder) and n=2,450:
*IOW:
*Define a user-written program to estimate mediation parameters
capture program drop IOW
program IOW, rclass
capture drop logodds predprob inverseodds wt_iow
*Run exposure model
logit smokingm bweightz i.bfed i.bses,or
*Create inverse odds weights
predict logodds,xb
gen predprob=exp(logodds)/(1+exp(logodds))
gen inverseodds = ((1-predprob)/predprob)
gen wt_iow = 1 if smokingm==0
replace wt_iow = inverseodds if smokingm==1
*Estimate TE
glm early_menopause i.smokingm i.bses, fam(binomial) link(log) vce(robust) eform nolog base
matrix bb_total = e(b)
scalar b_total = bb_total[1,1]
return scalar b_total = bb_total[1,1]
*Estimate NDE
glm early_menopause i.smokingm i.bses [pweight=wt_iow], fam(binomial) link(log) vce(robust) eform nolog base
matrix bb_direct = e(b)
scalar b_direct = bb_direct[1,1]
return scalar b_direct = bb_direct[1,1]
*Estimate NIE
return scalar b_indirect = b_total-b_direct
end
* Request bootstrapped estimates of indirect, direct and total effects.
bootstrap r(b_indirect) r(b_direct) r(b_total), seed(32222) reps(1000) nodrop: IOW
estat bootstrap, all
This returns coefficients of 0 and omitted standard errors i.e. no bootstrap results, and I don't know why that is. I would really appreciate your help if you've had this issue too.
I'm trying to make this work using logistic regression, but will subsequently perform on imputed data and in a time to event setting (as in 10.1136/bmjopen-2018-026258). I have estimated these effects using ldecomp (Buis, M. 2010; 10.1177/1536867X1001000104), but noting the imputation and the survival setting, the method above will be more appropriate for my analysis, in my opinion.
Thanks for your help.
Kind regards,
Darina
This is the output from dataex if this could help:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(bweightz early_menopause) byte(bses bfed smokingm _randomtag) -.210943 0 0 0 0 0 -1.0437096 0 1 0 1 0 -1.048419 0 0 1 0 0 -.9111431 0 1 0 1 0 -2.2724223 0 1 0 1 0 -.14652179 0 1 0 1 0 -.710833 1 1 1 1 0 .3924279 0 1 1 0 0 .454743 0 0 0 1 0 1.4280024 0 0 0 1 0 .0467419 0 1 1 1 0 1.5069565 0 0 1 0 0 -.2627374 0 1 0 1 0 .7768492 0 1 0 0 0 .3503493 0 0 1 0 0 -.3349975 0 1 0 0 0 .45871115 0 0 0 1 0 -1.9937698 0 1 0 1 0 -.56668586 0 1 0 1 0 -.4471542 0 1 1 0 0 .7261847 0 1 0 1 0 .45871115 0 0 0 1 0 -.14652179 0 1 0 0 0 .5691833 0 0 0 0 0 .06101154 0 1 0 0 0 -1.1128402 0 0 0 1 0 -.18289313 0 1 0 1 0 .34242785 0 0 0 1 0 -1.0054715 0 1 0 1 0 -.382733 0 1 0 0 0 -.210943 1 1 0 1 0 -.2627374 0 1 0 0 0 -.5576323 0 0 0 1 0 .08310597 0 1 1 0 0 -.017679332 0 0 1 0 0 -.7771568 0 1 0 1 0 -.6013076 0 1 0 1 0 -1.1275387 0 1 0 1 0 .04121107 0 1 1 0 0 .4944934 0 1 0 0 0 -.5339692 0 0 1 1 0 .21853185 0 0 0 0 0 -.56668586 0 0 1 0 0 -1.0937463 1 1 0 1 0 .39311635 1 0 0 1 0 2.167214 0 1 0 1 0 -.5115754 0 1 1 0 0 -.7051345 0 0 0 0 0 1.356198 0 1 1 1 0 .43200195 0 1 0 1 0 -.210943 0 0 1 0 0 .0467419 1 1 0 0 0 .6056868 0 0 1 1 0 -1.6181647 0 1 0 1 0 -1.1444348 0 1 0 0 0 .05519302 0 1 1 1 0 .10588152 1 0 0 1 0 .5691833 0 0 0 0 0 -.5115754 0 1 1 0 0 -.4676453 0 1 0 1 0 .08310597 0 1 1 0 0 .43200195 0 1 1 1 0 -.7343877 0 1 1 0 0 .34242785 0 1 0 0 0 .3261446 0 1 0 0 0 -.8766291 0 1 0 0 0 -1.6181647 0 1 0 1 0 -1.0437096 0 0 1 0 0 1.0774815 0 1 0 0 0 -.5576323 0 1 0 1 0 -.210943 0 1 0 1 0 .20725852 0 1 0 0 0 .6354665 0 1 1 1 0 -.8434807 0 0 0 1 0 -1.1762762 0 1 0 0 0 -1.5509355 0 1 0 1 0 -.1813533 0 1 1 0 0 -.7048391 1 1 0 1 0 .10716172 0 0 1 0 0 -.57599664 0 1 0 1 0 .51916426 0 1 1 0 0 -.15813383 0 0 0 1 0 2.712342 0 1 0 0 0 -.57599664 0 1 0 0 0 .454743 0 0 0 0 0 -.3349975 0 1 0 0 0 -.9774264 0 1 0 1 0 -2.839825 0 0 0 0 0 -1.370525 0 0 0 0 0 .21770154 0 1 1 0 0 .3061334 0 1 0 1 0 .2156725 0 0 0 0 0 -.7389268 0 1 0 0 0 -.4013214 0 1 0 0 0 .5691833 0 1 0 1 0 .39311635 0 1 0 0 0 -.27536425 0 1 0 1 0 -.3587825 0 1 0 1 0 -1.1529922 0 1 1 0 0 .454743 0 0 1 0 0 end label values bses manual_nof label def manual_nof 0 "non-manual", modify label def manual_nof 1 "manual or no father figure", modify label values bfed bfed label def bfed 0 "never_or_<1m", modify label def bfed 1 "1m+", modify
Comment