Introduction

I hypothesize that there is a relationship between a subject’s religion and their choice of political party. By studying the influence of religion on a subject’s choice of political party, researchers can gain insights into the values, wants, and needs that particular groups have. Political parties can use this information to identify gaps in their advertising and to improve their outreach methods.

Data Prep

library(readr) 
library(dplyr) 
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
library(forcats)
library(scales)
## 
## Attaching package: 'scales'
## The following object is masked from 'package:readr':
## 
##     col_factor
voter<-read.csv("/Volumes/FLASHDRIVE/Data 333/Abbreviated Voter Dataset Labeled.csv")
head(voter)
##   gender  race            education      familyincome children  region
## 1 Female White               4-year Prefer not to say       No    West
## 2 Female White         Some College      $60K-$69,999       No    West
## 3   Male White High School Graduate      $50K-$59,999       No Midwest
## 4   Male White         Some College      $70K-$79,999       No   South
## 5   Male White               4-year      $40K-$49,999       No   South
## 6 Female White               2-year      $30K-$39,999       No    West
##    urbancity     Vote2012        Vote2016   TrumpSanders
## 1     Suburb Barack Obama Hillary Clinton Bernie Sanders
## 2 Rural Area  Mitt Romney    Donald Trump   Donald Trump
## 3       City  Mitt Romney Hillary Clinton Bernie Sanders
## 4       City Barack Obama    Gary Johnson Bernie Sanders
## 5     Suburb  Mitt Romney    Donald Trump   Donald Trump
## 6     Suburb Barack Obama Hillary Clinton Bernie Sanders
##              PartyRegistration PartyIdentification     PartyIdentification2
## 1                         <NA>            Democrat Not very strong Democrat
## 2                   Republican          Republican        Strong Republican
## 3                         <NA>          Republican        Strong Republican
## 4 Decline/No Party/Independent         Independent              Independent
## 5                         <NA>          Republican        Strong Republican
## 6                     Democrat            Democrat          Strong Democrat
##   PartyIdentification3 NewsPublicAffairs      DemPrimary   RepPrimary
## 1             Moderate  Most of the time Hillary Clinton         <NA>
## 2         Conservative  Most of the time            <NA> Donald Trump
## 3             Moderate  Most of the time Hillary Clinton         <NA>
## 4             Moderate  Most of the time    Someone Else         <NA>
## 5         Conservative  Most of the time            <NA>  Marco Rubio
## 6         Very Liberal  Most of the time Hillary Clinton         <NA>
##   ImmigrantContributions ImmigrantNaturalization ImmigrationShouldBe
## 1      Mostly Contribute                   Favor     Slightly Easier
## 2         Mostly a Drain                Not Sure           No change
## 3      Mostly Contribute                   Favor         Much Easier
## 4      Mostly Contribute                   Favor         Much Easier
## 5         Mostly a Drain                Not Sure     Slightly Easier
## 6      Mostly Contribute                   Favor     Slightly Harder
##                                    Abortion GayMarriage DeathPenalty
## 1                        Legal in all cases       Favor       Oppose
## 2 Legal in some cases and Illegal in others      Oppose        Favor
## 3                        Legal in all cases       Favor        Favor
## 4 Legal in some cases and Illegal in others       Favor        Favor
## 5                      Illegal in all cases      Oppose        Favor
## 6                        Legal in all cases       Favor     Not Sure
##   DeathPenaltyFreq TaxWealthy Healthcare            GlobWarmExist
## 1        Too Often      Favor        Yes  Definitely is happening
## 2 Not Often Enough     Oppose         No Definitely not happening
## 3 Not Often Enough      Favor        Yes  Definitely is happening
## 4      About Right      Favor        Yes  Definitely is happening
## 5 Not Often Enough     Oppose         No Definitely not happening
## 6         Not Sure      Favor        Yes  Definitely is happening
##   GlobWarmingSerious AffirmativeAction              Religion
## 1       Very Serious             Favor        Roman Catholic
## 2               <NA>            Oppose                Mormon
## 3       Very Serious             Favor              Agnostic
## 4   Somewhat Serious             Favor Nothing in Particular
## 5               <NA>            Oppose                Mormon
## 6       Very Serious             Favor              Agnostic
##    ReligiousImportance      ChurchAttendance     PrayerFrequency NumChildren
## 1   Somewhat Important                Seldom          Once a day           0
## 2       Very Important More than once a week Several times a day           0
## 3 Not at all Important                Seldom               Never           0
## 4 Not at all Important                Seldom A few times a month           0
## 5       Very Important           Once a week  A few times a week           0
## 6 Not at all Important                 Never               Never           0
##     areatype        GunOwnership EconomyBetterWorse Immigr_Economy_GiveTake
## 1     Suburb No Gun in Household     Getting Better                       7
## 2 Rural Area    Gun in Household     About the Same                      10
## 3       City    Gun in Household     Getting Better                       8
## 4       City No Gun in Household     Getting Better                      NA
## 5     Suburb No Gun in Household      Getting Worse                       7
## 6     Suburb    Gun in Household     About the Same                      10
##   ft_fem_2017 ft_immig_2017 ft_police_2017 ft_dem_2017 ft_rep_2017
## 1          99            95             76          88          21
## 2          65            96             95          86          96
## 3          74            77             78          91          20
## 4          NA            NA             NA          NA          NA
## 5          25            91             94          22          83
## 6         100           100             28          99          NA
##   ft_evang_2017 ft_muslim_2017 ft_jew_2017 ft_christ_2017 ft_gays_2017
## 1            50             50          50             50           50
## 2            96             61         100             98           82
## 3             2             49          25             50           77
## 4            NA             NA          NA             NA           NA
## 5            70             80          91             94           71
## 6            NA            100         100             28          100
##   ft_unions_2017 ft_altright_2017 ft_black_2017 ft_white_2017 ft_hisp_2017
## 1             80                1            51            50           79
## 2             62               50            98            90           95
## 3            100                0            87            90           91
## 4             NA               NA            NA            NA           NA
## 5             20               50            90            85           90
## 6            100               NA           100            50          100

