I would like to plot odds ratios of mixed-effects logistic models of the association of four sexual risk-taking behaviours (Sex after substance use "SexDrunkDrugs", infrequent condom use "SexLastUnsafeConsist", multiple sexual partnership "SexPartnerFreq2More", and inequitable sexual partnership "InequitSex") with mobile phone use for health content "XC" and mobile phone use for social media "XM" by gender (boys and girls). I also want to show the p-values labels on the graphs.
I used and adapted Ben Jann coefplot at http://repec.sowi.unibe.ch/stata/coe...g-started.html for estimates from multiply imputed data. Here is the code:
My data looks like
I got a figure like the one I attached to this post Graph.gph .
Please, is there any reason why the p-value for health content use for infrequent condom use is missing.
I tried the same coding for non-imputed dataset and everything works.
I would appreciate any help from you.
Best,
Boladé
I used and adapted Ben Jann coefplot at http://repec.sowi.unibe.ch/stata/coe...g-started.html for estimates from multiply imputed data. Here is the code:
Code:
local y SexDrunkDrugs SexLastUnsafeConsist SexPartnerFreq2More InequitSex local x1 XC XM local xsex Rural AgeC HomeTypeInformal NecessitiesAll_r ARTever Relationship SchEnrol j foreach ys of local y { forvalues f = 0/1 { mi estimate, saving(`ys'`f', replace) cmdok : melogit `ys' `x1' `xsex' if Sex == `f' || ID:, or cov(un) estimate store `ys'`f' } } coefplot (SexDrunkDrugs0, label("Boy") msymbol(S) mcolor(black) mfcolor(white)) (SexDrunkDrugs1, label("Girl") msymbol(O) mcolor(black) mfcolor(black)) , bylabel("Sex after substance use") mlabel("{it:p} = " + string(@pval,"%9.3f")) mlabpos(1) /// || (SexLastUnsafeConsist0) (SexLastUnsafeConsist1) , bylabel("Infrequent condom use") /// || (SexPartnerFreq2More0) (SexPartnerFreq2More1) , bylabel("Multiple sexual partnership") /// || (InequitSex0) (InequitSex1) , bylabel("Inequitable sexual partnership") /// || , eform keep(XC XM) ciopts(lcolor(gs8) lwidth(thick)) xtitle("Adjusted odds ratios (ORs)") xlab(0(1)4,format(%3.0fc)) xline(1, lcolor(gs10)) ylab(1 `" "Health" "content" "use" "(Ref. no access)" "' 2 `" "Social" "media" "use" "(Ref. no access)" "') byopts(xrescale) subtitle(, fcolor(none) lstyle(none)) legend(order(2 "ORs for boys" 4 "ORs for girls" 3 "95% CI") row(1) ring(0) pos(10) region(lstyle(none)))
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input byte(SexDrunkDrugs SexLastUnsafeConsist SexPartnerFreq2More InequitSex) float(XC XM) byte(Sex Rural) double AgeC byte(HomeTypeInformal NecessitiesAll_r ARTever Relationship SchEnrol j) long ID int _mi_id byte _mi_miss int _mi_m
0 0 0 0 0 0 0 1 -.8304964539007091 1 1 1 0 1 0 10 1 0 0
0 1 0 . 1 1 0 1 -.8304964539007091 1 1 1 0 1 1 10 2 1 0
0 1 1 1 0 0 1 0 -.8304964539007091 0 1 1 0 1 0 20 3 0 0
0 1 0 0 0 0 1 0 -.8304964539007091 0 1 1 0 1 1 20 4 0 0
0 0 0 0 0 0 0 1 -3.830496453900709 0 1 1 0 1 0 50 5 0 0
0 0 0 0 0 0 0 1 -3.830496453900709 0 1 1 0 1 1 50 6 0 0
. 0 0 0 1 1 1 0 .16950354609929086 0 0 1 0 1 0 60 7 1 0
0 1 0 0 0 1 1 0 .16950354609929086 0 0 1 0 1 1 60 8 0 0
0 0 0 0 0 0 0 1 -.8304964539007091 0 1 0 0 1 0 70 9 0 0
0 0 0 0 1 1 0 1 -.8304964539007091 0 1 0 0 1 1 70 10 0 0
0 0 0 0 0 0 1 0 -.8304964539007091 1 0 1 0 1 0 90 11 0 0
0 0 0 0 0 0 1 0 -.8304964539007091 1 0 1 0 1 1 90 12 0 0
0 0 0 0 0 0 0 1 -1.8304964539007091 0 0 1 0 1 0 100 13 0 0
0 0 0 0 0 0 0 1 -1.8304964539007091 0 0 1 0 1 1 100 14 0 0
0 0 0 0 0 1 0 0 -2.830496453900709 0 0 1 0 1 0 140 15 0 0
0 0 0 0 0 0 0 0 -2.830496453900709 0 0 1 0 1 1 140 16 0 0
0 0 0 0 0 0 1 0 -2.830496453900709 0 0 0 0 1 0 150 17 0 0
0 0 0 0 0 1 1 0 -2.830496453900709 0 0 0 0 1 1 150 18 0 0
. 0 0 0 1 1 0 0 -.8304964539007091 0 0 1 1 1 0 170 19 1 0
1 1 1 . 0 1 0 0 -.8304964539007091 0 0 1 1 1 1 170 20 1 0
0 0 0 0 0 1 1 1 -.8304964539007091 0 0 1 0 1 0 200 21 0 0
0 0 0 0 0 1 1 1 -.8304964539007091 0 0 1 0 1 1 200 22 0 0
. 0 0 0 0 0 0 0 -.8304964539007091 0 0 0 0 1 0 210 23 1 0
0 0 0 0 0 0 0 0 -.8304964539007091 0 0 0 0 1 1 210 24 0 0
0 0 0 0 0 1 1 1 -1.8304964539007091 0 0 1 0 1 0 230 25 0 0
0 0 0 0 0 1 1 1 -1.8304964539007091 0 0 1 0 1 1 230 26 0 0
0 0 0 0 0 0 0 1 -3.830496453900709 0 1 1 0 1 0 240 27 0 0
0 0 0 0 0 0 0 1 -3.830496453900709 0 1 1 0 1 1 240 28 0 0
0 0 0 0 0 1 1 1 .16950354609929086 0 1 0 0 1 0 280 29 0 0
0 0 0 0 0 0 1 1 .16950354609929086 0 1 0 0 1 1 280 30 0 0
0 0 0 0 0 0 0 0 -1.8304964539007091 0 1 1 0 1 0 290 31 0 0
0 0 0 0 0 0 0 0 -1.8304964539007091 0 1 1 0 1 1 290 32 0 0
0 0 1 0 0 0 0 0 6.169503546099291 0 0 1 1 1 0 300 33 0 0
0 0 1 0 0 0 0 0 6.169503546099291 0 0 1 1 1 1 300 34 0 0
0 0 0 0 0 0 1 0 3.169503546099291 0 0 1 1 1 0 310 35 0 0
0 0 0 0 0 0 1 0 3.169503546099291 0 0 1 1 1 1 310 36 0 0
0 0 0 0 0 0 0 0 -.8304964539007091 0 1 0 0 1 0 340 37 0 0
1 1 0 . 0 0 0 0 -.8304964539007091 0 1 0 0 1 1 340 38 1 0
. 0 0 0 0 1 1 0 3.169503546099291 0 0 1 0 1 0 360 39 1 0
0 0 0 0 0 1 1 0 3.169503546099291 0 0 1 0 1 1 360 40 0 0
0 0 0 0 0 1 1 0 .16950354609929086 0 0 1 0 1 0 390 41 0 0
0 0 0 0 0 0 1 0 .16950354609929086 0 0 1 0 1 1 390 42 0 0
0 0 0 0 0 0 1 0 -1.8304964539007091 0 0 1 0 1 0 410 43 0 0
0 0 0 0 0 1 1 0 -1.8304964539007091 0 0 1 0 1 1 410 44 0 0
0 0 0 0 0 0 1 1 -3.830496453900709 0 0 0 0 1 0 440 45 0 0
0 0 0 0 0 1 1 1 -3.830496453900709 0 0 0 0 1 1 440 46 0 0
1 0 1 1 0 1 0 0 .16950354609929086 0 1 1 0 1 0 450 47 0 0
. 1 0 . 0 1 0 0 .16950354609929086 0 1 1 0 1 1 450 48 1 0
0 0 0 0 0 1 1 1 -.8304964539007091 0 0 1 0 1 0 470 49 0 0
0 0 0 0 0 0 1 1 -.8304964539007091 0 0 1 0 1 1 470 50 0 0
0 0 0 0 0 0 0 1 -3.830496453900709 1 1 1 0 1 0 480 51 0 0
0 0 0 0 0 1 0 1 -3.830496453900709 1 1 1 0 1 1 480 52 0 0
0 0 0 0 0 1 1 0 3.169503546099291 0 0 0 0 1 0 490 53 0 0
0 1 0 0 0 1 1 0 3.169503546099291 0 0 0 0 1 1 490 54 0 0
0 0 0 0 0 1 1 0 -.8304964539007091 0 0 0 1 1 0 510 55 0 0
0 0 0 0 0 1 1 0 -.8304964539007091 0 0 0 1 1 1 510 56 0 0
0 0 1 0 0 1 1 0 1.1695035460992909 0 0 0 1 1 0 530 57 0 0
0 0 1 1 0 1 1 0 1.1695035460992909 0 0 0 1 1 1 530 58 0 0
0 0 1 0 0 0 1 0 1.1695035460992909 0 0 1 0 1 0 540 59 0 0
0 1 0 1 0 1 1 0 1.1695035460992909 0 0 1 0 1 1 540 60 0 0
0 0 1 0 0 0 1 1 3.169503546099291 0 1 1 1 1 0 580 61 0 0
0 1 1 1 0 1 1 1 3.169503546099291 0 1 1 1 1 1 580 62 0 0
0 0 1 0 0 1 1 1 2.169503546099291 0 0 1 1 1 0 600 63 0 0
0 0 0 0 0 1 1 1 2.169503546099291 0 0 1 1 1 1 600 64 0 0
0 0 0 0 0 0 1 0 -.8304964539007091 0 0 1 0 1 0 620 65 0 0
0 0 0 0 0 1 1 0 -.8304964539007091 0 0 1 0 1 1 620 66 0 0
0 1 1 0 0 0 1 0 .16950354609929086 0 0 0 1 1 0 650 67 0 0
0 1 0 0 0 1 1 0 .16950354609929086 0 0 0 1 1 1 650 68 0 0
1 1 1 0 0 0 1 0 -.8304964539007091 0 0 0 0 1 0 680 69 0 0
0 0 0 1 0 0 1 0 -.8304964539007091 0 0 0 0 1 1 680 70 0 0
0 0 0 0 0 0 0 0 -3.830496453900709 0 1 1 0 1 0 690 71 0 0
. 0 0 . 0 0 0 0 -3.830496453900709 0 1 1 0 1 1 690 72 1 0
0 0 0 0 0 0 1 0 -2.830496453900709 0 1 0 0 1 0 700 73 0 0
0 0 0 0 0 0 1 0 -2.830496453900709 0 1 0 0 1 1 700 74 0 0
0 0 0 0 0 0 1 0 -3.830496453900709 0 0 0 0 1 0 710 75 0 0
0 0 0 0 0 0 1 0 -3.830496453900709 0 0 0 0 1 1 710 76 0 0
0 0 0 0 0 0 1 0 -.8304964539007091 0 1 1 0 1 0 750 77 0 0
0 0 0 0 0 1 1 0 -.8304964539007091 0 1 1 0 1 1 750 78 0 0
0 0 0 0 1 1 1 1 2.169503546099291 0 0 1 1 1 0 780 79 0 0
0 1 0 0 0 1 1 1 2.169503546099291 0 0 1 1 1 1 780 80 0 0
. 0 0 0 0 1 0 0 1.1695035460992909 0 0 0 1 1 0 790 81 1 0
0 1 0 0 0 1 0 0 1.1695035460992909 0 0 0 1 1 1 790 82 0 0
0 0 0 0 0 1 1 0 -.8304964539007091 0 0 1 0 1 0 800 83 0 0
0 0 0 0 0 1 1 0 -.8304964539007091 0 0 1 0 1 1 800 84 0 0
. 0 0 0 0 0 1 0 1.1695035460992909 0 0 0 1 1 0 810 85 1 0
0 0 0 0 0 1 1 0 1.1695035460992909 0 0 0 1 1 1 810 86 0 0
. 0 0 0 0 1 1 1 .16950354609929086 0 1 0 0 1 0 830 87 1 0
0 1 0 0 1 1 1 1 .16950354609929086 0 1 0 0 1 1 830 88 0 0
0 0 0 0 0 0 1 0 -1.8304964539007091 0 1 0 0 1 0 850 89 0 0
0 1 0 . 1 1 1 0 -1.8304964539007091 0 1 0 0 1 1 850 90 1 0
0 0 0 0 0 0 1 1 -2.830496453900709 0 1 0 0 1 0 870 91 0 0
0 0 0 0 0 0 1 1 -2.830496453900709 0 1 0 0 1 1 870 92 0 0
0 0 0 0 1 1 1 0 1.1695035460992909 0 0 0 0 1 0 930 93 0 0
0 0 0 0 0 0 1 0 1.1695035460992909 0 0 0 0 1 1 930 94 0 0
0 0 0 0 0 0 1 0 -3.830496453900709 0 0 1 0 1 0 940 95 0 0
0 0 0 0 0 0 1 0 -3.830496453900709 0 0 1 0 1 1 940 96 0 0
. 0 0 0 0 0 1 0 .16950354609929086 1 0 0 1 1 0 950 97 1 0
0 1 0 0 0 0 1 0 .16950354609929086 1 0 0 1 1 1 950 98 0 0
0 0 0 0 0 0 1 1 -3.830496453900709 0 0 1 0 1 0 970 99 0 0
0 0 0 0 0 0 1 1 -3.830496453900709 0 0 1 0 1 1 970 100 0 0
end
label values SexLastUnsafeConsist yes_no
label values SexPartnerFreq2More yes_no
label def yes_no 0 "0. No", modify
label def yes_no 1 "1. Yes", modify
label values Sex Sex
label def Sex 0 "Male", modify
label def Sex 1 "Female", modify
label values Rural UrbRur
label def UrbRur 0 "0. Urban", modify
label def UrbRur 1 "1. Rural", modify
label values ARTever binary
label values HomeTypeInformal binary
label values Relationship binary
label values SchEnrol binary
label def binary 0 "0. No", modify
label def binary 1 "1. Yes", modify
label values NecessitiesAll_r binary_r
label def binary_r 0 "0. Yes", modify
label def binary_r 1 "1. No", modify
Please, is there any reason why the p-value for health content use for infrequent condom use is missing.
I tried the same coding for non-imputed dataset and everything works.
I would appreciate any help from you.
Best,
Boladé
Comment