Logistic Regression in R on State Voting in National Elections and Income

This data set - a link is at the bottom - is slightly different, income by state and political group, red or blue. Generally, residents of blue states have higher incomes, although not when adjusted for cost of living:

Example Code

 # R - Logistic Regression  
 stateData <- read.table("CostByStateAndSalary.csv", header = TRUE, sep = ",")  
 am.data = glm(formula = Liberal ~ Y2014, data = stateData, family = binomial)  
 print(summary(am.data))     

Example Results

 Call:  
 glm(formula = Liberal ~ Y2014, family = binomial, data = stateData)  
   
 Deviance Residuals:   
   Min     1Q      Median  3Q      Max   
   -2.4347 -0.7297 -0.4880  0.6327  1.8722   
   
 Coefficients:  
             Estimate Std. Error     z value Pr(>|z|)    
 (Intercept) -9.325e+00    2.671e+00 -3.491  0.000481 ***  
 Y2014        1.752e-04    5.208e-05  3.365  0.000765 ***  
 ---  
 Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1  
   
 (Dispersion parameter for binomial family taken to be 1)  
   
   Null deviance: 66.266 on 48 degrees of freedom  
 Residual deviance: 48.442 on 47 degrees of freedom  
  (2 observations deleted due to missingness)  
 AIC: 52.442  
   
 Number of Fisher Scoring iterations: 4  

Sample Data

Popular posts from this blog

Decision Tree in R, with Graphs: Predicting State Politics from Big Five Traits

Chi-Square in R on by State Politics (Red/Blue) and Income (Higher/Lower)