set more off
window manage close graph _all
set scheme s1mono
use final_analysis_dataset.dta if catalist_match==1, clear

qui gen validated_regd_demrep = 1*(PartyRegist == "Democratic.Party" | PartyRegist == "Republican.Party")
label var validated_regd_demrep "Validated party registration Dem or Rep"

*Only make comparisons in states with any party reg.
tabstat validated_regd_demrep, s(mean) by(StateAbbr)
qui egen party_reg_rate_in_state = mean(validated_regd_demrep), by(StateAbbr)
qui gen party_reg_state = 1*(party_reg_rate_in_state > .1)

*******
*
* This block prepares the data for the R Plots of Demographics differences
*
*******

*Shorten policy item labels to fit on graphs
foreach var of varlist CC320 CC321 CC324 CC325 CC326 CC327 CC328 CC329 {
 levelsof `var' , local(levels)
 foreach l of local levels {
  local templabel : label (`var') `l'
  local templabel=substr("`templabel'",1,15)
  label define `var' `l' "`templabel'", modify
 }
 label values `var' `var'
} 

label var faminc "Family Income: "
label var unionhh "Union: "
label var race "Race: "
label var educ "Education: "
label var decades "Age in decades: "
label var pew_religimp "Religion Importance: "
gen male=gender==1
label var male "Male"

