4/30/2024 0 Comments Xline stata color![]() Graph export 2_dbp_bland_altman_ave.png, width(4000) replace Graph save 2_dbp_bland_altman_ave.gph, replace Yline($lowerCL1, lpattern(dash) lcolor(gray)) /// Yline($mean1, lpattern(shortdash) lcolor(gray)) /// Graph twoway scatter diff_dbp_ave mean_dbp_ave, /// Gen diff_dbp_ave=ibp_dbp_pair-average_dbp_omron_23 Gen mean_dbp_ave=(average_dbp_omron_23+ibp_dbp_pair)/2 Graph export 1_sbp_bland_altman_ave.png, width(4000) replace Graph save 1_sbp_bland_altman_ave.gph, replace Graphregion(color(white)) ylabel(, grid glcolor(gs14)) /// white backgroundĪspectratio(1.08) // annoyingly, this wasn't a perfectly square figure so this line fixes it. Yline($upperCL1, lpattern(dash) lcolor(gray)) /// Yline($lowerCL1, lpattern(dash) lcolor(gray)) /// ditto Yline($mean1, lpattern(shortdash) lcolor(gray)) /// calls the macro from above Xtitle("") /// xtitle("Average of Reference and Comparator (mmHg)") Ytitle("") /// ytitle("Reference Minus Comparator (mmHg)") Graph twoway scatter diff_sbp_ave mean_sbp_ave, /// Global lowerCL1=r(mean) - 2*r(sd) // this saves a macro for the mean+2 times the SD ("r(sd)") Global mean1=r(mean) // this saves the macro as mean1, to be called later Sum diff_sbp_ave // this allows you to make a macro of the mean ("r(mean)") of the y axis variable Gen diff_sbp_ave=ibp_sbp_pair-average_sbp_omron_23 // this will be y-axis Gen mean_sbp_ave=(average_sbp_omron_23+ibp_sbp_pair)/2 // this will be the x-axis Graph export combined_scatterplots_fit.png, width(4000) replace Graph save combined_scatterplots_fit.gph, replace // Graph combine 20_sbp_scatterplot_fit.gph 21_dbp_scatterplot_fit.gph, /// Graph export 21_dbp_scatterplot_fit.png, width(4000) replace Graph save 21_dbp_scatterplot_fit.gph, replace Graphregion(color(white)) ylabel(, grid glcolor(gs14)) /// Yline(90, lpattern(solid) lcolor(gray)) /// Xline(90, lpattern(solid) lcolor(gray)) /// (scatter ibp_dbp_pair average_dbp_omron_23, mcolor(black) msize(vsmall)), /// (function y=x, ra(average_dbp_omron_23) clcolor(gs4)) /// ![]() Twoway (lfit ibp_dbp_pair average_dbp_omron_23, lcolor(gray) lpattern(dash) lwidth(vthick)) /// Graph export 20_sbp_scatterplot_fit.png, width(4000) replace Graph save 20_sbp_scatterplot_fit.gph, replace // need graph to merge later Xlabel(90(20)170) ylabel(90(20)170) /// where X and Y labels occurĪspectratio(1) // force figure to be a 1x1 square, not a rectangle Graphregion(color(white)) ylabel(, grid glcolor(gs14)) /// white background, light gray lines Yline(140, lpattern(solid) lcolor(gray)) /// ditto Xline(140, lpattern(solid) lcolor(gray)) /// cutoff for systolic hypertension Ytitle("") /// no title, will add when merging SBP and DBP (scatter ibp_sbp_pair average_sbp_omron_23, mcolor(black) msize(vsmall)), /// make dots appear for scatter, y x axis (function y=x, ra(average_sbp_omron_23) clcolor(gs4)) /// diagonal line of unity Twoway (lfit ibp_sbp_pair average_sbp_omron_23, lcolor(gray) lpattern(dash) lwidth(vthick)) /// line of fit code **********scatterplot ave with lines of fit ![]() The Y-axis is the difference between the variables and the X-axis is a mean of the variables. You just need to set up all of the variables intentionally to trick it into rendering a B-A plot. The dotted line is relative mean difference, the long dashed lines are +/- 2 SD.Īs far as Stata’s graph maker is concerned, this is a scatterplot. Again, two different B-A plots that are merged then labels applied.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |