************************************ ************************************ ***SOCI 420: ADVANCED METHODS OF SOCIAL RESEARCH ***INTRODUCTION TO INFERENTIAL STATISTICS (chapter 6) ***ESTIMATION PROCEDURES (chapter 7) ************************************ ************************************ ************************************ ***CLEAR MEMORY ************************************ clear all ************************************ ***CREATE SHORTCUTS AND LOG FILE ************************************ ***Shortcut for folders global codes = "H:\course\codes" global data = "H:\course\data" global output = "H:\course\output" ***Start saving results window log using "$codes\Stata06-07.log", replace text ************************************ ***OPENING COMMANDS ************************************ ***Tell Stata to not pause for "more" messages set more off ***Open 2021 GSS use "$data\GSS2021.dta", clear ***Complex survey design svyset [weight=wtssnrps], strata(vstrat) psu(vpsu) singleunit(scaled) ************************************ ***CONFIDENCE INTERVAL FOR MEANS ************************************ ************************************ ***Respondent income in constant dollars (conrinc) ************************************ ***No weight sum conrinc, d mean conrinc estat sd ***Weight ***It corrects the mean sum conrinc [aweight=wtssnrps], d mean conrinc [aweight=wtssnrps] estat sd ***Survey design ***It corrects the mean and standard error svy, subpop(if conrinc!=.): mean conrinc estat sd ************************************ ***Different confidence levels ************************************ ***90% confidence level svy, subpop(if conrinc!=.): mean conrinc, level(90) ***95% confidence level svy, subpop(if conrinc!=.): mean conrinc ***99% confidence level svy, subpop(if conrinc!=.): mean conrinc, level(99) ************************************ ***CONFIDENCE INTERVAL FOR PROPORTIONS ************************************ ************************************ ***Opinion about how should the number ***of immigrants to America be nowadays ************************************ ***No weight tab letin1 prop letin1 ***Weight ***It corrects the proportions tab letin1 [aweight=wtssnrps] prop letin1 [iweight=wtssnrps] // aweights not allowed ***Survey design ***It corrects the proportions and standard errors svy, subpop(if letin1!=.): tab letin1 svy, subpop(if letin1!=.): prop letin1 ************************************ ***Different confidence levels ************************************ ***90% confidence level svy, subpop(if letin1!=.): prop letin1, level(90) ***95% confidence level svy, subpop(if letin1!=.): prop letin1 ***99% confidence level svy, subpop(if letin1!=.): prop letin1, level(99) ************************************ ***CLOSING COMMANDS ************************************ ***Save data save "$data\Stata06-07.dta", replace ***Save log log close