infile id site age male bkrace smoker estrogen prevdis /// diab2 bmi aai cholest crp fib ttodth death cvddth /// using http://www.emersonstatistics.com/datasets/inflamm.txt twoway (scatter fib crp if prevdis==1, jitter(2) col(blue)) /// (lowess fib crp if prevdis==1, col(blue)) /// (scatter fib crp if prevdis==0, jitter(1) col(pink) msymb(D)) /// (lowess fib crp if prevdis==0, col(pink)) /// (lowess fib crp, col(black) xtitle("C Reactive Protein (CRP) (mg/L)") /// ytitle("Fibrinogen (mg/dL)") t1("Fibrinogen by CRP and Prior CVD")), /// legend(label(5 "All subjects (lowess)") label(1 "Prior CVD") /// label(2 "Prior CVD (lowess)") label(3 "No Prior CVD") /// label(4 "No Prior CVD (lowess)")) g icrp = crp replace icrp=0.5 if crp==0 g logcrp= log(icrp) / log(2) g logfib= log(fib) twoway (scatter fib icrp if prevdis==1, jitter(2) col(blue) yscale(log) xscale(log)) /// (lowess fib icrp if prevdis==1, col(blue)) /// (scatter fib icrp if prevdis==0, jitter(1) col(pink) msymb(D)) /// (lowess fib icrp if prevdis==0, col(pink)) /// (lowess fib icrp, col(black) xtitle("C Reactive Protein (CRP) (mg/L)") /// ytitle("Fibrinogen (mg/dL)") t1("Fibrinogen by CRP and Prior CVD")), /// legend(label(5 "All subjects (lowess)") label(1 "Prior CVD") /// label(2 "Prior CVD (lowess)") label(3 "No Prior CVD") /// label(4 "No Prior CVD (lowess)")) recode crp 3/4=4 5/8=8 9/16=16 17/32=32 33/max=64, gen(ctgcrp) tabulate ctgcrp prevdis, missing tabstat crp, stat(n mean sd min q max) col(stat) by(prevdis) bysort prevdis: tabstat fib, stat(n mean sd min q max) col(stat) by(ctgcrp) missing tabstat fib, stat(n mean sd min q max) col(stat) by(ctgcrp) missing tabstat fib if crp==., stat(n mean sd min q max) col(stat) corr fib crp spearman fib crp corr logfib logcrp ttest fib, by(prevdis) regress fib prevdis ttest fib, by(prevdis) unequal regress fib prevdis, robust regress fib crp, robust regress fib logcrp, robust regress logfib crp, robust regress logfib crp, robust eform(GM) regress logfib logcrp, robust regress logfib logcrp, robust eform(GM)