Hello
I am using Stata 14.1 and am having trouble creating a certain type of figure and have not been able to figure it out in Stata.
I want to display OR's from a logistic regression model on the y-axis over a continuous variable on the x-axis by a secondary dichotomous variable.
For example, I want to display all the OR's from logistic regression models of the relationship between the development of tuberculosis and BCG vaccination -- over a third variable that is continuous, which we can say is age here. On the x-axis would be age. On the y-axis would be OR's. The reference would be "No vaccination" and the OR's would show the increased odds of tuberculosis among BCG vaccinated individuals over age. I understand this would need to be done with some sort of smoothed curve.
__________________________________________________ __________________________________________________ ____
To give you an example of what I am trying to create see below
,
From the article "Strength of the Association of Elevated Vitamin B12 and Solid Cancers: An Adjusted Case-Control Study" in the journal J. Clin. Med. 2020, 9, 474.
Another example is:

From the article "Dietary carbohydrate intake, glycaemic index, glycaemic load and digestive system cancers: an updated dose–response meta-analysis"
Cai, X., Li, X., Tang, M., Liang, C., Xu, Y., Zhang, M., Yu, W. and Li, X., 2019. Dietary carbohydrate intake, glycaemic index, glycaemic load and digestive system cancers: an updated dose–response meta-analysis. British Journal of Nutrition, 121(10), pp.1081-1096
__________________________________________________ __________________________________________________ __________________________________________________ ____
I'm able to show multiple odds ratios for differing age groups using the 'coefplots' command and here is my code and graph for that graph.
Figure. Risk of Death Among BCG Vaccinated and Unvaccinated Children, Stratified by Age Groups

But I would like to create a graph that treats age as a continuous variable and is able to smooth out the relative risk estimates over the continuous variable if possible. I have been unable to find any leads or ways to do this as of yet.
I'd appreciate any help you can offer.
Best
Leo
I am using Stata 14.1 and am having trouble creating a certain type of figure and have not been able to figure it out in Stata.
I want to display OR's from a logistic regression model on the y-axis over a continuous variable on the x-axis by a secondary dichotomous variable.
For example, I want to display all the OR's from logistic regression models of the relationship between the development of tuberculosis and BCG vaccination -- over a third variable that is continuous, which we can say is age here. On the x-axis would be age. On the y-axis would be OR's. The reference would be "No vaccination" and the OR's would show the increased odds of tuberculosis among BCG vaccinated individuals over age. I understand this would need to be done with some sort of smoothed curve.
__________________________________________________ __________________________________________________ ____
To give you an example of what I am trying to create see below
,
From the article "Strength of the Association of Elevated Vitamin B12 and Solid Cancers: An Adjusted Case-Control Study" in the journal J. Clin. Med. 2020, 9, 474.
Another example is:
From the article "Dietary carbohydrate intake, glycaemic index, glycaemic load and digestive system cancers: an updated dose–response meta-analysis"
Cai, X., Li, X., Tang, M., Liang, C., Xu, Y., Zhang, M., Yu, W. and Li, X., 2019. Dietary carbohydrate intake, glycaemic index, glycaemic load and digestive system cancers: an updated dose–response meta-analysis. British Journal of Nutrition, 121(10), pp.1081-1096
__________________________________________________ __________________________________________________ __________________________________________________ ____
I'm able to show multiple odds ratios for differing age groups using the 'coefplots' command and here is my code and graph for that graph.
Code:
#Running a logistic model for each age group and saving the estimates# melogit death_merg bcg_merg age_merg sex_cont_merg prosp_retro_merg if all_dis_merg<5 & age_merg<15 & age_merg>=10 ||study_new:, or estimates store death_bcg_3 melogit death_merg bcg_merg age_merg sex_cont_merg prosp_retro_merg if all_dis_merg<5 & age_merg<10 & age_merg>=5 ||study_new:, or estimates store death_bcg_2 melogit death_merg bcg_merg age_merg sex_cont_merg prosp_retro_merg if all_dis_merg<5 & age_merg<5 ||study_new:, or estimates store death_bcg_1 melogit death_merg bcg_merg age_merg sex_cont_merg prosp_retro_merg if all_dis_merg<5 & age_merg<150 & age_merg>=15 ||study_new:, or estimates store death_bcg_4 melogit death_merg bcg_merg age_merg sex_cont_merg prosp_retro_merg if all_dis_merg<5 ||study_new:, or estimates store death_bcg_5 #coefplot based on saved estimates# coefplot (death_bcg_5 , label("All Participants") mlabels(bcg_merged=1 "N=18175") mlabsize(small) mlabcolor(black) lpatt(solid)lcol(black)msym(d)mcol(black)ciopts(recast(. rcap)lcol(black)) drop(_cons age_merged sex_cont_merged prosp_retro_merged) xlabel(0.2 "0.2" 0.5 "0.5" 1 "1.0" 2 "2.0" 3.0 "3.0")) (death_bcg_1 , label("<5 years old") mlabels(bcg_merged=1 "N=4567") mlabsize(small) mlabcolor(black) lpatt(solid)lcol(brown)msym(d)mcol(brown)ciopts(recast(. rcap)lcol(brown)) drop(_cons age_merged sex_cont_merged prosp_retro_merged) xlabel(0.2 "0.2" 0.5 "0.5" 1 "1.0" 2 "2.0" 3.0 "3.0")) (death_bcg_2, label("5-9 years old") mlabels(bcg_merged=1 "N=6139") mlabsize(small) mlabcolor(black) lpatt(solid)lcol(maroon)msym(d)mcol(maroon)ciopts(recast(. rcap)lcol(maroon)) drop(_cons age_merged sex_cont_merged prosp_retro_merged) xlabel(0.2 "0.2" 0.5 "0.5" 1 "1.0" 2 "2.0" 3.0 "3.0")) (death_bcg_3, label("10-14 years old") mlabels(bcg_merged=1 "N=4632") mlabsize(small) mlabcolor(black) xlabel(0.2 "0.2" 0.5 "0.5" 1 "1.0" 2 "2.0" 3.0 "3.0") lpatt(solid)lcol(dkgreen)msym(d)mcol(dkgreen)ciopts(recast(. rcap)lcol(dkgreen)) drop(_cons age_merged sex_cont_merged prosp_retro_merged)) (death_bcg_4, label("≥15 years old") mlabels(bcg_merged=1 "N=2837") mlabsize(small) mlabcolor(black) xlabel(0.2 "0.2" 0.5 "0.5" 1 "1.0" 2 "2.0" 3.0 "3.0") lpatt(solid)lcol(navy)msym(d)mcol(navy)ciopts(recast(. rcap)lcol(navy)) drop(_cons age_merged sex_cont_merged prosp_retro_merged )), eform xline(1, lcolor(black) lwidth(thin) lpattern(dash)) xtitle(Odds Ratio) levels(95) msymbol(d) mfcolor(white) ciopts(recast(. rcap))legend(rows(8) ring(0) pos(2) col(1) size(3.5) region(fcolor(gs15))) graphregion(fcolor(white))
Figure. Risk of Death Among BCG Vaccinated and Unvaccinated Children, Stratified by Age Groups
But I would like to create a graph that treats age as a continuous variable and is able to smooth out the relative risk estimates over the continuous variable if possible. I have been unable to find any leads or ways to do this as of yet.
I'd appreciate any help you can offer.
Best
Leo
Comment