fork download
  1. # Examine correlation and regression coefficients
  2.  
  3. pwcorr x y z // x&y: r=.70; x&z: r=.61
  4. reg y x // b=.70
  5. reg z x // b=4.04
  6.  
  7. # Make graph
  8. scatter y x, msize(large) mcolor(stgreen%80) mlcolor(lime) mlwidth(medium) jitter(10) ///
  9. xlab( , glpattern(solid) glcolor(gs14) glwidth(thin)) ///
  10. ylab( , glpattern(solid) glcolor(gs14) glwidth(thin)) ///
  11. || lfit y x, lwidth(medthick) lcolor(red%80) || ///
  12. scatter z x, msize(large) mcolor(stblue%80) mlcolor(cyan) mlwidth(medium) jitter(10) || ///
  13. lfit z x, lcolor(stc10%90) lwidth(medthick) ///
  14. legend(order (1 "Y Variable" 2 "{&beta}=.70" 3 "Z Variable" 4 "{&beta}=4.04")) ///
  15. legend(region(fcolor(gs15) lcolor(gs10))) ///
  16. xsize(6.5) ysize(4.5) graphregion(margin(vsmall)) ///
  17. title(Correlation vs. Regression, box fcolor(black) color(white) span bexpand) ///
  18. scheme(white_jet) /// note: requires installing "schemepack"
  19. text(75 48.5 "{stSans: {it:r}} = .70", placement(c) justification(left) size(medium) box fcolor(edkblue) color(white)) ///
  20. text(50 48.5 "{stSans: {it:r}} = .61", placement(c) justification(left) size(medium) box fcolor(edkblue) color(white)) ///
  21. xtitle(X Variable)
Success #stdin #stdout 0.02s 25664KB
stdin
Standard input is empty
stdout
# Examine correlation and regression coefficients

pwcorr x y z // x&y: r=.70; x&z:  r=.61
reg y x // b=.70
reg z x // b=4.04

# Make graph
scatter y x, msize(large) mcolor(stgreen%80) mlcolor(lime) mlwidth(medium) jitter(10) ///
xlab( , glpattern(solid) glcolor(gs14) glwidth(thin)) ///
ylab( , glpattern(solid) glcolor(gs14) glwidth(thin)) /// 
|| lfit y x, lwidth(medthick) lcolor(red%80) || ///
scatter z x, msize(large) mcolor(stblue%80) mlcolor(cyan) mlwidth(medium) jitter(10) || ///
lfit z x, lcolor(stc10%90) lwidth(medthick) ///
legend(order (1 "Y Variable" 2 "{&beta}=.70" 3 "Z Variable" 4 "{&beta}=4.04")) ///
legend(region(fcolor(gs15) lcolor(gs10))) ///
xsize(6.5) ysize(4.5) graphregion(margin(vsmall)) ///
title(Correlation vs. Regression, box fcolor(black) color(white) span bexpand) ///
scheme(white_jet) /// note: requires installing "schemepack"
text(75 48.5 "{stSans: {it:r}} = .70", placement(c) justification(left) size(medium) box fcolor(edkblue) color(white)) ///
text(50 48.5 "{stSans: {it:r}} = .61", placement(c) justification(left) size(medium) box fcolor(edkblue) color(white)) ///
xtitle(X Variable)