************************************ ************************************ ***ASSOCIATION BETWEEN VARIABLES MEASURED AT THE INTERVAL-RATIO LEVEL (chapter 13) ************************************ ************************************ ************************************ ***Opening commands ************************************ ***Clear memory clear all ***Start saving results window log using "C:\course\progs\Stata13.log", replace text // Windows log using "/course/progs/Stata13.log", replace text // Macintosh ***Open 2016 GSS use "C:\course\data\GSS2016.dta", clear // Windows use "/course/data/GSS2016.dta", clear // Macintosh ************************************ ***Complex survey design ************************************ svyset [weight=wtssall], strata(vstrat) psu(vpsu) singleunit(scaled) ************************************ ***Respondent's income and education ************************************ ***Scatterplot without regression line twoway scatter conrinc educ ***Scatterplot with regression line twoway scatter conrinc educ || lfit conrinc educ, ytitle(Respondent's income) xtitle(Years of schooling) twoway (scatter conrinc educ) (lfit conrinc educ), ytitle(Respondent's income) xtitle(Years of schooling) // same as above ***Regression coefficients ***Least-squares regression model ***They can be reported in the footnote of the scatterplot svy: reg conrinc educ ***Pearson's r correlation corr conrinc educ [aweight=wtssall] pwcorr conrinc educ [aweight=wtssall] // same as above pwcorr conrinc educ [aweight=wtssall], sig // Pearson's r with test of significance ***Coefficient of determination (r-squared) di .3387^2 ************************************ ***Correlation matrix ************************************ ***Respondent's income income, age, education pwcorr conrinc age educ [aweight=wtssall], sig ***Coefficient of determination (r-squared) ***Respondent's income and age di .1852^2 ***Coefficient of determination (r-squared) ***Respondent's income and education di .3387^2 ************************************ ***CLOSING COMMANDS ************************************ ***Save data save "Stata13.dta", replace ***Save log log close