Response Summary

Dependent Variable Distribution

table(voter$PartyRegistration)%>%
  prop.table()
## 
##                Another Party Decline/No Party/Independent 
##                   0.03646434                   0.18924533 
##                     Democrat                   Republican 
##                   0.41818601                   0.35610432

Independent Variable Distribution

table(voter$Religion)%>%
  prop.table()
## 
##                  Agnostic                   Atheist                  Buddhist 
##               0.059074912               0.047385621               0.008924082 
## Eastern or Greek Orthodox                     Hindu                    Jewish 
##               0.003519356               0.001131222               0.033810960 
##                    Mormon                    Muslim     Nothing in Particular 
##               0.017722474               0.003016591               0.151206637 
##                Protestant            Roman Catholic            Something Else 
##               0.395047763               0.219457014               0.059703369

Preliminary Summary

Expected

chisq.test(voter$Religion,voter$PartyIdentification)[7]
## Warning in chisq.test(voter$Religion, voter$PartyIdentification): Chi-squared
## approximation may be incorrect
## $expected
##                            voter$PartyIdentification
## voter$Religion                 Democrat Independent   Not Sure      Other
##   Agnostic                   176.102313  145.442433  6.1437908  6.3800905
##   Atheist                    141.256536  116.663399  4.9281046  5.1176471
##   Buddhist                    26.602690   21.971091  0.9281046  0.9638009
##   Eastern or Greek Orthodox   10.491202    8.664656  0.3660131  0.3800905
##   Hindu                        3.372172    2.785068  0.1176471  0.1221719
##   Jewish                     100.790473   83.242584  3.5163399  3.6515837
##   Mormon                      52.830694   43.632730  1.8431373  1.9140271
##   Muslim                       8.992459    7.426848  0.3137255  0.3257919
##   Nothing in Particular      450.746983  372.270739 15.7254902 16.3303167
##   Protestant                1177.637381  972.607592 41.0849673 42.6651584
##   Roman Catholic             654.201357  540.303167 22.8235294 23.7013575
##   Something Else             177.975742  146.989693  6.2091503  6.4479638
##                            voter$PartyIdentification
## voter$Religion              Republican
##   Agnostic                  135.931373
##   Atheist                   109.034314
##   Buddhist                   20.534314
##   Eastern or Greek Orthodox   8.098039
##   Hindu                       2.602941
##   Jewish                     77.799020
##   Mormon                     40.779412
##   Muslim                      6.941176
##   Nothing in Particular     347.926471
##   Protestant                909.004902
##   Roman Catholic            504.970588
##   Something Else            137.377451

Observed

chisq.test(voter$Religion,voter$PartyIdentification)[6]
## Warning in chisq.test(voter$Religion, voter$PartyIdentification): Chi-squared
## approximation may be incorrect
## $observed
##                            voter$PartyIdentification
## voter$Religion              Democrat Independent Not Sure Other Republican
##   Agnostic                       208         194        8     9         51
##   Atheist                        212         128        1     8         28
##   Buddhist                        35          25        1     4          6
##   Eastern or Greek Orthodox        8           6        0     0         14
##   Hindu                            8           0        0     0          1
##   Jewish                         145          64        2     3         55
##   Mormon                          27          48        4     3         59
##   Muslim                          13           9        1     0          1
##   Nothing in Particular          493         441       23    15        231
##   Protestant                    1048         870       31    38       1156
##   Roman Catholic                 588         511       25    16        606
##   Something Else                 196         166        8    12         93

Row Percent

table(voter$Religion,voter$PartyIdentification)%>%
  prop.table(1)%>%
round(3)
##                            
##                             Democrat Independent Not Sure Other Republican
##   Agnostic                     0.443       0.413    0.017 0.019      0.109
##   Atheist                      0.562       0.340    0.003 0.021      0.074
##   Buddhist                     0.493       0.352    0.014 0.056      0.085
##   Eastern or Greek Orthodox    0.286       0.214    0.000 0.000      0.500
##   Hindu                        0.889       0.000    0.000 0.000      0.111
##   Jewish                       0.539       0.238    0.007 0.011      0.204
##   Mormon                       0.191       0.340    0.028 0.021      0.418
##   Muslim                       0.542       0.375    0.042 0.000      0.042
##   Nothing in Particular        0.410       0.367    0.019 0.012      0.192
##   Protestant                   0.333       0.277    0.010 0.012      0.368
##   Roman Catholic               0.337       0.293    0.014 0.009      0.347
##   Something Else               0.413       0.349    0.017 0.025      0.196

Row Percent Interpretation

Extra Credit

ggplot(voter,aes(x=Religion,fill=PartyIdentification)) +
  geom_bar(position="fill")+
  theme_classic()+
  theme(plot.title = element_text(hjust = 0.5),plot.subtitle =element_text(hjust = 0.5) ) +
  theme(axis.text.x=element_text(angle=90, hjust=1))+
  labs(x="Religion", y="Percent", title="Religion & Political Party", subtitle="Anika Lewis") 

Chi-Square Statistical Test

chisq.test(voter$Religion,voter$PartyIdentification)
## Warning in chisq.test(voter$Religion, voter$PartyIdentification): Chi-squared
## approximation may be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  voter$Religion and voter$PartyIdentification
## X-squared = 492.36, df = 44, p-value < 2.2e-16

Chi-Square Interpretation