I am trying to visualise continuous-by-continuous interactions (albuminuria and eGFR) with margins and twoway contour after Cox-model (contours of rate ratios for the joint effect of eGFR and uacr on ESKD).
PHP Code:
Codes:
stcox c.gfr#c.log_uacr gfr log_uacr, nolog
quietly margins, at(gfr=(180(30)30))
marginsplot
quietly margins, at(uacr=(1(2)10))
marginsplot
quietly margins, at(gfr=(180(30)30) log_uacr=(1(2)10)) saving(predictions, replace)
****
use predictions, clear
rename _at1 gfr
rename _at2 uacr
rename _margin pr_eskd
twoway (contour pr_eskd gfr uacr, ccuts(0(1)6.0)),
xlabel(180(30)30)
ylabel(1(2)10, angle(horizontal))
xtitle("UACR (log-transformed)")
ytitle("eGFR")
ztitle("Predicted probability of d")
title("Predicted probability of d by eGFR and UACR")
PHP Code:
clear
input byte(_deriv _term _predict _at _atopt) float(pr_eskd _se _statistic _pvalue _ci_lb _ci_ub) int gfr byte uacr
. 1 . 1 1 .06169354 .04276859 1.4424965 .14916235 -.022131355 .14551844 180 1
. 1 . 2 1 .18353756 .0986591 1.8603206 .06284018 -.009830727 .3769058 180 3
. 1 . 3 1 .54602206 .2263545 2.412243 .015854707 .1023754 .9896687 180 5
. 1 . 4 1 1.624409 .5840914 2.781087 .005417719 .479611 2.769207 180 7
. 1 . 5 1 4.832598 1.9406745 2.490164 .012768422 1.0289453 8.6362505 180 9
. 1 . 6 1 .10049447 .05927823 1.6953013 .09001829 -.01568874 .21667767 150 1
. 1 . 7 1 .26137534 .12606023 2.0734162 .03813356 .014301818 .50844884 150 3
. 1 . 8 1 .6798093 .26749414 2.5413985 .011041 .15553033 1.2040882 150 5
. 1 . 9 1 1.768111 .5985598 2.953942 .0031374276 .5949554 2.941267 150 7
. 1 . 10 1 4.598667 1.5385205 2.989019 .0027987454 1.5832226 7.614112 150 9
. 1 . 11 1 .16369845 .07965537 2.0550835 .03987093 .007576788 .3198201 120 1
. 1 . 12 1 .3722239 .1595339 2.333196 .01963786 .05954317 .6849046 120 3
. 1 . 13 1 .8463772 .3219558 2.628862 .008567116 .2153555 1.477399 120 5
. 1 . 14 1 1.9245254 .6660874 2.889299 .003861021 .6190181 3.230033 120 7
. 1 . 15 1 4.376061 1.4445285 3.0294044 .002450365 1.544837 7.207284 120 9
. 1 . 16 1 .26665333 .10226919 2.607367 .009124146 .0662094 .46709725 90 1
. 1 . 17 1 .53008306 .1998973 2.651777 .008006934 .1382916 .9218745 90 3
. 1 . 18 1 1.0537579 .3963306 2.658785 .007842294 .27696422 1.8305516 90 5
. 1 . 19 1 2.0947769 .7972497 2.627504 .008601375 .5321963 3.6573575 90 7
. 1 . 20 1 4.16423 1.6255087 2.561801 .01041309 .9782916 7.350168 90 9
. 1 . 21 1 .4343596 .1220007 3.560304 .0003704257 .1952426 .6734766 60 1
. 1 . 22 1 .7548898 .24825417 3.0407944 .002359549 .26832065 1.241459 60 3
. 1 . 23 1 1.3119514 .499772 2.6251 .008662352 .3324163 2.2914865 60 5
. 1 . 24 1 2.2800896 .9932981 2.2954738 .02170599 .3332611 4.2269177 60 7
. 1 . 25 1 3.962653 1.949993 2.0321372 .04213978 .14073704 7.784569 60 9
. 1 . 26 1 .7075414 .12689924 5.575616 2.466553e-08 .4588235 .9562594 30 1
. 1 . 27 1 1.0750366 .306939 3.502444 .0004610108 .4734472 1.676626 30 3
. 1 . 28 1 1.633408 .6444405 2.534614 .011257137 .3703276 2.896488 30 5
. 1 . 29 1 2.481796 1.2522383 1.9818878 .0474918 .02745381 4.936138 30 7
. 1 . 30 1 3.770834 2.3193245 1.6258328 .10398523 -.7749587 8.316627 30 9
end
label values _term _term
label def _term 1 "_cons", modify
label values _atopt _atopt
label def _atopt 1 "gfr=(180(30)30) log_uacr=(1(2)10)", modify
1. How to add reference to contours plot (relative to a reference of individual eGFR =90 and for UACR (log-trasnformed)=3.4)?
2. In other analysis, the data showed that higher albuminuria and lower eGFR are associated with increased risk of CKD. However, I can not see this in this contour (maybe something wrong in my codes?).
3. Is it possible in Stata to create the contours as below (labels in x-axis in increasing order; y-axis in descending order; and putting HRs per line)?
(I am using Stata 15)
Array
Thank you so much.
0 Response to How to add reference to contours plot
Post a Comment