* Steps from Dec 4, 2022 * 1. Get Member Ideology Data from https://voteview.com/articles/data_help_members (HSall_members.csv) * 2. Insert two columns on the left of the "HSall_members.csv" file * 3. Paste this into the A column (starting in row 2): =IF(D2="House",CONCATENATE("replace party=",I2," if icpsr==",E2),".") * 4. Paste this into the B column (starting in row 2): =IF(D2="House",CONCATENATE("replace ICPSRname=","""",L2,""""," if icpsr==",E2),".") * 5. Get House data (house_BridgeIdealPoints_1951_2020.csv) from https://michaelbailey.georgetown.domains/bridge-ideal-points-2020/ * 6. Import "house_BridgeIdealPoints_1951_2020.csv" into Stata using: import delimited G:\house_BridgeIdealPoints_1951_2020.csv * 7. Run these commands in Stata: gen party = . gen ICPSRname="." * 8. Copy the A column into a Stata do file. Copy the B column into a Stata do file. Then run the do file. * 9. Run these commands in Stata: gen south = 0 replace south = 1 if state_abbrev == "AL" /* Alabama */ replace south = 1 if state_abbrev == "AR" /* Arkansas */ replace south = 1 if state_abbrev == "FL" /* Florida */ replace south = 1 if state_abbrev == "GA" /* Georgia */ replace south = 1 if state_abbrev == "LA" /* Louisiana */ replace south = 1 if state_abbrev == "MS" /* Mississippi */ replace south = 1 if state_abbrev == "NC" /* North Carolina */ replace south = 1 if state_abbrev == "SC" /* South Carolina */ replace south = 1 if state_abbrev == "TN" /* Tennessee */ replace south = 1 if state_abbrev == "TX" /* Texas */ replace south = 1 if state_abbrev == "VA" /* Virginia */ egen gop = mean(ideal) if party==200, by(year) egen dem = mean(ideal) if party==100, by(year) egen demsouth = mean(ideal) if party==100 & south==1, by(year) egen demnonsouth = mean(ideal) if party==100 & south==0, by(year) gen group = "." replace group = "GOP" if party==200 replace group = "DemSouth" if party==100 & south==1 replace group = "DemNonSouth" if party==100 & south==0 drop if group == "." twoway (scatter gop year, mcolor(red)) (scatter demsouth year, mcolor(dknavy)) (scatter demnonsouth year, mcolor(ltblue)) * 10. Export to a CSV file export delimited using "G:\bailey polarization.csv" * 11. Open R and run these commands: DATA <- read.csv(file.choose(), header=TRUE) library(tidyverse) ggplot(data=DATA, aes(x=year, y=ideal, color=group)) + geom_hline(yintercept=0, col="white") + geom_point(stat="summary", fun="mean") + scale_color_manual(breaks=c("GOP","DemSouth","DemNonSouth"), labels=c("GOP","Dem South","Dem NonSouth"), values=c("red","blue4","blue1")) + scale_x_continuous(breaks=seq(1950,2020,10), labels=seq(1950,2020,10), expand=c(0,0), limits=c(1950,2020), sec.axis=dup_axis()) + scale_y_continuous(breaks=seq(-2,2,1), labels=seq(-2,2,1), expand=c(0,0), limits=c(-2.5,2.5), sec.axis=dup_axis()) + labs(title="Mean ideology by party in the U.S. House of Representatives", caption="Data source: Bailey Bridge Ideal Points (https://michaelbailey.georgetown.domains/bridge-ideal-points-2020/)") + theme( plot.background = element_rect(fill="white"), plot.margin = unit(c(0.5,0.5,0.5,0.5),"cm"), plot.title = element_text(face="bold", margin=margin(t=0, b=0), size=15, hjust=0.5), plot.subtitle = element_text(size=12, hjust=0.5, margin=margin(b=7)), plot.caption = element_text(size=10, hjust=0, margin=margin(t=7)), panel.background = element_rect(fill="gray90", color="black", size=0.5, linetype="solid"), panel.border = element_rect(fill=NA, color="black", linetype="solid", size=1.5), panel.grid.major.x = element_blank(), panel.grid.major.y = element_blank(), panel.grid.minor.x = element_blank(), panel.grid.minor.y = element_blank(), panel.spacing.x = unit(1, "lines"), panel.spacing.y = unit(1, "lines"), axis.text.x = element_text(size=12, color="black", margin=margin(t=7, b=7)), axis.text.x.top = element_text(size=12, color="black", margin=margin(t=7, b=7)), axis.text.y = element_text(size=12, color="black", margin=margin(l=7, r=7)), axis.text.y.right = element_text(size=12, color="black", margin=margin(l=7, r=7)), axis.ticks.y = element_blank(), axis.ticks.x = element_blank(), axis.title.y = element_blank(), axis.title.x = element_blank(), legend.position = "right", legend.text = element_text(size=12, color="black"), legend.title = element_blank()) ggsave(file="G:Bailey polarization 2022.svg", width=10, height=5) 11. Run this in R: DATA$party <- recode(DATA$group, "DemSouth"="Dem", "DemNonSouth"="Dem") 12. Run the above ggplot2 command, but change these lines: ggplot(data=DATA, aes(x=year, y=ideal, color=party)) + scale_color_manual(breaks=c("GOP","Dem"), labels=c("GOP","Dem"), values=c("red","blue3")) +