# # Barry Edwards # Replication file for Formulating Voting Rights Act Remedies to Address Current Conditions # Code to Plot Parity Conditions Over Time # Figure 3 in paper is generated from two different scripts, this is the bottom half # Note: the values hard coded in this file are generate by script "repeatCrossSections.r" ########### uncomment to write graphics files to disk rather than display in R # setwd('H:/voting rights/hi res figures/') # png(file="breakEvenFigure4.png", width=7, height=2.9, units="in", pointsize=10, res=800) spacing <- .06 par(mfrow=c(1,2)) par(mar=c(3.1,3.1,1.1,1.1), mgp=c(2,.6,.5), family = "serif") ###################################### AF AM CALCULATIONS afamYearMeanConstant <- NULL afamYearMeanConstant[93:112] <- c( -10.194956, -7.777487, -6.750306, -8.076880, -5.900563, -6.150806, -8.069870, -9.327854, -9.070937, -5.031474, -6.955865, -6.015291, -5.035172, -9.515061, -7.637877, -10.577615, -6.779610, -6.367782, -7.487653, -5.354892) afamLogitCoefficient <- NULL afamLogitCoefficient[93:112] <- c( 25.08298, 22.17199, 21.34021, 21.16102, 15.93245, 14.61030, 18.49812, 21.60522, 21.24446, 21.01039, 19.87854, 17.14508, 12.86218, 17.83682, 17.42525, 23.82407, 22.43500, 15.30356, 14.62277, 16.52179) ################# what is break even percent? minYear <- 93 maxYear <- 112 magicNumber <- NULL findParity <- NULL bvapParity <- NULL # 0 = afamLogitCoefficient *magicNumber + afamYearMeanConstant magicNumber <- -1*afamYearMeanConstant/afamLogitCoefficient counter <- 93 while (counter <= 112) { bvapRange <- seq(0,1,by=.001) XB <- afamLogitCoefficient[counter]*bvapRange + afamYearMeanConstant[counter] probability <- exp(XB) / (1 + exp(XB)) findParity <- abs(probability[50:950] - bvapRange[50:950]) bvapParity[counter] <- bvapRange[findParity==min(findParity)] + .05 counter <- counter + 1 } year <- seq(1,maxYear,by=1) plot(x="",y="",xlim=c(minYear,maxYear),xlab="",ylab="African American VAP (%)",ylim=c(0,80), main="",axes=F,cex.lab=1.0,cex.main=1.0 ) points(x=year,y=magicNumber*100,pch=1) lines(x=year,y=magicNumber*100,lty=2) points(x=year,y=bvapParity*100,pch=16) lines(x=year,y=bvapParity*100,lty=1) # segments(year,seLower,year,seUpper,lty=2) # abline(h=0,lty=3) axis(2,las=2, line=0) axis(1, at=seq(minYear,maxYear,by=1), labels=seq(1972,2010,by=2),las=2, line=0) # abline(h=50,lty=2) box() # rect(87.5-spacing,-20,87.5+spacing,200,col="white",border=T) # rect(92.5-spacing,-20,92.5+spacing,200,col="white",border=T) rect(97.5-spacing,-20,97.5+spacing,200,col="white",border=T) rect(102.5-spacing,-20,102.5+spacing,200,col="white",border=T) rect(107.5-spacing,-20,107.5+spacing,200,col="white",border=T) legend(x=107.5, y=10, lwd=c(1,1), col=c("black","black"), lty=c(1,2), pch=c(16,1),bty="n", legend=c('Parity','50% Chance'), cex=.6) ####################################################### spacing <- .05 latinoYearMeanConstant <- NULL # terms 96 - 112 latinoYearMeanConstant[96:112] <- c( -7.434496, -7.349732, -8.222173, -7.912738, -7.003834, -6.207025, -10.274888, -6.578609, -6.975946, -14.919298, -15.812785, -6.835041, -17.657861, -7.642998, -8.669346, -9.344330, -4.716175) latinoLogitCoefficient <- NULL latinoLogitCoefficient[96:112] <- c( 25.458929, 20.222160, 19.269952, 19.882974, 19.111654, 19.772100, 24.534381, 15.642359, 17.020315, 24.671199, 27.565424, 12.018718, 30.736033, 17.889646, 19.982545, 16.258586, 8.975505) ################# what is break even percent? minYear <- 96 maxYear <- 112 latinoMagicNumber <- NULL latinoMagicNumber <- -1*latinoYearMeanConstant/latinoLogitCoefficient findParity <- NULL hvapParity <- NULL counter <- 96 while (counter <= 112) { hvapRange <- seq(0,1,by=.001) XB <- latinoLogitCoefficient[counter]*hvapRange + latinoYearMeanConstant[counter] probability <- exp(XB) / (1 + exp(XB)) findParity <- abs(probability[50:950] - hvapRange[50:950]) hvapParity[counter] <- hvapRange[findParity==min(findParity)] + .05 counter <- counter + 1 } year <- seq(1,maxYear,by=1) plot(x="",y="",xlim=c(minYear,maxYear),xlab="",ylab="Latino VAP (%)",ylim=c(0,80),main="",axes=F,cex.lab=1.0,cex.main=1.0 ) points(x=year,y=latinoMagicNumber*100,pch=1) lines(x=year,y=latinoMagicNumber*100,lty=2) points(x=year,y=hvapParity*100,pch=16) lines(x=year,y=hvapParity*100) # segments(year,seLower,year,seUpper,lty=2) # abline(h=0,lty=3) axis(2,las=2, line=0) axis(1, at=seq(minYear,maxYear,by=1), labels=seq(1978,2010,by=2),las=2, line=0) # abline(h=50,lty=2) # indicate redistricting points box() # rect(92.5-spacing,-20,92.5+spacing,200,col="white",border=T) rect(97.5-spacing,-20,97.5+spacing,200,col="white",border=T) rect(102.5-spacing,-20,102.5+spacing,200,col="white",border=T) rect(107.5-spacing,-20,107.5+spacing,200,col="white",border=T) legend(x=108, y=10, lwd=c(1,1), col=c("black","black"), lty=c(1,2), pch=c(16,1),bty="n", legend=c('Parity','50% Chance'), cex=.6) ########### uncomment to write graphics files to disk rather than display in R # dev.off()