/* UAS Political Question Analysis */ //Will only need the following variables in this analysis keep uasid el001 el002 el003a el003b el003c el003d el003e el003_randomizer //Create other variables of interest gen democrat=1 if el001==1 | el001==4 replace democrat=0 if democrat!=1 gen republican=1 if democrat==0 replace republican=0 if republican!=1 gen party=democrat label define party 1 "Democrat" 0 "Republican" label values party party gen sex=gender-1 //Rename variables to candidate names rename el003a clinton rename el003b cruz rename el003c kasich rename el003d sanders rename el003e trump //Drop observation if participant does not choose a "best" president drop if el001==. | el001==.e //Drop observations in which all the candidates are not rated foreach i of varlist clinton-trump { drop if `i'==.e drop if `i'==. } //Give best and worst candidates of 100 and 0, respectively, so that their ratings are comparable replace clinton=0 if el002==1 replace clinton=100 if el001==1 replace cruz=0 if el002==2 replace cruz=100 if el001==2 replace kasich=0 if el002==3 replace kasich=100 if el001==3 replace sanders=0 if el002==4 replace sanders=100 if el001==4 replace trump=0 if el002==5 replace trump=100 if el001==5 //Create new variables RankCandidate to show rank order for each candidate program RankCandidates gen Rank`1'=1 if `1'>=`2' & `1'>=`3' & `1'>=`4' & `1'>=`5' replace Rank`1'=2 if `1'<`2' | `1'<`3' | `1'<`4' | `1'<`5' replace Rank`1'=3 if (`1'<`2' & (`1'<`3' | `1'<`4' | `1'<`5')) | (`1'<`3' & (`1'<`4' | `1'<`5')) | (`1'<`4' & `1'<`5') replace Rank`1'=4 if (`1'<`2' & `1'<`3' & (`1'<`4' | `1'<`5')) | (`1'<`4' & `1'<`5' & (`1'<`2' | `1'<`3')) replace Rank`1'=5 if `1'<`2' & `1'<`3' & `1'<`4' & `1'<`5' end RankCandidates clinton cruz kasich sanders trump RankCandidates cruz clinton kasich sanders trump RankCandidates kasich clinton cruz sanders trump RankCandidates sanders clinton cruz kasich trump RankCandidates trump clinton cruz kasich sanders *-----------------------------------------------------------------------------------------------------------------------------------------------* *Voting mechanisms* *** 1. NGA Mechanism *** egen mu=rowmean(clinton cruz kasich sanders trump) egen sd=rowsd(clinton cruz kasich sanders trump) foreach i of varlist clinton-trump { gen std`i'=(`i'-mu)/sd } //NGA Results Using Unstructured Ratings sum stdclinton-stdtrump if el003_r==1 //NGA Results Using Expected Utility Ratings sum stdclinton-stdtrump if el003_r==2 *** 2. Current Voting system winner *** //Number of “best” candidate ratings using Unstructured Ratings tab el001 if el003_r==1 //Number of “best” candidate ratings using Expected Utility Ratings tab el001 if el003_r==2 gen prefclinton=-999 replace prefclinton=1 if Rankclinton=`2' & `1'>=`3' & `1'>=`4' & `1'>=`5' replace Rank`1'=2 if `1'<`2' | `1'<`3' | `1'<`4' | `1'<`5' replace Rank`1'=3 if (`1'<`2' & (`1'<`3' | `1'<`4' | `1'<`5')) | (`1'<`3' & (`1'<`4' | `1'<`5')) | (`1'<`4' & `1'<`5') replace Rank`1'=4 if (`1'<`2' & `1'<`3' & (`1'<`4' | `1'<`5')) | (`1'<`4' & `1'<`5' & (`1'<`2' | `1'<`3')) replace Rank`1'=5 if `1'<`2' & `1'<`3' & `1'<`4' & `1'<`5' end RankstdCandidates_extreme stdclinton_extreme stdcruz_extreme stdkasich_extreme stdsanders_extreme stdtrump_extreme RankstdCandidates_extreme stdcruz_extreme stdclinton_extreme stdkasich_extreme stdsanders_extreme stdtrump_extreme RankstdCandidates_extreme stdkasich_extreme stdclinton_extreme stdcruz_extreme stdsanders_extreme stdtrump_extreme RankstdCandidates_extreme stdsanders_extreme stdclinton_extreme stdcruz_extreme stdkasich_extreme stdtrump_extreme RankstdCandidates_extreme stdtrump_extreme stdclinton_extreme stdcruz_extreme stdkasich_extreme stdsanders_extreme //Identify most extremely rated candidate gen extreme_stdcandidate="a" foreach i of varlist stdclinton-stdtrump{ replace extreme_stdcandidate="`i'" if Rank`i'_extreme==1 } //Identify most extremely rated score gen extreme_stdscore=999 foreach i of varlist stdclinton-stdtrump { replace extreme_stdscore=`i' if extreme_stdcandidate=="`i'" } //for ties foreach i of varlist stdclinton-stdtrump { foreach j of varlist stdclinton-stdtrump{ replace extreme_stdcandidate = "`i'_`j'" if Rank`i'_extreme==1 & Rank`j'_extreme==1 & "`i'"!="`j'" } } foreach i of varlist stdclinton-stdtrump{ foreach j of varlist stdclinton-stdtrump{ foreach k of varlist stdclinton-stdtrump{ replace extreme_stdcandidate = "`i'_`j'_`k'" if Rank`i'_extreme==1 & Rank`j'_extreme==1 & Rank`k'_extreme==1 & "`i'"!="`j'" & "`i'"!="`k'"& "`k'"!="`j'" } } } //Identify second most extremely rated candidate gen extreme_2_stdcandidate="a" foreach i of varlist stdclinton-stdtrump { replace extreme_2_stdcandidate="`i'" if Rank`i'_extreme==2 } //Identify second most extremely rated score gen extreme_2_stdscore=999 foreach i of varlist stdclinton-stdtrump { replace extreme_2_stdscore=`i' if extreme_2_stdcandidate=="`i'" replace extreme_2_stdscore=extreme_stdscore if extreme_2_stdcandidate=="a" } //for ties in second most extreme foreach i of varlist stdclinton-stdtrump { foreach j of varlist stdclinton-stdtrump{ replace extreme_2_stdcandidate = "`i'_`j'" if Rank`i'_extreme==2 & Rank`j'_extreme==2 & "`i'"!="`j'" } } foreach i of varlist stdclinton-stdtrump{ foreach j of varlist stdclinton-stdtrump{ foreach k of varlist stdclinton-stdtrump{ replace extreme_2_stdcandidate = "`i'_`j'_`k'" if Rank`i'_extreme==1 & Rank`j'_extreme==1 & Rank`k'_extreme==1 & "`i'"!="`j'" & "`i'"!="`k'"& "`k'"!="`j'" } } } //Create an indidicator variable to see whether extreme candidate is negative or positive gen extreme_love=0 foreach i of varlist stdclinton-stdtrump{ replace extreme_love=1 if extreme_stdcandidate=="`i'" & `i'>0 replace extreme_love=-1 if extreme_stdcandidate=="`i'" & `i'<0 } //Create an indidicator variable to see whether second most extreme candidate is negative or positive* gen extreme_2_love=0 foreach i of varlist stdclinton-stdtrump{ replace extreme_2_love=1 if extreme_2_stdcandidate=="`i'" & `i'>0 replace extreme_2_love=-1 if extreme_2_stdcandidate=="`i'" & `i'<0 } //Most Extreme Candidates by Rating Type tab extreme_stdcandidate if el003_r==1 tab extreme_stdcandidate if el003_r==2 //When each candidate is most extreme, are they loved or hated? tab extreme_stdcandidate if extreme_love==-1 & el003_r==1 tab extreme_stdcandidate if extreme_love==1 & el003_r==1 tab extreme_stdcandidate tab extreme_stdcandidate if extreme_love==-1 & el003_r==2 tab extreme_stdcandidate if extreme_love==1 & el003_r==2 //Second Most Extreme Candidates by Rating Type tab extreme_2_stdcandidate if el003_r==1 tab extreme_2_stdcandidate if el003_r==2 //When each candidate is second most extreme, are they loved or hated? tab extreme_2_stdcandidate if extreme_2_love==-1 & el003_r==1 tab extreme_2_stdcandidate if extreme_2_love==1 & el003_r==1 tab extreme_2_stdcandidate if extreme_2_love==-1 & el003_r==2 tab extreme_2_stdcandidate if extreme_2_love==1 & el003_r==2 //To create Figures egen freqstdscore = total(1), by(extreme_stdscore extreme_2_stdscore) //Most Extreme vs. Second Most Extreme Ratings Using Unstructured Ratings scatter extreme_2_stdscore extreme_stdscore if el003_r==1, title("Extreme Ratings - Unstructured") mfcolor(none) xtitle("Most Extreme Standardized Rating") ytitle("2nd Most Extreme Standardized Rating") //Most Extreme vs. Second Most Extreme Ratings Using E(U) Ratings scatter extreme_2_stdscore extreme_stdscore if el003_r==2, title("Extreme Ratings - E(U)") mfcolor(none) xtitle("Most Extreme Standardized Rating") ytitle("2nd Most Extreme Standardized Rating") //To calculate counts for each "group" in figures gen extreme_dummy=1 if extreme_stdscore>0 & extreme_stdscore!=. replace extreme_dummy=-1 if extreme_stdscore<0 & extreme_stdscore!=. gen extreme2_dummy=1 if extreme_2_stdscore>0 & extreme_2_stdscore!=. replace extreme2_dummy=-1 if extreme_2_stdscore<0 & extreme_2_stdscore!=. tab extreme2_dummy extreme_dummy if el003_r==1 tab extreme2_dummy extreme_dummy if el003_r==2 *-----------------------------------------------------------------------------------------------------------------------------------------------* *** Variance between standardized ratings in own party *** egen demdev=rowsd(stdclinton stdsanders) gen demvar=demdev^2 // Among those whose top candidate was a Democrat, what was the average variance between Clinton and Sanders ratings? sum demvar if party==1 & el003_r==1 sum demvar if party==1 & el003_r==2 egen repdev=rowsd(stdcruz stdkasich stdtrump) gen repvar=repdev^2 // Among those whose top candidate was a Republican, what was the average variance between Cruz, Kasich, and Trump ratings? sum repvar if party==0 & el003_r==1 sum repvar if party==0 & el003_r==2 *-----------------------------------------------------------------------------------------------------------------------------------------------* *** Skewness *** //Reshape the data rename clinton el0031 rename cruz el0032 rename kasich el0033 rename sanders el0034 rename trump el0035 reshape long el003, i(uasid) j(candidate) rename el003 rating //Standardized Scores for each person sort uasid egen murat=mean(rating), by(uasid) egen sdev=sd(rating), by(uasid) gen stdrating=(rating-murat)/sdev //Calculate skew by person sort uasid egen ratskew=skew(stdrating), by(uasid) //Only keep first observation for each person by uasid: gen first=_n keep if first==1 //Skewness of Ratings sum ratskew if el003_r==1 sum ratskew if el003_r==2 //Skewness of Unstructured vs. E(U) Ratings twoway (histogram ratskew if el003_r==1, width(0.1) freq color(green)) /// (histogram ratskew if el003_r==2, width(0.1) freq /// fcolor(none) lcolor(black)), title("Skewness by Rating Type") legend(order(1 "Unstructured" 2 "E(U)" )) xtitle("Skewness")