File size: 7,237 Bytes
4328c38 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | use "Data\allcandidates_words.dta", clear
egen race2=rowtotal(racial race )
egen Race=rowtotal(race2 black african)
egen Crime2=rowtotal(crime crimin)
egen Crime=rowtotal(Crime2 drug rape)
egen Crime_strict=rowtotal(Crime2 rape)
gen Drug = drug
egen Terrorism =rowtotal(afghanistan iraq isi isis islam jihad syria syrian terror terrorist )
egen Business=rowtotal(busi businessman businessmen businesspeopl job tax manufactur manufacturing)
egen Corruption =rowtotal(rig cnn swamp media corrupt washington)
egen Trade =rowtotal(trade china nafta )
egen Mexico =rowtotal(mexican mexico )
egen OtherRace =rowtotal(gun prison riot thug urban )
egen Migration =rowtotal(migration migrat immigr migrat )
egen Police =rowtotal( polic policemen police )
egen Clinton = rowtotal (hilari hillari clinton email lock)
egen Implicit = rowtotal (crime crimin drug rape gun prison riot thug urban)
egen Allreferences=rowtotal(Implicit Race )
bysort candidate: su Allreferences Implicit Race Clinton Trade Terrorism Business Corruption
preserve
keep if candidate =="trump"
pwcorr Mexi Implicit
su Implicit if Mexic>0
su Implicit if Mexic==0
gen D_Mexico=(Mexic>0)
gen D_Implicit=(Implicit>0)
restore
foreach var of varlist Allreferences Implicit race2 Race Crime2 Crime Crime_strict Drug Terrorism Business Corruption Trade Mexico OtherRace Migration Police {
gen p`var'=(`var'/tot_words)*100
}
ren democrat democrat_trumpsp
gen democrat=.
replace democrat=0 if candidate == "mccain"|candidate == "romney"|candidate == "cruz" |candidate == "trump"
replace democrat=1 if candidate == "clinton"
gen pres_candidate_plot = .
replace pres_candidate_plot = 5 if candidate == "trump"
replace pres_candidate_plot = 4 if candidate == "cruz"
replace pres_candidate_plot = 3 if candidate == "clinton"
replace pres_candidate_plot = 2 if candidate == "romney"
replace pres_candidate_plot = 1 if candidate == "mccain"
label define pres_candidates 5 "Donald Trump (2016)" 4 "Ted Cruz (2016)" 3 "Hillary Clinton (2016)" 2 "Mitt Romney (2012)" 1 "John McCain (2008)"
cap drop coef* se*
cap drop u_coef* l_coef*
foreach x of varlist Allreferences Implicit race2 Race Crime2 Crime Crime_strict Drug Terrorism Business Corruption Trade Mexico OtherRace Migration Police {
bysort candidate: egen m`x'=mean(`x')
bysort candidate: egen sd`x'=sd(`x')
gen coef`x'=.
gen se`x'=.
bysort candidate: replace coef`x'=m`x'
}
foreach x of varlist Allreferences Implicit race2 Race Crime2 Crime Crime_strict Drug Terrorism Business Corruption Trade Mexico OtherRace Migration Police {
replace se`x'=(1.960*sd`x')/13.78 if candidate=="trump"
replace se`x'=(1.960*sd`x')/2.45 if candidate=="cruz"
replace se`x'=(1.960*sd`x')/13.93 if candidate=="clinton"
replace se`x'=(1.960*sd`x')/10.05 if candidate=="romney"
replace se`x'=(1.960*sd`x')/13.229 if candidate=="mccain"
}
collapse (mean) coef* democrat se*, by(pres_candidate_plot candidate)
foreach x in Allreferences Implicit race2 Race Crime2 Crime Crime_strict Drug Terrorism Business Corruption Trade Mexico OtherRace Migration Police {
*foreach x of varlist addict-weapon race2 race3 Race Crime Mexico Migration Crime2{
bysort candidate: gen u_coef`x' = coef`x' + se`x'
bysort candidate: gen l_coef`x' = coef`x' - se`x'
}
label values pres_candidate_plot pres_candidates
* Do plot
foreach x in Allreferences Implicit Race Crime {
*foreach x of varlist addict-weapon race2 race3 Race Crime Mexico Migration Crime2{
twoway (bar coef`x' pres_candidate_plot if democrat == 0, bcolor(black) ///
barwidth(0.9) horizontal) (bar coef`x' pres_candidate_plot if democrat == 1, ///
lcolor(black) fcolor(white) lwidth(medthick) barwidth(0.9) horizontal) (rcap l_coef`x' u_coef`x' ///
pres_candidate_plot, horizontal lcolor(black)) , xlabel(0(3)12) ylabel(1(1)5, ///
angle(horizontal) valuelabel labsize(*.8)) ytitle("") legend(off) ///
title("Mentions of words: `x'", size(medium) color(black)) ///
graphregion(fcolor(white) lcolor(white))
graph save Results/`x'_words.gph, replace
graph export Results/`x'_words.eps, replace
}
twoway (bar coefAllreferences pres_candidate_plot if democrat == 0, bcolor(black) ///
barwidth(0.9) horizontal) (bar coefAllreferences pres_candidate_plot if democrat == 1, ///
lcolor(black) fcolor(white) lwidth(medthick) barwidth(0.9) horizontal) (rcap l_coefAllreferences u_coefAllreferences ///
pres_candidate_plot, horizontal lcolor(black)) , xlabel(0(3)12) ylabel(1(1)5, ///
angle(horizontal) valuelabel labsize(*.8)) ytitle("") legend(off) ///
title("Explicit and Implicit Racial Mentions", size(medium) color(black)) ///
graphregion(fcolor(white) lcolor(white))
graph save Results/Allreferences_words.gph, replace
graph export Results/Allreferences_words.eps, replace
twoway (bar coefImplicit pres_candidate_plot if democrat == 0, bcolor(black) ///
barwidth(0.9) horizontal) (bar coefImplicit pres_candidate_plot if democrat == 1, ///
lcolor(black) fcolor(white) lwidth(medthick) barwidth(0.9) horizontal) (rcap l_coefImplicit u_coefImplicit ///
pres_candidate_plot, horizontal lcolor(black)) , xlabel(0(3)12) ylabel(1(1)5, ///
angle(horizontal) valuelabel labsize(*.8)) ytitle("") legend(off) ///
title("Implicit Racial Mentions", size(medium) color(black)) ///
graphregion(fcolor(white) lcolor(white))
graph save Results/Implicit_words.gph, replace
graph export Results/Implicit_words.eps, replace
twoway (bar coefRace pres_candidate_plot if democrat == 0, bcolor(black) ///
barwidth(0.9) horizontal) (bar coefRace pres_candidate_plot if democrat == 1, ///
lcolor(black) fcolor(white) lwidth(medthick) barwidth(0.9) horizontal) (rcap l_coefRace u_coefRace ///
pres_candidate_plot, horizontal lcolor(black)) , xlabel(0(3)12) ylabel(1(1)5, ///
angle(horizontal) valuelabel labsize(*.8)) ytitle("") legend(off) ///
title("Explicit Racial Mentions", size(medium) color(black)) ///
graphregion(fcolor(white) lcolor(white))
graph save Results/Race_words.gph, replace
graph export Results/Race_words.eps, replace
twoway (bar coefCrime_strict pres_candidate_plot if democrat == 0, bcolor(black) ///
barwidth(0.9) horizontal) (bar coefCrime_strict pres_candidate_plot if democrat == 1, ///
lcolor(black) fcolor(white) lwidth(medthick) barwidth(0.9) horizontal) (rcap l_coefCrime_strict u_coefCrime_strict ///
pres_candidate_plot, horizontal lcolor(black)) , xlabel(0(3)12) ylabel(1(1)5, ///
angle(horizontal) valuelabel labsize(*.8)) ytitle("") legend(off) ///
title("Crime", size(medium) color(black)) ///
graphregion(fcolor(white) lcolor(white))
graph save Results/Crime_strict_words.gph, replace
graph export Results/Crime_strict_words.eps, replace
graph combine Results/Allreferences_words.gph Results/Race_words.gph Results/Implicit_words.gph Results/Crime_strict_words.gph , scheme(s1mono)
graph export Results/FigureA1.pdf, replace
graph export Results/FigureA1.png, replace
|