Our data shows different demographic variable for counties including which party they voted for. Our task is to determine the impact of income on red voting states.Here is the summary of our model in which we will need the coefficients
election <- read.csv("https://www.macalester.edu/~ajohns24/data/IMAdata1.csv")
election$Red <- as.numeric(election$StateColor == "red")
redmod<-glm(Red ~ IncomeBracket, family = binomial, data = election)
summary(redmod)
##
## Call:
## glm(formula = Red ~ IncomeBracket, family = binomial, data = election)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.2294 -1.2294 -0.9821 1.1263 1.3861
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -0.47838 0.06356 -7.527 5.19e-14 ***
## IncomeBracketlow 0.59977 0.07717 7.772 7.74e-15 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 4352.6 on 3142 degrees of freedom
## Residual deviance: 4291.1 on 3141 degrees of freedom
## AIC: 4295.1
##
## Number of Fisher Scoring iterations: 4
Below is the probability of a high income area voting red.
A<-exp(coef(redmod)[1])
probhigh<-A/(A+1)
probhigh
## (Intercept)
## 0.3826336
Below is the probability of a low income area voting red.
B<-exp((coef(redmod)[1]+coef(redmod)[2]))
problow<- B/(B+1)
problow
## (Intercept)
## 0.5303103
The odds of a high income state being red are times the odds of a low income state being red.
probhigh/problow
## (Intercept)
## 0.7215278