solutionskillo.blogg.se

Twoway scatter stata
Twoway scatter stata







twoway scatter stata

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)), ///

twoway scatter stata

(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 SCATTER STATA CODE

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.









Twoway scatter stata