* Create indicator variables from categories
foreach var of varlist faminc unionhh race educ decades pew_religimp {
 local tempvarlabel : var label `var'
 levelsof `var', local(levels)
 local ctr=1
  foreach lvl of local levels {
   if `ctr'~=1 {
    gen I_`var'_`ctr'=(`var'==`lvl') if `var'~=.
	local tempvallabel : label (`var') `lvl'
	label var I_`var'_`ctr' "`tempvarlabel'`tempvallabel'"
   }
  local ctr=`ctr'+1
 }
}

* Demographic Comparison of Contributors and Non-Contributors

gen iscontributord=iscontributor if isdem==1
gen iscontributorr=iscontributor if isdem==0
gen amountcontd=binned_2012amountR_withmissing if isdem==1
gen amountcontr=binned_2012amountR_withmissing if isdem==0
*Four-way classification, contributor by dem/rep.
gen iscont_pid = .
qui replace iscont_pid = 1 if iscontributord == 1
qui replace iscont_pid = 2 if iscontributord == 0
qui replace iscont_pid = 3 if iscontributorr == 1
qui replace iscont_pid = 4 if iscontributorr == 0
label var iscont_pid "Party ID by contributor"
label define iscont_pid 1 "Dem Donor" 2 "Dem Non-donor" 3 "Rep Donor" 4 "Rep Non-donor"
label values iscont_pid iscont_pid
tab iscont_pid [aweight = V103], miss
qui gen votetype_pid = .
qui replace votetype_pid = 1 if voted2012 == 1 & isdem == 1
qui replace votetype_pid = 2 if voted2012 == 0 & isdem == 1
qui replace votetype_pid = 3 if voted2012 == 1 & isdem == 0
qui replace votetype_pid = 4 if voted2012 == 0 & isdem == 0
label var votetype_pid "Party ID by 2012 turnout"
label define votetype_pid 1 "Dem voter" 2 "Dem non-voter" 3 "Rep voter" 4 "Rep non-voter"
label values votetype_pid votetype_pid

qui recode faminc (1/3=1) (4/6=2) (7/9=3) (10/14=4) (16/32=4) (else=.), gen(faminc2)
label define faminc2 1 "<$30,000" 2 "$30-60,000" 3 "$60-100,000" 4 ">$100,000"
label values faminc2 faminc2

*Save out csv of data to make plots in R.
outsheet faminc2 educ decades race pew_religimp iscont_pid votetype_pid V103 using "dataForRPlots.csv", comma replace

*********************
*Table 1: summary of demographic and behavioral differences
*********************

*Variables: faminc2 educ decades pew_religimp race  voted2012congprim validated_regd_demrep
qui gen diff_incgt100 = (faminc2 == 4)
label var diff_incgt100 "Family income > $100K"
qui gen diff_educ4yr = (educ == 5 | educ == 6)
label var diff_educ4yr "Education 4-year college+"
qui gen diff_age50 = (age > 49)
label var diff_age50 "Age 50+"
qui gen diff_relig = (pew_religimp == 1)
label var diff_relig "Religion very important"
qui gen diff_racenonwhite = (race != 1)
label var diff_racenonwhite "Race not white"
qui gen diff_prim = voted2012congprim
label var diff_prim "Voted 2012 congressional primary"
qui gen diff_regd = validated_regd_demrep
qui replace diff_regd = . if party_reg_state == 0
label var diff_regd "Registered with major party in party registration state"
summ diff_*

*File for writing.
file open myfile using "tables/Table01_DonorVoterDifferencesDemogsBehavior.csv", write replace
file write myfile ",Democrats,,,Republicans,,," _n
file write myfile ",Difference in Percentage with Characteristic,,,Difference in Percentage with Characteristic,," _n
file write myfile "Characteristic,Donors vs Non-Donors,Voters vs Non-Voters,Ratio of differences,Donors vs Non-Donors,Voters vs Non-Voters,Ratio of differences" _n

*Use collapse to calculate proportional differences.
foreach var of varlist diff_*{
	local rowlabel: variable label `var'
  local row "`rowlabel'"
  di _n _n "`rowlabel':" _n
  *local sdrow "          "  
  *Grab four values: 
  *1. Dem donors - Dem non-donors
  *2. Dem voters - Dem non-voters
  *3. Rep donors - Rep non-donors
  *2. Rep voters - Rep non-voters
  *Donor diffs.
  preserve
  collapse (mean) mn=`var' (semean) se=`var'  [aweight = V103], by(iscont_pid)
  li
  local demdonor = mn in 1
  local demnondonor = mn in 2
  local demdonordiff = `demdonor' - `demnondonor'
  di "Democratic diff: `demdonordiff'"
  local repdonor = mn in 3
  local repnondonor = mn in 4
  local repdonordiff = `repdonor' - `repnondonor'
  di "Republican diff: `repdonordiff'"
  restore
  *Voter diffs.
  preserve
  collapse (mean) mn=`var' (semean) se=`var'  [aweight = V103], by(votetype_pid)
  li
  local demvoter = mn in 1
  local demnonvoter = mn in 2
  local demvoterdiff = `demvoter' - `demnonvoter'
  di "Democratic diff: `demvoterdiff'"
  local repvoter = mn in 3
  local repnonvoter = mn in 4
  local repvoterdiff = `repvoter' - `repnonvoter'
  di "Republican diff: `repvoterdiff'"
  restore
  local demratio = `demdonordiff'/ `demvoterdiff'
  local repratio = `repdonordiff'/ `repvoterdiff'
  local row = "`row'" + "," + string(100*`demdonordiff',"%9.2f") + "," + string(100*`demvoterdiff',"%9.2f") + "," + string(`demratio',"%9.2f")
  local row = "`row'" + "," + string(100*`repdonordiff',"%9.2f") + "," + string(100*`repvoterdiff',"%9.2f") + "," + string(`repratio',"%9.2f")
  *local sdrow = "`sdrow'" + ",[" + string(100*`se',"%9.2f") + "]"
  di "`row'"
  *di "`sdrow'"
  file write myfile "`row'" _n
  *file write myfile "`sdrow'" _n
}
*Add rows indicating numbers of donors and voters by party.
*Donors.
qui count if iscontributord == 1
local row = "Number of donors,`r(N)',,,"
qui count if iscontributorr == 1
local row = "`row'" + "`r(N)',,,"
di "`row'"
file write myfile "`row'" _n
*Non-donors.
qui count if iscontributord == 0
local row = "Number of non-donors,`r(N)',,,"
qui count if iscontributorr == 0
local row = "`row'" + "`r(N)',,,"
di "`row'"
file write myfile "`row'" _n
*Voters.
qui count if votetype_pid == 1
local row = "Number of voters,,`r(N)',,"
qui count if votetype_pid == 3
local row = "`row'" + ",`r(N)',,"
di "`row'"
file write myfile "`row'" _n
*Non-donors.
qui count if votetype_pid == 2
local row = "Number of non-voters,,`r(N)',,"
qui count if votetype_pid == 4
local row = "`row'" + ",`r(N)',,"
di "`row'"
file write myfile "`row'" _n

*file write myfile "Standard errors in brackets." _n
file close myfile

**************************
*
* Table 02: Predicting ideology within party by contributor status
*
**************************

*Set constant sample among reps
qui regress ideofactor voted2012 voted2012congprim iscontributor I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* i.inputstate [aweight=V103]
gen useme=e(sample)
local templabel : var label ideofactor

tobit ideofactor voted2012 voted2012congprim iscontributor if isdem==0 & useme==1 [aweight=V103], ll(-1) ul(1) robust
summ ideofactor if e(sample)
outreg using "tables/Table02.out", bracket 3aster se ctitle("`templabel' Republicans") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)',"Left censored obs.",`e(N_lc)',"Right censored obs.",`e(N_rc)') replace

tobit ideofactor voted2012 voted2012congprim iscontributor I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if isdem==0 & useme==1 [aweight=V103], ll(-1) ul(1) robust
summ ideofactor if e(sample)
outreg using "tables/Table02.out", bracket 3aster se ctitle("`templabel' Republicans") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)',"Left censored obs.",`e(N_lc)',"Right censored obs.",`e(N_rc)') append

tobit ideofactor voted2012 voted2012congprim iscontributor if isdem==1 & useme==1 [aweight=V103], ll(-1) ul(1) robust
summ ideofactor if e(sample)
outreg using "tables/Table02.out", bracket 3aster se ctitle("`templabel' Democrats") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)',"Left censored obs.",`e(N_lc)',"Right censored obs.",`e(N_rc)') append

tobit ideofactor voted2012 voted2012congprim iscontributor I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if isdem==1 & useme==1 [aweight=V103], ll(-1) ul(1) robust
summ ideofactor if e(sample)
outreg using "tables/Table02.out", bracket 3aster se ctitle("`templabel' Democrats") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)',"Left censored obs.",`e(N_lc)',"Right censored obs.",`e(N_rc)') append
drop useme

**************************
*
* Table 03: Predicting the decision to contribute. Spatial models
*  Also includes code for SI Table 06 (Correlation coefficients for spatial model analysis)
*
**************************

qui regress iscontributor quadloss abs_selfplace dist_between I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* [aweight=V103] 
gen useme=e(sample)
summ iscontributor if useme==1
local rmean=`r(mean)'
local rdv=`r(sd)'
local templabel : var label iscontributor

* Correlation coefficients for Spatial model. SI Table 06.
log using "tables/SITable06_CorrelationCoefficientsSpatialAnalysis.out", replace text

	* Everyone
	pwcorr quadloss abs_selfplace dist_closer dist_between if useme==1 [aweight=V103], sig

	* Democrats
	pwcorr quadloss abs_selfplace dist_closer dist_between if useme==1 & isdem==1 [aweight=V103], sig

	* Republicans
	pwcorr quadloss abs_selfplace dist_closer dist_between if useme==1 & isdem==0 [aweight=V103], sig

log close

* Basic model, pooled partisans.
regress iscontributor quadloss I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 [aweight=V103], robust 
outreg using "tables/Table03.out", bracket 3aster bdec(4) se ctitle("Spatial model") addstat("Mean of DV",`rmean',"SD of DV",`rdv') replace

* Basic model, Dems.
regress iscontributor quadloss I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==1 [aweight=V103], robust 
summ iscontributor if e(sample)
local rmean=`r(mean)'
local rdv=`r(sd)'
outreg using "tables/Table03.out", bracket 3aster bdec(4) se ctitle("Democrats") addstat("Mean of DV",`rmean',"SD of DV",`rdv') append

* Basic model, Reps.
regress iscontributor quadloss I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==0 [aweight=V103], robust 
summ iscontributor if e(sample)
local rmean=`r(mean)'
local rdv=`r(sd)'
outreg using "tables/Table03.out", bracket 3aster bdec(4) se ctitle("Republicans") addstat("Mean of DV",`rmean',"SD of DV",`rdv') append

* With self placement
regress iscontributor quadloss abs_selfplace I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==1 [aweight=V103], robust 
summ iscontributor if e(sample)
local rmean=`r(mean)'
local rdv=`r(sd)'
outreg using "tables/Table03.out", bracket 3aster bdec(4) se ctitle("Robustness: With Self-Placement, Democrats") addstat("Mean of DV",`rmean',"SD of DV",`rdv') append

regress iscontributor quadloss abs_selfplace I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==0 [aweight=V103], robust 
summ iscontributor if e(sample)
local rmean=`r(mean)'
local rdv=`r(sd)'
outreg using "tables/Table03.out", bracket 3aster bdec(4) se ctitle("Robustness: With Self-Placement, Republicans") addstat("Mean of DV",`rmean',"SD of DV",`rdv') append

* With distance to closer
regress iscontributor quadloss dist_closer I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==1 [aweight=V103], robust 
summ iscontributor if e(sample)
local rmean=`r(mean)'
local rdv=`r(sd)'
outreg using "tables/Table03.out", bracket 3aster bdec(4) se ctitle("Robustness: With Distance to Closer, Democrats") addstat("Mean of DV",`rmean',"SD of DV",`rdv') append

regress iscontributor quadloss dist_closer I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==0 [aweight=V103], robust 
summ iscontributor if e(sample)
local rmean=`r(mean)'
local rdv=`r(sd)'
outreg using "tables/Table03.out", bracket 3aster bdec(4) se ctitle("Robustness: With Distance to Closer, Republicans") addstat("Mean of DV",`rmean',"SD of DV",`rdv') append

* With polarization
regress iscontributor quadloss dist_between I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==1 [aweight=V103], robust 
summ iscontributor if e(sample)
local rmean=`r(mean)'
local rdv=`r(sd)'
outreg using "tables/Table03.out", bracket 3aster bdec(4) se ctitle("Robustness: With Party Polarization, Democrats") addstat("Mean of DV",`rmean',"SD of DV",`rdv') append

regress iscontributor quadloss dist_between I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==0 [aweight=V103], robust 
summ iscontributor if e(sample)
local rmean=`r(mean)'
local rdv=`r(sd)'
outreg using "tables/Table03.out", bracket 3aster bdec(4) se ctitle("Robustness: With Party Polarization, Republicans") addstat("Mean of DV",`rmean',"SD of DV",`rdv') append

* Saturated Model
regress iscontributor quadloss abs_selfplace dist_closer dist_between I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==1 [aweight=V103], robust 
summ iscontributor if e(sample)
local rmean=`r(mean)'
local rdv=`r(sd)'
outreg using "tables/Table03.out", bracket 3aster bdec(4) se ctitle("Robustness: Saturated Model, Democrats") addstat("Mean of DV",`rmean',"SD of DV",`rdv') append

regress iscontributor quadloss abs_selfplace dist_closer dist_between I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==0 [aweight=V103], robust 
summ iscontributor if e(sample)
local rmean=`r(mean)'
local rdv=`r(sd)'
outreg using "tables/Table03.out", bracket 3aster bdec(4) se ctitle("Robustness: Saturated Model, Republicans") addstat("Mean of DV",`rmean',"SD of DV",`rdv') append
drop useme

**************************
*
* Figure 01: Ideology by party and voting and donor status
*
**************************

* Boxplot of ideology for donors vs non donors.
* Figure 1, Panel A
graph box ideofactor [aweight = V103], over(iscont_pid) ytitle("") title("Panel A: Boxplots of Ideology", size(small) span) xsize(8.5) ysize(5) ytitle("Ideology scale (-1=Liberal, 1=Conservative)")  name(F1pideoCont, replace) fysize(50)
tabstat ideofactor [aweight = V103], by(iscont_pid) s(p5 q p95)

* Figure 1, Panel B
* This is the graph of the policy factor ideology score, by party
twoway (kdensity ideofactor [aweight=V103], lcolor(black)) (kdensity ideofactor if voted2012==1 [aweight=V103], lcolor(black) lpattern(longdash)) (kdensity ideofactor if voted2012congprim==1 [aweight=V103], lcolor(black) lpattern(shortdash)) (kdensity ideofactor if iscontributor==1 & binned_2012amountR>0 [aweight=V103], lcolor(black) lpattern(dot)) if isdem==0, legend(order(1 "Everyone" 2 "Voted 2012 General" 3 "Voted 2012 Cong. Prim." 4 "Gave 2012") size(vsmall) cols(2)) xtitle("Ideology scale (-1=Liberal, 1=Conservative)") ytitle("Density") title("Republicans") name(F1IdeoByTypeR, replace)  scheme(s1mono)

twoway (kdensity ideofactor [aweight=V103], lcolor(black)) (kdensity ideofactor if voted2012==1 [aweight=V103], lcolor(black) lpattern(longdash)) (kdensity ideofactor if voted2012congprim==1 [aweight=V103], lcolor(black) lpattern(shortdash)) (kdensity ideofactor if iscontributor==1 & binned_2012amountR>0 [aweight=V103], lcolor(black) lpattern(dot)) if isdem==1, legend(off) xtitle("Ideology scale (-1=Liberal, 1=Conservative)") ytitle("Density") title("Democrats") name(F1IdeoByTypeD, replace) scheme(s1mono)

grc1leg F1IdeoByTypeD F1IdeoByTypeR, ycommon xcommon cols(3) imargin(tiny) scheme(s1mono) xsize(8.5) ysize(5) title("Panel B: Ideology by Levels of Participation", size(small) span) name(F1IdeoByTypeCombinedGR1, replace) legendfrom(F1IdeoByTypeR)

* BUILD FIGURE 1, export all 2 panels
graph combine F1pideoCont F1IdeoByTypeCombinedGR1, cols(1) iscale(*1.0) imargin(small) title("Figure 1: Ideology of Contributors and Non-Contributors, by Party", size(vsmall) nobox) note("Source: Merged CCES/DIME dataset.") name(Figure01, replace) xsize(7.5) ysize(10) scale(1.0)
graph export "figures/Figure01.pdf", as(pdf) replace

**************************
*
* Figure 02: Plot of CFScore by PolicyIdeology survey scale
*
**************************

* Npte: This is CF score. 2012 weighted CF score in appendix

*Simple within-party correlations.
corr ideofactor cfscoreR [aweight = V103]
bys isdem: corr ideofactor cfscoreR [aweight = V103]
*For Repubs with CF > 0 and Dems with CF < 0.
corr ideofactor cfscoreR if isdem == 0 & cfscoreR > 0 [aweight = V103]
corr ideofactor cfscoreR if isdem == 1 & cfscoreR < 0 [aweight = V103]
*How many Republican donors with cf < 0?
qui gen cfgt0 = cfscoreR > 0
tab cfgt0 if isdem == 0 & iscontributor == 1 [aweight = V103]
*Thirty percent of Republican donors with cf < 0 voted for Obama.
tab CC410a cfgt0 if isdem == 0 & iscontributor == 1 [aweight = V103], col

* For graphing purposes, topcode and bottomcode CFscores
gen truncorigcf=cfscoreR
replace truncorigcf=2 if truncorigcf>2 & truncorigcf~=.
replace truncorigcf=-2 if truncorigcf<-2 & truncorigcf~=.
label var truncorigcf "CFscore, top coded at -2 and 2 (8 cases)"

*Panel A: Density of CFscores
twoway (kdensity truncorigcf if isdem==1 & iscontributor==1 [aweight = V103], lcolor(black) lpattern(solid) ) (kdensity truncorigcf if isdem==0 & iscontributor==1 [aweight = V103], lcolor(black) lpattern(dash) ) (kdensity truncorigcf if iscontributor==1 & isdem==. [aweight = V103], lcolor(black) lpattern(dot) ) , title("A) Distribution of CFscores", size(small)) legend(order(1 "Democrats" 2 "Republicans" 3 "Others") size(small)) scheme(s1mono) xtitle("CFscore", size(small)) ytitle("Density", size(small)) name(F2CFtoIdeoPanelA, replace)

*Panel B: Density of CFscores
twoway (kdensity ideofactor if isdem==1 & iscontributor==1 [aweight = V103], lcolor(black) lpattern(solid) ) (kdensity ideofactor if isdem==0 & iscontributor==1 [aweight = V103], lcolor(black) lpattern(dash) ) (kdensity ideofactor if iscontributor==1 & isdem==. [aweight = V103], lcolor(black) lpattern(dot) ) , title("B) Distribution of Policy Ideology Score Among Donors", size(small)) legend(order(1 "Democrats" 2 "Republicans" 3 "Others") size(small)) scheme(s1mono) xtitle("Policy Ideology Score", size(small)) ytitle("Density", size(small)) name(F2CFtoIdeoPanelB, replace)

*Panel C: Policy Score by CFscore
twoway (scatter ideofactor truncorigcf if isdem==1 & iscontributor==1, mcolor(black) msize(tiny) msymbol(circle)) (scatter ideofactor truncorigcf if isdem==0 & iscontributor==1, mcolor(gs8) msize(tiny) msymbol(square)) (scatter ideofactor truncorigcf if isdem==. & iscontributor==1, mcolor(gs12) msize(vsmall) msymbol(triangle)) (lpoly ideofactor truncorigcf [aweight = V103], lcolor(black) lpattern(dash)), title("C) Policy Ideology Score by CFscore", size(small)) subtitle("All contributors", size(small)) legend(order(1 "Democrats" 2 "Republicans" 3 "Others" 4 "Local Smoother") size(small)) scheme(s1mono) xtitle("CFscore", size(small)) ytitle("Policy Ideology Score", size(small)) name(F2CFtoIdeoPanelC, replace)

summ truncorigcf if isdem==1 & iscontributor==1 [aweight = V103], detail
gen plotdem=isdem==1 & iscontributor==1 & truncorigcf>`r(p10)' & truncorigcf<`r(p90)'
summ truncorigcf ideofactor if isdem==1 & iscontributor==1 & plotdem==1 [aweight = V103]
pwcorr truncorigcf ideofactor if isdem==1 & iscontributor==1 & plotdem==1 [aweight = V103]

summ truncorigcf if isdem==0 & iscontributor==1 [aweight = V103], detail
gen plotrep=isdem==0 & iscontributor==1 & truncorigcf>`r(p10)' & truncorigcf<`r(p90)'
summ truncorigcf ideofactor if isdem==0 & iscontributor==1 & plotrep==1 [aweight = V103]
pwcorr truncorigcf ideofactor if isdem==0 & iscontributor==1 & plotrep==1 [aweight = V103]

* Panel D: Policy Scores by CFscores, within party D/R 10-90% percentile
twoway (scatter ideofactor truncorigcf if isdem==1 & iscontributor==1 & plotdem==1, mcolor(gs6) msize(tiny) msymbol(circle)) (scatter ideofactor truncorigcf if isdem==0 & iscontributor==1 & plotrep==1, mcolor(gs8) msize(tiny) msymbol(square)) (lpoly ideofactor truncorigcf if isdem==1 & iscontributor==1 & plotdem==1 [aweight = V103], lcolor(black) lpattern(dash)) (lpoly ideofactor truncorigcf if isdem==0 & iscontributor==1 & plotrep==1 [aweight = V103], lcolor(black) lpattern(dash)), title("D) Policy Ideology Score by CFscore", size(small)) subtitle("10% to 90% percentile of CFscore in party", size(small)) legend(order(1 "Democrats" 2 "Republicans" 3 "Among Dems." 4 "Among Reps.") size(small)) scheme(s1mono) xtitle("CFscore", size(small)) ytitle("Policy Ideology Score", size(small)) name(F2CFtoIdeoPanelD, replace)

* Marginal effect of changes in CF on ideology from this figure

lpoly ideofactor truncorigcf if isdem==1 & iscontributor==1 & plotdem==1 [aweight = V103], gen(pred) at(truncorigcf)  nograph  
summ truncorigcf if isdem==1 & iscontributor==1 & plotdem==1 [aweight = V103], detail
summ pred if truncorigcf >`r(min)' & truncorigcf<=`r(p10)' & isdem==1 & iscontributor==1 & plotdem==1 [aweight = V103]
qui summ truncorigcf if isdem==1 & iscontributor==1 & plotdem==1 [aweight = V103], detail
summ pred if truncorigcf >`r(p90)' & truncorigcf<=`r(max)' & isdem==1 & iscontributor==1 & plotdem==1 [aweight = V103]
drop pred

lpoly ideofactor truncorigcf if isdem==0 & iscontributor==1 & plotrep==1 [aweight = V103], gen(pred) at(truncorigcf)  nograph  
qui summ truncorigcf if isdem==0 & iscontributor==1 & plotrep==1 [aweight = V103], detail
summ pred if truncorigcf >`r(min)' & truncorigcf<=`r(p10)' & isdem==0 & iscontributor==1 & plotrep==1 [aweight = V103]
qui summ truncorigcf if isdem==0 & iscontributor==1 & plotrep==1 [aweight = V103], detail
summ pred if truncorigcf >`r(p90)' & truncorigcf<=`r(max)' & isdem==0 & iscontributor==1 & plotrep==1 [aweight = V103]
drop pred

graph combine F2CFtoIdeoPanelA  F2CFtoIdeoPanelB  F2CFtoIdeoPanelC  F2CFtoIdeoPanelD, imargin(medsmall) title(Figure 2: Relationship between Policy Ideology and CFscore by Party, size(small)) note(Note: Partisans include leaners. See text for details. Source: Merged CCES/DIME., size(vsmall)) scheme(s1mono) name(Figure02, replace) xsize(8.5) ysize(11) scale(.75)
graph export "figures/Figure02.pdf", as(pdf) replace

* Various footnote/supplemental analysis

* For footnote: Another outcome, Obama Approval - Congress Approval
recode CC308a (1=1) (2=.67) (3=.33) (4=0) (*=.), gen(ObamaApproval)
recode CC308b (1=1) (2=.67) (3=.33) (4=0) (*=.), gen(CongApproval)
gen ApprovalOminusC=ObamaApproval-CongApproval

twoway (scatter ApprovalOminusC truncorigcf if isdem==1 & iscontributor==1 & plotdem==1, mcolor(gs8) msize(tiny) msymbol(circle)) (scatter ApprovalOminusC truncorigcf if isdem==0 & iscontributor==1 & plotrep==1, mcolor(gs8) msize(tiny) msymbol(square)) (lpoly ApprovalOminusC truncorigcf if isdem==1 & iscontributor==1 & plotdem==1 [aweight = V103], lcolor(black) lpattern(dash)) (lpoly ApprovalOminusC truncorigcf if isdem==0 & iscontributor==1 & plotrep==1 [aweight = V103], lcolor(black) lpattern(dash)), title("Footnote: Approval Obama minus Approval Congress by CFscore", size(small)) legend(order(1 "Democrats (with leaners)" 2 "Republicans (with leaners)" 3 "Others" 4 "Local Polynomial Smoother") size(small)) scheme(s1mono) xtitle("CFscore", size(small)) ytitle("Obama Approval minus Congress Approval", size(small)) name(CFtoIdeoPanelFootnote1, replace)

* Another footnote: Instead of conditiong on PID, just divide CFscore into 3 bins
twoway (scatter ideofactor truncorigcf, msize(tiny)) (lpoly ideofactor truncorigcf [aweight = V103] if truncorigcf<-.5) (lpoly ideofactor truncorigcf [aweight = V103] if truncorigcf>=-.5 & truncorigcf<=.5) (lpoly ideofactor truncorigcf [aweight = V103] if truncorigcf>.5), title("Policy Ideology Score by CFscore, 3 Bins", size(small)) legend(off) scheme(s1mono) ytitle("Policy Ideology Scale", size(small)) xtitle("CFscore", size(small)) name(CFtoIdeoPanelFootnote2, replace)

twoway (scatter ideofactor truncorigcf, msize(small)) (lpoly ideofactor truncorigcf [aweight = V103]) (kdensity truncorigcf [aweight = V103], yaxis(2)), ytitle("Policy Ideology Scale", size(small)) xtitle("CFscore", size(small)) by(, title(Policy Ideology by CFscore by PID, size(small))) legend(order(2 "Policy Ideology" 3 "Density CFscore") size(small)) scheme(s1color) name(CFtoIdeobyPID, replace) by(pid7, holes(4 6) imargin(vsmall) iscale(*.5))

drop cfgt0 plotdem plotrep

**************************
*
* SI Figure 05: Donors and non-donors on validated behaviors.
*
**************************

*Panel A of Figure S5
tab voted2012 iscont_pid [aweight = V103], col
graph bar (mean) voted2012 [aweight = V103], over(iscont_pid, label(labcolor(black) angle(forty_five) labsize(vsmall))) ytitle(Proportion Voting) title("Panel A: 2012 General Election Turnout", size(small) span) xsize(8.5) ysize(5) name(S5pvoted12Cont, replace)

*Panel B of Figure S5
tab voted2012congprim iscont_pid [aweight = V103], col
graph bar (mean) voted2012congprim [aweight = V103], over(iscont_pid, label(labcolor(black) angle(forty_five) labsize(vsmall))) ytitle(Proportion Voting) title("Panel B: 2012 Congressional Primary Election Turnout", size(small) span) xsize(8.5) ysize(5) name(S5pvoted12primCont, replace)

* BUILD FIGURE S5, export all 2 panels
graph combine S5pvoted12Cont S5pvoted12primCont, cols(1) iscale(*.90) imargin(small) title("Figure S5: Participation by Contributors and Non-Contributors, by Party", size(vsmall) nobox) note("Source: Merged CCES/DIME dataset.") name(FigureS05, replace) xsize(7.5) ysize(10) scale(.80)
graph export "figures/FigureS05.pdf", as(pdf) replace

**************************
*
* SI Figure 08: Party Registration by Contributor Status
*
**************************

tab validated_regd_demrep iscont_pid if party_reg_state == 1 [aweight = V103], col
graph bar (mean) validated_regd_demrep if party_reg_state == 1 [aweight = V103], over(iscont_pid, label(labcolor(black) angle(forty_five) labsize(vsmall))) ytitle(Rate of Registration) title("2012 Registered with Major Party by Contributor Status") note("Source: 2012 CCES merged to DIME data; Only states with Party of Registration") name(S8pregdPartyCont, replace)
graph combine S8pregdPartyCont, cols(1) iscale(*.90) imargin(small) title("Figure S8", size(vsmall) nobox) name(FigureS08, replace) xsize(7.5) ysize(10) scale(.80)
graph export "figures/FigureS08.pdf", as(pdf) replace

**************************
*
* SI Figure 09: Plot of 2012 Dollar-weighted CFScore by PolicyIdeology survey scale
*
**************************

*Simple within-party correlations.
corr ideofactor wtrecipcf12R [aweight = V103]
bys isdem: corr ideofactor wtrecipcf12R [aweight = V103]
*For Repubs with CF > 0 and Dems with CF < 0.
corr ideofactor wtrecipcf12R if isdem == 0 & wtrecipcf12R > 0 [aweight = V103]
corr ideofactor wtrecipcf12R if isdem == 1 & wtrecipcf12R < 0 [aweight = V103]
*How many Republican donors with cf < 0?
qui gen cfgt0 = wtrecipcf12R > 0
tab cfgt0 if isdem == 0 & iscontributor == 1 [aweight = V103]
*Thirty percent of Republican donors with cf < 0 voted for Obama.
tab CC410a cfgt0 if isdem == 0 & iscontributor == 1 [aweight = V103], col

* For graphing purposes, topcode and bottomcode CFscores
gen trunc12cf=wtrecipcf12R
replace trunc12cf=2 if trunc12cf>2 & trunc12cf~=.
replace trunc12cf=-2 if trunc12cf<-2 & trunc12cf~=.
label var trunc12cf "2012 Dollar Weighted CFscore, top coded at -2 and 2 (4 cases)"

*Panel A: Density of CFscores
twoway (kdensity trunc12cf if isdem==1 & iscontributor==1 [aweight = V103], lcolor(black) lpattern(solid) ) (kdensity trunc12cf if isdem==0 & iscontributor==1 [aweight = V103], lcolor(black) lpattern(dash) ) (kdensity trunc12cf if iscontributor==1 & isdem==. [aweight = V103], lcolor(black) lpattern(dot) ) , title("A) Distribution of CFscores", size(small)) legend(order(1 "Democrats" 2 "Republicans" 3 "Others") size(small)) scheme(s1mono) xtitle("2012 Dollar Weighted CFscore", size(small)) ytitle("Density", size(small)) name(S9CFtoIdeoPanelA, replace)

*Panel B: Density of CFscores
twoway (kdensity ideofactor if isdem==1 & iscontributor==1 [aweight = V103], lcolor(black) lpattern(solid) ) (kdensity ideofactor if isdem==0 & iscontributor==1 [aweight = V103], lcolor(black) lpattern(dash) ) (kdensity ideofactor if iscontributor==1 & isdem==. [aweight = V103], lcolor(black) lpattern(dot) ) , title("B) Distribution of Policy Ideology Score Among Donors", size(small)) legend(order(1 "Democrats" 2 "Republicans" 3 "Others") size(small)) scheme(s1mono) xtitle("Policy Ideology Score", size(small)) ytitle("Density", size(small)) name(S9CFtoIdeoPanelB, replace)

*Panel C: Policy Score by CFscore
twoway (scatter ideofactor trunc12cf if isdem==1 & iscontributor==1, mcolor(black) msize(tiny) msymbol(circle)) (scatter ideofactor trunc12cf if isdem==0 & iscontributor==1, mcolor(gs8) msize(tiny) msymbol(square)) (scatter ideofactor trunc12cf if isdem==. & iscontributor==1, mcolor(gs12) msize(vsmall) msymbol(triangle)) (lpoly ideofactor trunc12cf [aweight = V103], lcolor(black) lpattern(dash)), title("C) Policy Ideology Score by CFscore", size(small)) subtitle("All contributors", size(small)) legend(order(1 "Democrats" 2 "Republicans" 3 "Others" 4 "Local Smoother") size(small)) scheme(s1mono) xtitle("2012 Dollar Weighted CFscore", size(small)) ytitle("Policy Ideology Score", size(small)) name(S9CFtoIdeoPanelC, replace)

summ trunc12cf if isdem==1 & iscontributor==1, detail
gen plotdem= isdem==1 & iscontributor==1 & trunc12cf>`r(p10)' & trunc12cf<`r(p90)'
summ trunc12cf ideofactor if isdem==1 & iscontributor==1 & plotdem==1

summ trunc12cf if isdem==0 & iscontributor==1, detail
gen plotrep= isdem==0 & iscontributor==1 & trunc12cf>`r(p10)' & trunc12cf<`r(p90)'
summ trunc12cf ideofactor if isdem==0 & iscontributor==1 & plotrep==1

* Panel D: Policy Scores by CFscores, within party D/R 10-90% percentile
twoway (scatter ideofactor trunc12cf if isdem==1 & iscontributor==1 & plotdem==1, mcolor(gs6) msize(tiny) msymbol(circle)) (scatter ideofactor trunc12cf if isdem==0 & iscontributor==1 & plotrep==1, mcolor(gs8) msize(tiny) msymbol(square)) (lpoly ideofactor trunc12cf if isdem==1 & iscontributor==1 & plotdem==1 [aweight = V103], lcolor(black) lpattern(dash)) (lpoly ideofactor trunc12cf if isdem==0 & iscontributor==1 & plotrep==1 [aweight = V103], lcolor(black) lpattern(dash)), title("D) Policy Ideology Score by CFscore", size(small)) subtitle("10% to 90% percentile of CFscore in party", size(small)) legend(order(1 "Democrats" 2 "Republicans" 3 "Among Dems." 4 "Among Reps.") size(small)) scheme(s1mono) xtitle("2012 Dollar Weighted CFscore", size(small)) ytitle("Policy Ideology Score", size(small)) name(S9CFtoIdeoPanelD, replace)

* Marginal effect of changes in CF on ideology from this figure

lpoly ideofactor trunc12cf if isdem==1 & iscontributor==1 & plotdem==1 [aweight = V103], gen(pred) at(trunc12cf)  nograph  
summ trunc12cf if isdem==1 & iscontributor==1 & plotdem==1 [aweight = V103], detail
summ pred if trunc12cf >`r(min)' & trunc12cf<=`r(p10)' & isdem==1 & iscontributor==1 & plotdem==1 [aweight = V103]
qui summ trunc12cf if isdem==1 & iscontributor==1 & plotdem==1 [aweight = V103], detail
summ pred if trunc12cf >`r(p90)' & trunc12cf<=`r(max)' & isdem==1 & iscontributor==1 & plotdem==1 [aweight = V103]
drop pred

lpoly ideofactor trunc12cf if isdem==0 & iscontributor==1 & plotrep==1 [aweight = V103], gen(pred) at(trunc12cf)  nograph  
qui summ trunc12cf if isdem==0 & iscontributor==1 & plotrep==1 [aweight = V103], detail
summ pred if trunc12cf >`r(min)' & trunc12cf<=`r(p10)' & isdem==0 & iscontributor==1 & plotrep==1 [aweight = V103]
qui summ trunc12cf if isdem==0 & iscontributor==1 & plotrep==1 [aweight = V103], detail
summ pred if trunc12cf >`r(p90)' & trunc12cf<=`r(max)' & isdem==0 & iscontributor==1 & plotrep==1 [aweight = V103]
drop pred

graph combine S9CFtoIdeoPanelA  S9CFtoIdeoPanelB  S9CFtoIdeoPanelC  S9CFtoIdeoPanelD, imargin(medsmall) title(Figure S9: Relationship between Policy Ideology and Estimated 2012 CFscore by Party, size(small)) note(Note: Partisans include leaners. See text for details. Source: Merged CCES/DIME., size(vsmall)) scheme(s1mono) name(FigureS09, replace) xsize(8.5) ysize(11) scale(.75)
graph export "figures/FigureS09.pdf", as(pdf) replace

**************************
*
* SI Figure 10: Robustness of Figure 2 result for various numbers of donations
*
**************************

qui gen numdons2012 = 0
qui replace numdons2012 = 1 if binned_2012num == 1
qui replace numdons2012 = 2 if binned_2012num > 1 & binned_2012num < 5
qui replace numdons2012 = 3 if binned_2012num > 5
qui replace numdons2012 = 0 if binned_2012num == .
label define numdons 1 "1 2012 donation" 2 "2-4 2012 donations" 3 "5+ 2012 donations"
label values numdons2012 numdons
label variable numdons2012 "Number of validated 2012 donations"
forvalues i = 1/3 {
  preserve
  keep if numdons == `i' 
  local lab : label (numdons) `i'
  *Policy Score by CFscore
  twoway (scatter ideofactor truncorigcf if isdem==1 & iscontributor==1, mcolor(black) msize(tiny) msymbol(circle)) (scatter ideofactor truncorigcf if isdem==0 & iscontributor==1, mcolor(gs8) msize(tiny) msymbol(square)) (scatter ideofactor truncorigcf if isdem==. & iscontributor==1, mcolor(gs12) msize(vsmall) msymbol(triangle)) (lpoly ideofactor truncorigcf [aweight = V103], lcolor(black) lpattern(dash)), title("Policy Ideology Score by CFscore, `lab'", size(small)) legend(order(1 "Democrats" 2 "Republicans" 3 "Others" 4 "Local Smoother") size(small)) scheme(s1mono) xtitle("CFscore", size(small)) ytitle("Policy Ideology Score", size(small)) name("S10_`i'", replace)
  restore
}

* For graphing purposes, topcode and bottomcode CFscores
gen trunc10cf=wtrecipcf10R
replace trunc10cf=2 if trunc10cf>2 & trunc10cf~=.
replace trunc10cf=-2 if trunc10cf<-2 & trunc10cf~=.
label var trunc10cf "2010 Dollar Weighted CFscore, top coded at -2 and 2 (4 cases)"

twoway (scatter ideofactor trunc10cf if isdem==1 & iscontributor==1, mcolor(black) msize(tiny) msymbol(circle)) (scatter ideofactor trunc10cf if isdem==0 & iscontributor==1, mcolor(gs8) msize(tiny) msymbol(square)) (scatter ideofactor trunc10cf if isdem==. & iscontributor==1, mcolor(gs12) msize(vsmall) msymbol(triangle)) (lpoly ideofactor trunc10cf [aweight = V103], lcolor(black) lpattern(dash)), title("Policy Ideology Score by 2010 CFscore", size(small)) legend(order(1 "Democrats" 2 "Republicans" 3 "Others" 4 "Local Smoother") size(small)) scheme(s1mono) xtitle("2010 Dollar Weighted CFscore", size(small)) ytitle("Policy Ideology Score", size(small)) name("S10_4", replace)

*Save out.
graph combine S10_1 S10_2 S10_3 S10_4, imargin(medsmall) title("Figure S10: Robustness of Relationship between Policy Ideology and CFscore by Party", size(small)) note(Note: Partisans include leaners. See text for details. Source: Merged CCES/DIME., size(vsmall)) scheme(s1mono) name(FigureS10, replace) xsize(11) ysize(8.5) scale(.75)
graph export "figures/FigureS10.pdf", as(pdf) replace

**************************
*
* SI Figure 11: Foreign Policy Ideology by Donor/Voter Status
*
**************************

* Boxplot of ideology for donors vs non donors.
* Figure S11 Panel A
graph box foreignpolicyfactor [aweight = V103], over(iscont_pid) ytitle("") title("Panel A: Boxplots of Foreign Policy Ideology", size(small) span) xsize(8.5) ysize(5) ytitle("Foreign Policy Ideology scale")  name(S11fppideoCont, replace) fysize(50)
tabstat foreignpolicyfactor [aweight = V103], by(iscont_pid) s(p5 q p95)

* Figure S11, Panel B

* This is the graph of the policy factor ideology score, by party
twoway (kdensity foreignpolicyfactor [aweight=V103], lcolor(black)) (kdensity foreignpolicyfactor if voted2012==1 [aweight=V103], lcolor(black) lpattern(longdash)) (kdensity foreignpolicyfactor if voted2012congprim==1 [aweight=V103], lcolor(black) lpattern(shortdash)) (kdensity foreignpolicyfactor if iscontributor==1 & binned_2012amountR>0 [aweight=V103], lcolor(black) lpattern(dot)) if isdem==0, legend(order(1 "Everyone" 2 "Voted 2012 general" 3 "Voted 2012 Cong. Prim." 4 "Gave 2012") size(vsmall) cols(2)) xtitle("Foreign Policy scale (-1=Liberal, 1=Conservative)") ytitle("Density") title("Republicans") name(S11FPIdeoByTypeR, replace)  scheme(s1mono)

twoway (kdensity foreignpolicyfactor [aweight=V103], lcolor(black)) (kdensity foreignpolicyfactor if voted2012==1 [aweight=V103], lcolor(black) lpattern(longdash)) (kdensity foreignpolicyfactor if voted2012congprim==1 [aweight=V103], lcolor(black) lpattern(shortdash)) (kdensity foreignpolicyfactor if iscontributor==1 & binned_2012amountR>0 [aweight=V103], lcolor(black) lpattern(dot)) if isdem==1, legend(off) xtitle("Foreign Policy Ideology scale") ytitle("Density") title("Democrats") name(S11FPIdeoByTypeD, replace) scheme(s1mono)

grc1leg S11FPIdeoByTypeD S11FPIdeoByTypeR, ycommon xcommon cols(3) imargin(tiny) scheme(s1mono) xsize(8.5) ysize(5) title("Panel B: Foreign Policy Ideology by Levels of Participation", size(small) span) name(S11FPIdeoByTypeCombinedGR1, replace) legendfrom(S11FPIdeoByTypeR)

* BUILD FIGURE S11, export all 2 panels
graph combine S11fppideoCont S11FPIdeoByTypeCombinedGR1, cols(1) iscale(*1.0) imargin(small) title("Figure S11: Foreign Policy Ideology of Contributors and Non-Contributors, by Party", size(vsmall) nobox) note("Source: Merged CCES/DIME dataset.") name(FigureS11, replace) xsize(7.5) ysize(10) scale(1.0)
graph export "figures/FigureS11.pdf", as(pdf) replace

**************************
*
* SI Figure 12: Self-reported ideology by CFScore
*
**************************

twoway (scatter ideo5 truncorigcf if isdem==1 & iscontributor==1, mcolor(black) msize(tiny) msymbol(circle)) (scatter ideo5 truncorigcf if isdem==0 & iscontributor==1, mcolor(gs8) msize(tiny) msymbol(square)) (scatter ideo5 truncorigcf if isdem==. & iscontributor==1, mcolor(gs12) msize(vsmall) msymbol(triangle)) (lpoly ideo5 truncorigcf [aweight = V103], lcolor(black) lpattern(dash)), title("Self-Report Ideology by CFscore", size(small)) subtitle("All contributors", size(small)) legend(order(1 "Democrats" 2 "Republicans" 3 "Others" 4 "Local Smoother") size(small)) scheme(s1mono) xtitle("CFscore", size(small)) ytitle("Ideology (1=Very Liberal; 5=Very Conservative)", size(small)) name(S12CFtoSelfReportIdeo, replace)

graph combine S12CFtoSelfReportIdeo, cols(1) iscale(*.90) imargin(small) title("Figure S12", size(vsmall) nobox) note("Source: Merged CCES/DIME dataset.") name(FigureS12, replace) xsize(7.5) ysize(10) scale(.80) 
graph export "figures/FigureS12.pdf", as(pdf) replace

**************************
*
* SI Table 1: Predicting Participation by Donor Status
*
**************************

*Regressions to control for income and education.
*Republicans.
regress voted2012 iscontributor I_faminc* I_race* I_educ* I_decades* if isdem==0 [aweight=V103], robust
qui summ voted2012 if e(sample)
outreg using "tables/SITable01_predictingparticipation.out", bracket 3aster se ctitle("Turnout 2012 General, Republicans") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)') replace

regress voted2012congprim iscontributor I_faminc* I_race* I_educ* I_decades* if isdem==0 [aweight=V103], robust
qui summ voted2012congprim if e(sample)
outreg using "tables/SITable01_predictingparticipation.out", bracket 3aster se ctitle("Turnout 2012 Primary, Republicans") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)') append

*Democrats.
regress voted2012 iscontributor I_faminc* I_race* I_educ* I_decades* if isdem==1 [aweight=V103], robust
qui summ voted2012 if e(sample)
outreg using "tables/SITable01_predictingparticipation.out", bracket 3aster se ctitle("Turnout 2012 General, Democrats") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)') append

regress voted2012congprim iscontributor I_faminc* I_race* I_educ* I_decades* if isdem==1 [aweight=V103], robust
qui summ voted2012congprim if e(sample)
outreg using "tables/SITable01_predictingparticipation.out", bracket 3aster se ctitle("Turnout 2012 Primary, Democrats") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)') append

**************************
*
* SI Table 02: Factor Analysis of CCES items.
* See 00_MergeDatasetsPrepareForAnalysis.do
*
**************************

**************************
*
* SI Table 03: Predicting ideology within party by contributor status, 7 items with non-binary outcomes
*
**************************

*Set constant sample among reps. This is the same as the Table 2 sample.
qui regress ideofactor voted2012 voted2012congprim iscontributor I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* i.inputstate [aweight=V103]
gen useme=e(sample)

local templabel : var label ideofactornotbinary

tobit ideofactornotbinary voted2012 voted2012congprim iscontributor if isdem==0 & useme==1 [aweight=V103], ll(-1) ul(1) robust
summ ideofactornotbinary if e(sample)
outreg using "tables/SITable03_NonBinaryPolicyMeasures.out", bracket 3aster se ctitle("`templabel' Republicans") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)',"Left censored obs.",`e(N_lc)',"Right censored obs.",`e(N_rc)') replace

tobit ideofactornotbinary voted2012 voted2012congprim iscontributor I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if isdem==0 & useme==1 [aweight=V103], ll(-1) ul(1) robust
summ ideofactornotbinary if e(sample)
outreg using "tables/SITable03_NonBinaryPolicyMeasures.out", bracket 3aster se ctitle("`templabel' Republicans") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)',"Left censored obs.",`e(N_lc)',"Right censored obs.",`e(N_rc)') append

tobit ideofactornotbinary voted2012 voted2012congprim iscontributor if isdem==1 & useme==1 [aweight=V103], ll(-1) ul(1) robust
summ ideofactornotbinary if e(sample)
outreg using "tables/SITable03_NonBinaryPolicyMeasures.out", bracket 3aster se ctitle("`templabel' Democrats") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)',"Left censored obs.",`e(N_lc)',"Right censored obs.",`e(N_rc)') append

tobit ideofactornotbinary voted2012 voted2012congprim iscontributor I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if isdem==1 & useme==1 [aweight=V103], ll(-1) ul(1) robust
summ ideofactornotbinary if e(sample)
outreg using "tables/SITable03_NonBinaryPolicyMeasures.out", bracket 3aster se ctitle("`templabel' Democrats") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)',"Left censored obs.",`e(N_lc)',"Right censored obs.",`e(N_rc)') append

**************************
*
* Robustness, SI Table 04: Predicting ideology within party by contributor status, High Education folks
*
**************************

local templabel : var label ideofactor

tobit ideofactor voted2012 voted2012congprim iscontributor if isdem==0 & useme==1 & (educ==5 | educ==6) [aweight=V103], ll(-1) ul(1) robust
summ ideofactor if e(sample)
outreg using "tables/SITable04_HiEducation.out", bracket 3aster se ctitle("`templabel' Republicans") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)',"Left censored obs.",`e(N_lc)',"Right censored obs.",`e(N_rc)') replace

tobit ideofactor voted2012 voted2012congprim iscontributor I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if isdem==0 & useme==1 & (educ==5 | educ==6) [aweight=V103], ll(-1) ul(1) robust
summ ideofactor if e(sample)
outreg using "tables/SITable04_HiEducation.out", bracket 3aster se ctitle("`templabel' Republicans") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)',"Left censored obs.",`e(N_lc)',"Right censored obs.",`e(N_rc)') append

tobit ideofactor voted2012 voted2012congprim iscontributor if isdem==1 & useme==1 & (educ==5 | educ==6) [aweight=V103], ll(-1) ul(1) robust
summ ideofactor if e(sample)
outreg using "tables/SITable04_HiEducation.out", bracket 3aster se ctitle("`templabel' Democrats") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)',"Left censored obs.",`e(N_lc)',"Right censored obs.",`e(N_rc)') append

tobit ideofactor voted2012 voted2012congprim iscontributor I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if isdem==1 & useme==1 & (educ==5 | educ==6) [aweight=V103], ll(-1) ul(1) robust
summ ideofactor if e(sample)
outreg using "tables/SITable04_HiEducation.out", bracket 3aster se ctitle("`templabel' Democrats") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)',"Left censored obs.",`e(N_lc)',"Right censored obs.",`e(N_rc)') append
drop useme

**************************
*
* SI Table 05: Predicting ideological EXTREMITY (not directional, just number) by contributor status, 5 items with non-binary outcomes
*
**************************

*Set constant sample
qui ologit extreme_response voted2012 voted2012congprim iscontributor I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* i.inputstate isdem [aweight=V103]
gen useme=e(sample)
local templabel : var label extreme_response

ologit extreme_response voted2012 voted2012congprim iscontributor isdem if useme==1 [aweight=V103], robust
summ extreme_response if e(sample)
outreg using "tables/SITable05_ExtremityNonBinaryPolicyMeasures.out", bracket 3aster se ctitle("`templabel' Ordered Logit") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)') replace

ologit extreme_response voted2012 voted2012congprim iscontributor isdem I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 [aweight=V103], robust
summ extreme_response if e(sample)
outreg using "tables/SITable05_ExtremityNonBinaryPolicyMeasures.out", bracket 3aster se ctitle("`templabel' Ordered Logit") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)') append

regress extreme_response voted2012 voted2012congprim iscontributor isdem if useme==1 [aweight=V103], robust
summ extreme_response if e(sample)
outreg using "tables/SITable05_ExtremityNonBinaryPolicyMeasures.out", bracket 3aster se ctitle("`templabel' OLS") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)') append

regress extreme_response voted2012 voted2012congprim iscontributor isdem I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 [aweight=V103], robust
summ extreme_response if e(sample)
outreg using "tables/SITable05_ExtremityNonBinaryPolicyMeasures.out", bracket 3aster se ctitle("`templabel' OLS") addstat("Mean of DV",`r(mean)',"SD of DV",`r(sd)') append

drop useme

**************************
*
* SI Table 06: Code is above with code for Table 3
*
**************************

**************************
*
* SI Table 07: Predicting the decision to contribute. Spatial models. Logit
*
**************************

* This is the same sample as in the Table 03 analysis
qui regress iscontributor quadloss abs_selfplace dist_between I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* [aweight=V103] 
gen useme=e(sample)

* Basic model, pooled partisans.
logit iscontributor quadloss I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 [pweight=V103], robust 
* perform in sample mfx analysis of 1 unit change in distance measure, from -.5 below observed to +.5 above it
replace quadloss=quadloss-.5
predict lowvalue
replace quadloss=quadloss+1
predict highvalue
replace quadloss=quadloss-.5
gen quantofinterest=highvalue-lowvalue
summ quantofinterest if e(sample) [aweight=V103]
drop lowvalue highvalue quantofinterest
* End MFX
outreg using "tables/SITable07_RobustnessLogit.out", bracket 3aster bdec(4) adec(5) se ctitle("Spatial model") addstat("MFX of 1 unit change in quad dist. measure",`r(mean)',"Mean of DV",`rmean',"SD of DV",`rdv') replace

* Basic model, Dems.
logit iscontributor quadloss I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==1 [pweight=V103], robust 
* perform in sample mfx analysis of 1 unit change in distance measure, from -.5 below observed to +.5 above it
replace quadloss=quadloss-.5
predict lowvalue
replace quadloss=quadloss+1
predict highvalue
replace quadloss=quadloss-.5
gen quantofinterest=highvalue-lowvalue
summ quantofinterest if e(sample) [aweight=V103]
drop lowvalue highvalue quantofinterest
* End MFX
outreg using "tables/SITable07_RobustnessLogit.out", bracket 3aster bdec(4) adec(5) se ctitle("Democrats") addstat("MFX of 1 unit change in quad dist. measure",`r(mean)',"Mean of DV",`rmean',"SD of DV",`rdv') append

* Basic model, Reps.
logit iscontributor quadloss I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==0 [pweight=V103], robust 
* perform in sample mfx analysis of 1 unit change in distance measure, from -.5 below observed to +.5 above it
replace quadloss=quadloss-.5
predict lowvalue
replace quadloss=quadloss+1
predict highvalue
replace quadloss=quadloss-.5
gen quantofinterest=highvalue-lowvalue
summ quantofinterest if e(sample) [aweight=V103]
drop lowvalue highvalue quantofinterest
* End MFX
outreg using "tables/SITable07_RobustnessLogit.out", bracket 3aster bdec(4) adec(5) se ctitle("Republicans") addstat("MFX of 1 unit change in quad dist. measure",`r(mean)',"Mean of DV",`rmean',"SD of DV",`rdv') append

* With self placement
logit iscontributor quadloss abs_selfplace I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==1 [pweight=V103], robust 
* perform in sample mfx analysis of 1 unit change in distance measure, from -.5 below observed to +.5 above it
replace quadloss=quadloss-.5
predict lowvalue
replace quadloss=quadloss+1
predict highvalue
replace quadloss=quadloss-.5
gen quantofinterest=highvalue-lowvalue
summ quantofinterest if e(sample) [aweight=V103]
drop lowvalue highvalue quantofinterest
* End MFX
outreg using "tables/SITable07_RobustnessLogit.out", bracket 3aster bdec(4) adec(5) se ctitle("Robustness: With Self-Placement, Democrats") addstat("MFX of 1 unit change in quad dist. measure",`r(mean)',"Mean of DV",`rmean',"SD of DV",`rdv') append

logit iscontributor quadloss abs_selfplace I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==0 [pweight=V103], robust 
* perform in sample mfx analysis of 1 unit change in distance measure, from -.5 below observed to +.5 above it
replace quadloss=quadloss-.5
predict lowvalue
replace quadloss=quadloss+1
predict highvalue
replace quadloss=quadloss-.5
gen quantofinterest=highvalue-lowvalue
summ quantofinterest if e(sample) [aweight=V103]
drop lowvalue highvalue quantofinterest
* End MFX
outreg using "tables/SITable07_RobustnessLogit.out", bracket 3aster bdec(4) adec(5) se ctitle("Robustness: With Self-Placement, Republicans") addstat("MFX of 1 unit change in quad dist. measure",`r(mean)',"Mean of DV",`rmean',"SD of DV",`rdv') append

* With distance to closer
logit iscontributor quadloss dist_closer I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==1 [pweight=V103], robust 
* perform in sample mfx analysis of 1 unit change in distance measure, from -.5 below observed to +.5 above it
replace quadloss=quadloss-.5
predict lowvalue
replace quadloss=quadloss+1
predict highvalue
replace quadloss=quadloss-.5
gen quantofinterest=highvalue-lowvalue
summ quantofinterest if e(sample) [aweight=V103]
drop lowvalue highvalue quantofinterest
* End MFX
outreg using "tables/SITable07_RobustnessLogit.out", bracket 3aster bdec(4) adec(5) se ctitle("Robustness: With Distance to Closer, Democrats") addstat("MFX of 1 unit change in quad dist. measure",`r(mean)',"Mean of DV",`rmean',"SD of DV",`rdv') append

logit iscontributor quadloss dist_closer I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==0 [pweight=V103], robust 
* perform in sample mfx analysis of 1 unit change in distance measure, from -.5 below observed to +.5 above it
replace quadloss=quadloss-.5
predict lowvalue
replace quadloss=quadloss+1
predict highvalue
replace quadloss=quadloss-.5
gen quantofinterest=highvalue-lowvalue
summ quantofinterest if e(sample) [aweight=V103]
drop lowvalue highvalue quantofinterest
* End MFX
outreg using "tables/SITable07_RobustnessLogit.out", bracket 3aster bdec(4) adec(5) se ctitle("Robustness: With Distance to Closer, Republicans") addstat("MFX of 1 unit change in quad dist. measure",`r(mean)',"Mean of DV",`rmean',"SD of DV",`rdv') append

* With polarization
logit iscontributor quadloss dist_between I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==1  [pweight=V103], robust 
* perform in sample mfx analysis of 1 unit change in distance measure, from -.5 below observed to +.5 above it
replace quadloss=quadloss-.5
predict lowvalue
replace quadloss=quadloss+1
predict highvalue
replace quadloss=quadloss-.5
gen quantofinterest=highvalue-lowvalue
summ quantofinterest if e(sample) [aweight=V103]
drop lowvalue highvalue quantofinterest
* End MFX
outreg using "tables/SITable07_RobustnessLogit.out", bracket 3aster bdec(4) adec(5) se ctitle("Robustness: With Party Polarization, Democrats") addstat("MFX of 1 unit change in quad dist. measure",`r(mean)',"Mean of DV",`rmean',"SD of DV",`rdv') append

logit iscontributor quadloss dist_between I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==0  [pweight=V103], robust 
* perform in sample mfx analysis of 1 unit change in distance measure, from -.5 below observed to +.5 above it
replace quadloss=quadloss-.5
predict lowvalue
replace quadloss=quadloss+1
predict highvalue
replace quadloss=quadloss-.5
gen quantofinterest=highvalue-lowvalue
summ quantofinterest if e(sample) [aweight=V103]
drop lowvalue highvalue quantofinterest
* End MFX
outreg using "tables/SITable07_RobustnessLogit.out", bracket 3aster bdec(4) adec(5) se ctitle("Robustness: With Party Polarization, Republicans") addstat("MFX of 1 unit change in quad dist. measure",`r(mean)',"Mean of DV",`rmean',"SD of DV",`rdv') append

* Saturated Model
logit iscontributor quadloss abs_selfplace dist_closer dist_between I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==1 [pweight=V103], robust 
* perform in sample mfx analysis of 1 unit change in distance measure, from -.5 below observed to +.5 above it
replace quadloss=quadloss-.5
predict lowvalue
replace quadloss=quadloss+1
predict highvalue
replace quadloss=quadloss-.5
gen quantofinterest=highvalue-lowvalue
summ quantofinterest if e(sample) [aweight=V103]
drop lowvalue highvalue quantofinterest
* End MFX
outreg using "tables/SITable07_RobustnessLogit.out", bracket 3aster bdec(4) adec(5) se ctitle("Robustness: Saturated Model, Democrats") addstat("MFX of 1 unit change in quad dist. measure",`r(mean)',"Mean of DV",`rmean',"SD of DV",`rdv') append

logit iscontributor quadloss abs_selfplace dist_closer dist_between I_faminc* I_unionhh* male I_race* I_educ* I_decades* I_pew_religimp* if useme==1 & isdem==0 [pweight=V103], robust 
* perform in sample mfx analysis of 1 unit change in distance measure, from -.5 below observed to +.5 above it
replace quadloss=quadloss-.5
predict lowvalue
replace quadloss=quadloss+1
predict highvalue
replace quadloss=quadloss-.5
gen quantofinterest=highvalue-lowvalue
summ quantofinterest if e(sample) [aweight=V103]
drop lowvalue highvalue quantofinterest
* End MFX
outreg using "tables/SITable07_RobustnessLogit.out", bracket 3aster bdec(4) adec(5) se ctitle("Robustness: Saturated Model, Republicans") addstat("MFX of 1 unit change in quad dist. measure",`r(mean)',"Mean of DV",`rmean',"SD of DV",`rdv') append
drop useme

