Hi all,
I am trying to perform a mediation analysis using the gformula package in stata, but I am having issues with my boostrapping.
My dataset contains 189 observations. Exposure = w1RD (binary indicator), Mediator = w2CR_lg_postorth, (continuous), Outcome = w3smoking (binary indicator). I have two intermediate confounders (i.e. variables which confound the mediator and outcome relationship but are predicted by the exposure), I also have 5 baseline confounders.
This is my gformula code (without imputation for the time being):
gformula w1RD_bin w3smoking w2CR_lg_postorth w1sex w1age w2smoking w2bingedrinking w1smoking w1house_inc w1degreestat ,mediation exposure(w1RD_bin) mediator(w2CR_lg_postorth) outcome(w3smoking) base_confs(w1sex w1age w1smoking w1house_inc w1degreestat) post_confs( w2smoking w2bingedrinking ) obe equations(w3smoking: i.w1RD_bin w2CR_lg_postorth i.w1sex w1age i.w2smoking i.w2bingedrinking i.w1smoking w1house_inc w1degreestat , w2CR_lg_postorth: i.w1RD_bin i.w1sex w1age i.w2smoking i.w2bingedrinking i.w1smoking w1house_inc w1degreestat, w2smoking: i.w1RD_bin w1age i.w1sex w1house_inc i.w1smoking w1degreestat, w2bingedrinking: i.w1RD_bin w1age i.w1sex i.w1smoking w1house_inc w1degreestat) commands(w3smoking: logit, w2CR_lg_postorth: regress, w2smoking: logit, w2bingedrinking: logit ) simulations(100) samples(1000) seed(8)
This code will return estimates, however on the boostrapping output it states that an error occurred when boostrapping.
Bootstrapping:
(running gformula_ on estimation sample)
Bootstrap replications (1,000): .........10.........20.........30.........x..x.... ..50.........60....xxx..70.........80..
> ...x...90...x.....100..x......110......x..120.x... ..x.130.x..x..x.140.xx......150.........160..x..x. ..x.........180....
> ..x..190..x....xx200..x......210x........220...... ..x230..x......240...x.....250...x.x...260........ .270.........280...
> ......290.........300.........310.........320..x.. ...x330.......x.340....x...x350.........360....... ..370.........380..
> x......390x...x....400.x.......410.........420.... .....430........x440.......x.450.........460...x.. x..470.........480.
> ........490.........500....x....510.........520... x.....530.........540x........550.........560..... ..x.570....x...x580
> ...x.....590....x....600.........610.......x.620.. .......x....x....640.x...xx..650.........660...... ...670.........680.
> ...x....690......x..700x........710.......x.720... ......730.........740.....x...750.........760x.... ....770........x780
> .........790.....x...800..x......810.........820.. .......830.........840.........850x..x.....860.... .....870.........88
> 0.........890.........900.....x...910........x920. ........930....x...x940.........950.........960.x. ......970......x..9
> 80.........990.....x...1,000 done
x: Error occurred when bootstrap executed gformula_.
I thought this may be due to my outcome (w3smoking) having a low prevalence (39 smokers out of 189). So i checked this by running a simple logistic regression with w3smoking as my outcome, including all my exposure, mediator and confounders and then boostrapped this : ( bootstrap, reps(200) seed(123): logit w3smoking i.w1RD_bin w2CR_lg_postorth i.w1sex i.w1age i.w1smoking i.w2smoking i.w1housinc_quart i.w2bingedrinking
This returned the error message: Bootstrap replications (200): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxx done
x: Error occurred when bootstrap executed logit.
insufficient observations to compute bootstrap standard errors; no results will be saved
To my understanding, this affirms my assumption that the boostrapping in failing due to a 'rare' outcome. I then reran this model unadjusted (just exposure and mediator and no confounders) and the boostrapping worked successfully. However, this is not a sufficient conceptual model to run due to the presence of confounding, particularly intermediate confounding.
Does this mean I am essentially unable to use gformula to test my mediation model?
Any guidance is greatly appreciated.
I am trying to perform a mediation analysis using the gformula package in stata, but I am having issues with my boostrapping.
My dataset contains 189 observations. Exposure = w1RD (binary indicator), Mediator = w2CR_lg_postorth, (continuous), Outcome = w3smoking (binary indicator). I have two intermediate confounders (i.e. variables which confound the mediator and outcome relationship but are predicted by the exposure), I also have 5 baseline confounders.
This is my gformula code (without imputation for the time being):
gformula w1RD_bin w3smoking w2CR_lg_postorth w1sex w1age w2smoking w2bingedrinking w1smoking w1house_inc w1degreestat ,mediation exposure(w1RD_bin) mediator(w2CR_lg_postorth) outcome(w3smoking) base_confs(w1sex w1age w1smoking w1house_inc w1degreestat) post_confs( w2smoking w2bingedrinking ) obe equations(w3smoking: i.w1RD_bin w2CR_lg_postorth i.w1sex w1age i.w2smoking i.w2bingedrinking i.w1smoking w1house_inc w1degreestat , w2CR_lg_postorth: i.w1RD_bin i.w1sex w1age i.w2smoking i.w2bingedrinking i.w1smoking w1house_inc w1degreestat, w2smoking: i.w1RD_bin w1age i.w1sex w1house_inc i.w1smoking w1degreestat, w2bingedrinking: i.w1RD_bin w1age i.w1sex i.w1smoking w1house_inc w1degreestat) commands(w3smoking: logit, w2CR_lg_postorth: regress, w2smoking: logit, w2bingedrinking: logit ) simulations(100) samples(1000) seed(8)
This code will return estimates, however on the boostrapping output it states that an error occurred when boostrapping.
Bootstrapping:
(running gformula_ on estimation sample)
Bootstrap replications (1,000): .........10.........20.........30.........x..x.... ..50.........60....xxx..70.........80..
> ...x...90...x.....100..x......110......x..120.x... ..x.130.x..x..x.140.xx......150.........160..x..x. ..x.........180....
> ..x..190..x....xx200..x......210x........220...... ..x230..x......240...x.....250...x.x...260........ .270.........280...
> ......290.........300.........310.........320..x.. ...x330.......x.340....x...x350.........360....... ..370.........380..
> x......390x...x....400.x.......410.........420.... .....430........x440.......x.450.........460...x.. x..470.........480.
> ........490.........500....x....510.........520... x.....530.........540x........550.........560..... ..x.570....x...x580
> ...x.....590....x....600.........610.......x.620.. .......x....x....640.x...xx..650.........660...... ...670.........680.
> ...x....690......x..700x........710.......x.720... ......730.........740.....x...750.........760x.... ....770........x780
> .........790.....x...800..x......810.........820.. .......830.........840.........850x..x.....860.... .....870.........88
> 0.........890.........900.....x...910........x920. ........930....x...x940.........950.........960.x. ......970......x..9
> 80.........990.....x...1,000 done
x: Error occurred when bootstrap executed gformula_.
I thought this may be due to my outcome (w3smoking) having a low prevalence (39 smokers out of 189). So i checked this by running a simple logistic regression with w3smoking as my outcome, including all my exposure, mediator and confounders and then boostrapped this : ( bootstrap, reps(200) seed(123): logit w3smoking i.w1RD_bin w2CR_lg_postorth i.w1sex i.w1age i.w1smoking i.w2smoking i.w1housinc_quart i.w2bingedrinking
This returned the error message: Bootstrap replications (200): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxx done
x: Error occurred when bootstrap executed logit.
insufficient observations to compute bootstrap standard errors; no results will be saved
To my understanding, this affirms my assumption that the boostrapping in failing due to a 'rare' outcome. I then reran this model unadjusted (just exposure and mediator and no confounders) and the boostrapping worked successfully. However, this is not a sufficient conceptual model to run due to the presence of confounding, particularly intermediate confounding.
Does this mean I am essentially unable to use gformula to test my mediation model?
Any guidance is greatly appreciated.

Comment