import delimited [pathname]\anes_pilot_2016.csv /* clean up: these together eliminate 20 cases, not all necessary for this but I just did it */ drop if ftmuslim==998 | fttrump ==998 | fthrc==998 | fthrc==998 | ftsci==998 | ftpolice==998 | ftsanders==998 | ftgay==998 | ftfem==998 | ftblack==998 gen rndwgt = round(100*weight) /* this is cuz logit doesn't allow non-integer weights */ gen onewgt = rndwgt/99.2 /* this is normalized at 1 so that significance isn't inflated with weighting, but it makes it non-integer again. gr. */ gen pid = pid1d + pid1r /* party id asked two ways */ label define pid_lbl 10 "Democrat" label define pid_lbl 11 "Republican", add label define pid_lbl 12 "Independent", add label define pid_lbl 13 "Something else", add label values pid pid_lbl gen preftrump = 0 replace preftrump = 1 if repcand == 9 label define pt_lbl 0 "Anyone else" label define pt_lbl 1 "Trump", add label values preftrump pt_lbl lab var preftrump "Trump favorite Rep" gen pidn = 0 replace pidn = 1 if pid==10 replace pidn = 2 if pid==11 replace pidn = 3 if pid==12 | pid == 13 label define pidn_lbl 1 "Democrat" label define pidn_lbl 2 "Republican", add label define pidn_lbl 3 "Other", add label values pidn pidn_lbl /* college grads */ gen baplus=0 replace baplus=1 if educ>=5 /* non-dem Trump supporters */ gen ndtrump = 0 replace ndtrump = 1 if (pid==11 | pid==12 | pid==13) & preftrump==1 gen repub = 0 replace repub = 1 if pidn==2 gen democ = 0 replace democ = 1 if pidn==1 * SALON analysis /* feelings */ /* muslims */ /* odds of supporting trump */ logit ndtrump birthyr i.gender i.baplus ftmuslim [weight=rndwgt] margins, at(ftmuslim=(0(20)100)) atmeans /* compare with odds of being republican */ logit repub birthyr i.gender i.baplus ftmuslim [weight=rndwgt] margins, at(ftmuslim=(0(20)100)) atmeans /* compare with odds of being democrat */ logit democ birthyr i.gender i.baplus ftmuslim [weight=rndwgt] margins, at(ftmuslim=(0(20)100)) atmeans /* To compare, use the same model to predict trump, given trump or repub, and check significance with onewgt */ logit ndtrump birthyr i.gender i.baplus ftmuslim [weight=onewgt] if ndtrump==1|repub==1 /* this shows a strong significant effect of ftmuslim on odds of trump preference, meaning trumpers are more racist than other repubs */ /* stereotypes */ /* muslims */ tab2 lazym ndtrump [weight=rndwgt] , col nofreq chi2 tab2 lazym pidn [weight=rndwgt] , col nofreq chi2 tab2 violentm ndtrump [weight=rndwgt] , col nofreq chi2 tab2 violentm pidn [weight=rndwgt] , col nofreq chi2