************************************ ************************************ ***HYPOTHESIS TESTING III: THE ANALYSIS OF VARIANCE (chapter 10) ************************************ ************************************ ************************************ ***OPENING COMMANDS ************************************ ***Clear memory clear all ***Start saving results window log using "C:\course\progs\Stata10.log", replace text // Windows log using "/course/progs/Stata10.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) ************************************ ***GENERATING VARIABLES ************************************ ***Generate dummy variable for hispanic tab hispanic, m tab hispanic, m nolabel gen hisp=. replace hisp=0 if hispanic==1 replace hisp=1 if hispanic>=2 & hispanic<=50 tab hispanic hisp, m ***Generate race/ethnicity variable tab race, m tab race, m nolabel gen raceeth=. replace raceeth=1 if race==1 & hisp==0 //non-hispanic white replace raceeth=2 if race==2 & hisp==0 //non-hispanic black replace raceeth=3 if hisp==1 //hispanic replace raceeth=4 if race==3 & hisp==0 //other label variable raceeth "Race/Ethnicity" label define race 1 "White" 2 "Black" 3 "Hispanic" 4 "Other" label values raceeth race tab raceeth race, m tab raceeth hisp, m ***Generate dummy variable for Democrats vs. Republicans ***"Independents" will be missing tab partyid, m tab partyid, m nolabel gen democrat=. replace democrat=1 if partyid>=0 & partyid<=2 replace democrat=0 if partyid>=4 & partyid<=6 label variable democrat "Political party" label define party 1 "Democrats" 0 "Republicans" label values democrat party tab partyid democrat, m tab democrat ************************************ ***ANOVA ************************************ ***Descriptive table table raceeth [aweight=wtssall], c(mean conrinc sd conrinc n conrinc) ***One-way Anova oneway conrinc raceeth [aweight=wtssall] anova conrinc raceeth [aweight=wtssall] ************************************ ***CLOSING COMMANDS ************************************ ***Save data save "Stata10.dta", replace ***Save log log close