************************************ ************************************ ***SOCI 420: ADVANCED METHODS OF SOCIAL RESEARCH ***ELABORATING BIVARIATE TABLES (chapter 14) ************************************ ************************************ ************************************ ***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\Stata14.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) ************************************ ***GENERATING VARIABLES ************************************ ***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, m ************************************ ***GAMMA - Opinion about immigration by sex ************************************ tab letin1 sex, col nofreq gamma *Test statistic: Z = gamma / ASE *ASE: Asymptotic Standard Error di 0.0156/0.030 *p-value *If Z is positive, p-value (one-tailed test): di 1-normal(Z) *If Z is negative, p-value (one-tailed test): di normal(Z) *There is NOT a statistically significant association di 1-normal(0.52) ************************************ ***GAMMA - Opinion about immigration by sex - Only for Republicans ************************************ tab letin1 sex if democrat==0, col nofreq gamma *Test statistic: Z = gamma / ASE *ASE: Asymptotic Standard Error di 0.0800/0.054 *p-value *If Z is positive, p-value (one-tailed test): di 1-normal(Z) *If Z is negative, p-value (one-tailed test): di normal(Z) *There is NOT a statistically significant association di 1-normal(1.4814815) ************************************ ***GAMMA - Opinion about immigration by sex - Only for Democrats ************************************ tab letin1 sex if democrat==1, col nofreq gamma *Test statistic: Z = gamma / ASE *ASE: Asymptotic Standard Error di 0.0784/0.046 *p-value *If Z is positive, p-value (one-tailed test): di 1-normal(Z) *If Z is negative, p-value (one-tailed test): di normal(Z) *There is a statistically significant association di 1-normal(1.7043478) ************************************ ***CLOSING COMMANDS ************************************ ***Save data save "$data\Stata14.dta", replace ***Save log log close