Research Question: How do Democrats and Republicans differ their perspectives on the important economic issues of the country such as poverty, taxes, the budget deficit and social security?

Introduction

I will compare Democrats and Republicans on the important economic issues using the voter data. This report will consist of the comparison between Democrats and Republicans on their views about poverty, taxes, the budget deficit and social security. In addition, I will compare how Democrats and Republicans differ in their feelings towards poor people when I discuss how they view poverty and how Democrats and Republicans differ in their feelings towards rich people when I discuss how their perspectives differ on taxes.

(Loading Necessary R Packages for the Report)

library(readr)
## Warning: package 'readr' was built under R version 3.6.3
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.6.3
## 
## 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)
## Warning: package 'ggplot2' was built under R version 3.6.3

(Importing the Data)

VoterData_Original<-read.csv("F:/Voter Data 2019.csv")

Data Preparation

VoterData_Original <- VoterData_Original%>%
  mutate(politicalparty = ifelse(pid3_2019==1,"Democrat",
                          ifelse(pid3_2019==2,"Republican",NA)))
VoterData_Original <- VoterData_Original%>%
  mutate(poverty = ifelse(imiss_q_2019==1,"Very Important",
                   ifelse(imiss_q_2019==2,"Somewhat Important",
                   ifelse(imiss_q_2019==3, "Not Very Important",
                   ifelse(imiss_q_2019==4, "Unimportant",NA)))))
VoterData_Original <- VoterData_Original%>%
  mutate(taxes =   ifelse(imiss_r_2019==1,"Very Important",
                   ifelse(imiss_r_2019==2,"Somewhat Important",
                   ifelse(imiss_r_2019==3, "Not Very Important",
                   ifelse(imiss_r_2019==4, "Unimportant",NA)))))
VoterData_Original <- VoterData_Original%>%
  mutate(budgetdeficit =   ifelse(imiss_p_2019==1,"Very Important",
                           ifelse(imiss_p_2019==2,"Somewhat Important",
                           ifelse(imiss_p_2019==3, "Not Very Important",
                           ifelse(imiss_p_2019==4, "Unimportant",NA)))))
VoterData_Original <- VoterData_Original%>%
  mutate(socialsecurity =  ifelse(imiss_m_2019==1,"Very Important",
                           ifelse(imiss_m_2019==2,"Somewhat Important",
                           ifelse(imiss_m_2019==3, "Not Very Important",
                           ifelse(imiss_m_2019==4, "Unimportant",NA)))))
VoterData_Original <- VoterData_Original%>%
  mutate(economictrend =   ifelse(econtrend_2019==1,"Getting Better",
                           ifelse(econtrend_2019==2,"About the Same",
                           ifelse(econtrend_2019==3, "Getting Worse",
                           ifelse(econtrend_2019==4, "Don't Know",NA)))))
VoterData_Original <-VoterData_Original%>%
  mutate(taxwealthy = ifelse(taxdoug_2019==1, "Yes",
                      ifelse(taxdoug_2019==2, "No",
                      ifelse(taxdoug_2019==3, "Don't Know",NA))))
VoterData_Original <- VoterData_Original%>%
  mutate(taxcredit = ifelse(policy6_2019==1, "Strongly Support",
                     ifelse(policy6_2019==2, "Somewhat Support",
                     ifelse(policy6_2019==3, "Neither Support nor Oppose",
                     ifelse(policy6_2019==4, "Somewhat Oppose",
                     ifelse(policy6_2019==5, "Strongly Oppose", NA))))))
VoterData_Original <- VoterData_Original%>%
  mutate(govtecon =  ifelse(diff_inc_2019==1, "Strongly Agree",
                     ifelse(diff_inc_2019==2, "Somewhat Agree",
                     ifelse(diff_inc_2019==3, "Neither Agree nor Disagree",
                     ifelse(diff_inc_2019==4, "Somewhat Disagree",
                     ifelse(diff_inc_2019==5, "Strongly Disagree", NA))))))
VoterData_Modified <- VoterData_Original%>%
  filter(politicalparty %in% c("Democrat", "Republican"))%>%
  select(politicalparty, poverty, taxes, budgetdeficit, socialsecurity, economictrend, taxwealthy, taxcredit, govtecon, rwm_2019, rww_2019, rbm_2019, rbw_2019, pwm_2019, pww_2019, pbm_2019, pbw_2019)
VoterData_Modified <- VoterData_Modified%>%
  mutate(economictrend = factor(economictrend, levels = c("Getting Better", "About the Same", "Getting Worse", "Don't Know")))
VoterData_Modified <- VoterData_Modified%>%
  mutate(poverty = factor(poverty, levels = c("Very Important", "Somewhat Important", "Not Very Important", "Unimportant")))
VoterData_Modified <- VoterData_Modified%>%
  mutate(govtecon = factor(govtecon, levels = c("Strongly Agree", "Somewhat Agree", "Neither Agree nor Disagree", "Somewhat Disagree", "Strongly Disagree" )))
VoterData_Modified <- VoterData_Modified%>%
  mutate(socialsecurity = factor(socialsecurity, levels = c("Very Important", "Somewhat Important", "Not Very Important", "Unimportant")))
VoterData_Modified <- VoterData_Modified%>%
  mutate(budgetdeficit = factor(budgetdeficit, levels = c("Very Important", "Somewhat Important", "Not Very Important", "Unimportant")))
VoterData_Modified <- VoterData_Modified%>%
  mutate(taxes = factor(taxes, levels = c("Very Important", "Somewhat Important", "Not Very Important", "Unimportant")))
VoterData_Modified <- VoterData_Modified%>%
  mutate(taxwealthy = factor(taxwealthy, levels = c("Yes", "No", "Don't Know")))
VoterData_Modified <- VoterData_Modified%>%
  mutate(taxcredit = factor(taxcredit, levels = c("Strongly Support", "Somewhat Support", "Neither Support nor Oppose", "Somewhat Oppose", "Strongly Oppose")))

Results

How Do Democrats and Republicans Differ in Their Views on the Economy in General? (Crosstab)

prop.table(table(VoterData_Modified$politicalparty, VoterData_Modified$economictrend),1)%>%
  round(2)
##             
##              Getting Better About the Same Getting Worse Don't Know
##   Democrat             0.11           0.49          0.34       0.06
##   Republican           0.69           0.25          0.04       0.02

Based on the crosstab, there is a difference in the ways in which Democrats and Republicans view the country’s economy. Most Democrats think the economy is about the same whereas the majority of Republicans think the economy is getting better. Also, Democrats are more pessimistic about the economy since there are 34% of Democrats who believe that the economy is getting worse compared to the 4% of Republicans who think the same way.

How Do Democrats and Republicans Differ in Their Views on the Economy? (Visualization)

VoterData_Modified%>%
  group_by(politicalparty, economictrend)%>%
  summarize(n=n())%>%
  mutate(percent=n/sum(n))%>%
  ggplot()+
  geom_col(aes(x=politicalparty, y=percent, fill=economictrend))
## Warning: Factor `economictrend` contains implicit NA, consider using
## `forcats::fct_explicit_na`

The stacked bar charts above clearly depict the difference between Democrats’ and Republicans’ perspectives on the economy of the country. More than half of Republicans believe that the economy is getting better. On the other hand, the Democrats think it is about the same or getting worse than before.

Chi-square test for statistical relationship between people’s political parties and their opinions about the economy

chisq.test(VoterData_Modified$politicalparty, VoterData_Modified$economictrend)
## 
##  Pearson's Chi-squared test
## 
## data:  VoterData_Modified$politicalparty and VoterData_Modified$economictrend
## X-squared = 1646.2, df = 3, p-value < 2.2e-16

Based on the results of the chi-square test generated above, p-value is 0.00000000000000022, which is less than 0.05. This implies that there is a statistically significant relationship between the political party in which a person belongs and his/her opinion about the economy of the country.

How Do Democrats and Republicans Differ in Their Perspectives on Poverty? (Crosstab)

prop.table(table(VoterData_Modified$politicalparty, VoterData_Modified$poverty),1)%>%
round(2)
##             
##              Very Important Somewhat Important Not Very Important Unimportant
##   Democrat             0.67               0.30               0.03        0.00
##   Republican           0.30               0.49               0.17        0.04

Based on the crosstab generated above, majority of Democrats think poverty is a very important issue in the United States. However, most Republicans think that poverty is somewhat important.

How Do Democrats and Republicans Differ in Their Perspectives on Poverty? (Visualization)

VoterData_Modified%>%
  group_by(politicalparty, poverty)%>%
  summarize(n=n())%>%
  mutate(percent=n/sum(n))%>%
  ggplot()+
  geom_col(aes(x=politicalparty, y=percent, fill=poverty))
## Warning: Factor `poverty` contains implicit NA, consider using
## `forcats::fct_explicit_na`

As shown by the bar charts, Democrats are more likely to think poverty is a very important issue than Republicans. In addition, there is almost no Democrat who think poverty is an unimportant issue.

Chi-square test for statistical relationship between people’s political parties and their opinions about poverty

chisq.test(VoterData_Modified$politicalparty, VoterData_Modified$poverty)
## 
##  Pearson's Chi-squared test
## 
## data:  VoterData_Modified$politicalparty and VoterData_Modified$poverty
## X-squared = 698.88, df = 3, p-value < 2.2e-16

Based on the chi-square test, the p-value is less than 0.05. This implies that there is a statistically significant relationship between the political party in which a person belongs and his/her opinion about poverty.

How Do Democrats and Republicans Differ in Their Feelings Towards Poor People?

How Do Democrats and Republicans Differ in Their Feelings Towards Poor White People? (Comparing the Average Feelings)

VoterData_Modified%>%
  group_by(politicalparty)%>%
  filter(pwm_2019<=100, pww_2019<=100)%>%
  summarize(avgft_pwm=mean(pwm_2019, na.rm= TRUE), avgft_pww = mean(pww_2019, na.rm = TRUE))
## # A tibble: 2 x 3
##   politicalparty avgft_pwm avgft_pww
##   <chr>              <dbl>     <dbl>
## 1 Democrat            53.5      63.5
## 2 Republican          68.7      67.3

In this table, avgft_pwm means “the average feeling towards poor white men” and avgft_pww means “the average feeling towards poor white women”. Based on the averages computed, there is a significant difference between Democrats and Republicans in their feelings towards poor white men. In general, Republicans gave higher values for their feelings for poor white men than Democrats. Similarly, they gave higher values for their feelings for poor white women.

How Do Democrats and Republicans Differ in Their Feelings Towards Poor White Men? (Visualization)

VoterData_Modified%>%
  filter(pwm_2019<=100)%>%
  ggplot()+geom_histogram(aes(x=pwm_2019))+
  facet_wrap(~politicalparty)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

The histograms show why the average for Democrats is lower. Most democrats gave values less than 50 for their feelings for poor white men. On the other hand, most Republicans gave values over 50 for their feelings towards poor white men.

How Do Democrats and Republicans Differ in Their Feelings Towards Poor White Women? (Visualization)

VoterData_Modified%>%
  filter(pww_2019<=100)%>%
  ggplot()+geom_histogram(aes(x=pww_2019))+
  facet_wrap(~politicalparty)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

The histograms above show why there was no significant difference between the average feelings towards poor white women. The Democrats’ average was slightly lower because more Democrats gave values of 50 or less compared to Republicans.

T-Test for Testing Statistical Difference between Political Party and the Average Feelings Towards Poor White Men and Poor White Women

VoterData_filtered1<-VoterData_Modified%>%
  filter(pwm_2019<=100, pww_2019<=100)
t.test(pwm_2019~politicalparty, data = VoterData_filtered1)
## 
##  Welch Two Sample t-test
## 
## data:  pwm_2019 by politicalparty
## t = -3.781, df = 147.6, p-value = 0.0002262
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -23.100473  -7.241879
## sample estimates:
##   mean in group Democrat mean in group Republican 
##                 53.50575                 68.67692
t.test(pww_2019~politicalparty, data = VoterData_filtered1)
## 
##  Welch Two Sample t-test
## 
## data:  pww_2019 by politicalparty
## t = -0.95512, df = 144.37, p-value = 0.3411
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -11.457457   3.991852
## sample estimates:
##   mean in group Democrat mean in group Republican 
##                 63.52874                 67.26154

Based on the results from the T-test above, there is a statistically significant difference between political parties in which people in their feelings towards poor white men since the p-value is less than 0.05 (0.0002262 < 0.05). However, there is no statistically significant difference between political parties in which they belong and their average feelings towards poor white women since the p-value is more than 0.05 (0.3411 > 0.05)

Generating Sampling Distributions

In this section, sampling distributions were created for the variables “pwm_2019” and “pww_2019” to confirm the results of the Central Limit Theorem.
VoterData_filtered1a <- VoterData_filtered1%>%
  filter(politicalparty == "Democrat")
VoterData_filtered1b <- VoterData_filtered1%>%
  filter(politicalparty == "Republican")

Sampling distribution for “pwm_2019” for Democrats

  replicate(10000, sample(VoterData_filtered1a$pwm_2019, 40)%>%
                 mean(na.rm=TRUE))%>%
  data.frame()%>%
  rename("mean"=1)%>%
  ggplot()+geom_histogram(aes(x=mean), fill="blue")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Sampling distribution for “pwm_2019” for Republicans

  replicate(10000, sample(VoterData_filtered1b$pwm_2019, 40)%>%
                 mean(na.rm=TRUE))%>%
  data.frame()%>%
  rename("mean"=1)%>%
  ggplot()+geom_histogram(aes(x=mean), fill="red")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Sampling distribution for “pww_2019” for Democrats

  replicate(10000, sample(VoterData_filtered1a$pww_2019, 40)%>%
                 mean(na.rm=TRUE))%>%
  data.frame()%>%
  rename("mean"=1)%>%
  ggplot()+geom_histogram(aes(x=mean), fill="blue")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Sampling distribution for “pww_2019” for Republicans

  replicate(10000, sample(VoterData_filtered1b$pww_2019, 40)%>%
                 mean(na.rm=TRUE))%>%
  data.frame()%>%
  rename("mean"=1)%>%
  ggplot()+geom_histogram(aes(x=mean), fill="red")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Based on the shape of the histograms above, the sampling distributions are normal and this confirms the result of Central Limit Theorem.

How Do Democrats and Republicans Differ in Their Feelings Towards Poor Black People? (Comparing the Average Feelings)

VoterData_Modified%>%
  group_by(politicalparty)%>%
  filter(pbm_2019<=100, pbw_2019<=100)%>%
  summarize(avgft_pbm=mean(pbm_2019, na.rm= TRUE), avgft_pbw = mean(pbw_2019, na.rm = TRUE))
## # A tibble: 2 x 3
##   politicalparty avgft_pbm avgft_pbw
##   <chr>              <dbl>     <dbl>
## 1 Democrat            66.0      72.4
## 2 Republican          52.3      53.6

In this table, avgft_pbm means “the average feeling towards poor black men” and avgft_pbw means “the average feeling towards poor black women”. Based on the averages computed, there is significant difference between Democrats and Republicans in their feelings towards poor black men. In general, Democrats gave higher values for their feelings for poor black men than Democrats. Similarly, they gave higher values for their feelings for poor black women and the difference is larger for the average feelings for them.

How Do Democrats and Republicans Differ in Their Feelings Towards Poor Black Men? (Visualization)

VoterData_Modified%>%
  filter(pbm_2019<=100)%>%
  ggplot()+geom_histogram(aes(x=pbm_2019))+
  facet_wrap(~politicalparty)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

The histograms above show why there was a significant difference between the average feelings towards poor black men. The Democrats’ average was higher because more Democrats gave values of 50 or higher and more Republicans gave values 50 or less.

How Do Democrats and Republicans Differ in Their Feelings Towards Poor Black Women? (Visualization)

VoterData_Modified%>%
  filter(pbw_2019<=100)%>%
  ggplot()+geom_histogram(aes(x=pbw_2019))+
  facet_wrap(~politicalparty)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

The histograms above show why there was a significant difference between the average feelings towards poor black women. The Democrats’ average was higher because more Democrats gave values of 50 or more compared to Republicans. Republicans’ average was lower since more Republicans gave values of 50 or lower for their feelings towards poor black women.

T-Test for Testing Statistical Difference between Political Party and the Average Feelings Towards Poor Black Men and Poor Black Women

VoterData_filtered2<-VoterData_Modified%>%
  filter(pbm_2019<=100, pbw_2019<=100)
t.test(pbm_2019~politicalparty, data = VoterData_filtered2)
## 
##  Welch Two Sample t-test
## 
## data:  pbm_2019 by politicalparty
## t = 3.0665, df = 119.07, p-value = 0.00268
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##   4.876269 22.650452
## sample estimates:
##   mean in group Democrat mean in group Republican 
##                 66.02899                 52.26562
t.test(pbw_2019~politicalparty, data = VoterData_filtered2)
## 
##  Welch Two Sample t-test
## 
## data:  pbw_2019 by politicalparty
## t = 4.3085, df = 116.92, p-value = 3.443e-05
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  10.18102 27.50331
## sample estimates:
##   mean in group Democrat mean in group Republican 
##                 72.42029                 53.57812

Based on the results from the T-test above, there is a statistically significant difference between political parties in which people in their feelings towards poor white men since the p-value is less than 0.05 (0.00268 < 0.05). Similary, there is a statistically significant difference between political parties in which they belong and their average feelings towards poor white women since the p-value is less than 0.05 (0.00003443 < 0.05)

Generating Sampling Distributions

In this section, sampling distributions were created for the variables “pbm_2019” and “pbw_2019” to confirm the results of the Central Limit Theorem.
VoterData_filtered2a <- VoterData_filtered2%>%
  filter(politicalparty == "Democrat")
VoterData_filtered2b <- VoterData_filtered2%>%
  filter(politicalparty == "Republican")

Sampling distribution for “pbm_2019” for Democrats

  replicate(10000, sample(VoterData_filtered2a$pbm_2019, 40)%>%
                 mean(na.rm=TRUE))%>%
  data.frame()%>%
  rename("mean"=1)%>%
  ggplot()+geom_histogram(aes(x=mean), fill="blue")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Sampling distribution for “pbm_2019” for Republicans

  replicate(10000, sample(VoterData_filtered2b$pbm_2019, 40)%>%
                 mean(na.rm=TRUE))%>%
  data.frame()%>%
  rename("mean"=1)%>%
  ggplot()+geom_histogram(aes(x=mean), fill="red")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Sampling distribution for “pbw_2019” for Democrats

  replicate(10000, sample(VoterData_filtered2a$pbw_2019, 40)%>%
                 mean(na.rm=TRUE))%>%
  data.frame()%>%
  rename("mean"=1)%>%
  ggplot()+geom_histogram(aes(x=mean), fill="blue")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Sampling distribution for “pbw_2019” for Republicans

  replicate(10000, sample(VoterData_filtered2b$pbw_2019, 40)%>%
                 mean(na.rm=TRUE))%>%
  data.frame()%>%
  rename("mean"=1)%>%
  ggplot()+geom_histogram(aes(x=mean), fill="red")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Based on the shape of the histograms above, the sampling distributions are normal and this confirms the result of Central Limit Theorem.

How Do Democrats and Republicans Differ in Their Opinions about Government’s Responsibility to Reduce Difference in Incomes between People with Low Incomes and People with High Incomes? (Crosstab)

prop.table(table(VoterData_Modified$politicalparty, VoterData_Modified$govtecon),1)%>%
  round(2)
##             
##              Strongly Agree Somewhat Agree Neither Agree nor Disagree
##   Democrat             0.26           0.32                       0.26
##   Republican           0.03           0.06                       0.12
##             
##              Somewhat Disagree Strongly Disagree
##   Democrat                0.09              0.06
##   Republican              0.11              0.67

Based on the crosstab, the majority of Republicans believe that it is not the responsibility of the government to reduce the differences in income between people with high incomes and those with low incomes. However, most Democrats believe that it is the responsibility of the government to reduce the differences in income between people with high incomes and those with low incomes.

How Do Democrats and Republicans Differ in Their Opinions about Government’s Responsibility to Reduce Difference in Incomes between People with Low Incomes and People with High Incomes? (Visualization)

VoterData_Modified%>%
  group_by(politicalparty, govtecon)%>%
  summarize(n=n())%>%
  mutate(percent=n/sum(n))%>%
  ggplot()+
  geom_col(aes(x=politicalparty, y=percent, fill=govtecon))
## Warning: Factor `govtecon` contains implicit NA, consider using
## `forcats::fct_explicit_na`

The stacked bar chart demonstrates the difference between Democrats’ and Republicans’ views on the government’s role in reducing the difference in Incomes between People with Low Incomes and People with High Incomes. More than half of the Republicans believe that it is not the responsibility of the government to reduce the differences in income between people with high incomes and those with low incomes. However, most Democrats think otherwise.

Chi-square test for statistical relationship between people’s political parties and their opinions about the government’s role in reducing the income difference

chisq.test(VoterData_Modified$politicalparty, VoterData_Modified$govtecon)
## 
##  Pearson's Chi-squared test
## 
## data:  VoterData_Modified$politicalparty and VoterData_Modified$govtecon
## X-squared = 2026.6, df = 4, p-value < 2.2e-16

Based on the chi-square test, the p-value is less than 0.05. This implies that there is a statistically significant relationship between the political party in which a person belongs and his/her opinion about the government’s role in reducing the income difference.

How Do Democrats and Republicans Differ in Their Perspectives on Social Security? (Crosstab)

prop.table(table(VoterData_Modified$politicalparty, VoterData_Modified$socialsecurity),1)%>%
  round(2)
##             
##              Very Important Somewhat Important Not Very Important Unimportant
##   Democrat             0.81               0.16               0.03        0.01
##   Republican           0.65               0.29               0.05        0.00

Based on the crosstab, social security is a very important issue for both Democrats and Republicans Looking at the percentages of the respondents for those who think social security is a very important issue, Democrats consider this issue more important than Republicans.

How Do Democrats and Republicans Differ in Their Perspectives on Social Security? (Visualization)

VoterData_Modified%>%
  group_by(politicalparty, socialsecurity)%>%
  summarize(n=n())%>%
  mutate(percent=n/sum(n))%>%
  ggplot()+
  geom_col(aes(x=politicalparty, y=percent, fill=socialsecurity))
## Warning: Factor `socialsecurity` contains implicit NA, consider using
## `forcats::fct_explicit_na`

As shown in the stacked bar chart, social security is a very important issue for both Democrats and Republicans.

Chi-square test for statistical relationship between people’s political parties and their opinions about social security

chisq.test(VoterData_Modified$politicalparty, VoterData_Modified$socialsecurity)
## 
##  Pearson's Chi-squared test
## 
## data:  VoterData_Modified$politicalparty and VoterData_Modified$socialsecurity
## X-squared = 135.61, df = 3, p-value < 2.2e-16

Based on the chi-square test, the p-value is less than 0.05. This implies that there is a statistically significant relationship between the political party in which a person belongs and his/her opinion about social security.

How Do Democrats and Republicans Differ in Their Perspectives on Budget Deficit? (Crosstab)

prop.table(table(VoterData_Modified$politicalparty, VoterData_Modified$budgetdeficit),1)%>%
  round(2)
##             
##              Very Important Somewhat Important Not Very Important Unimportant
##   Democrat             0.42               0.41               0.13        0.04
##   Republican           0.59               0.35               0.05        0.01

Based on the crosstab, Republicans are more likely to view budget deficit as an important issue than Democrats since 94% of them consider it as important (94% vs 83%).

How Do Democrats and Republicans Differ in Their Perspectives on Budget Deficit? (Visualization)

VoterData_Modified%>%
  group_by(politicalparty, budgetdeficit)%>%
  summarize(n=n())%>%
  mutate(percent=n/sum(n))%>%
  ggplot()+
  geom_col(aes(x=politicalparty, y=percent, fill=budgetdeficit))
## Warning: Factor `budgetdeficit` contains implicit NA, consider using
## `forcats::fct_explicit_na`

As shown in the stacked bar chart, budget deficit is an important issue for both Democrats and Republicans. Republicans think of it as more important issue than Democrats according to the combined percentages of people who see it as “Very Important” and “Somewhat Important”.

Chi-square test for statistical relationship between people’s political parties and their opinions about budget deficit

chisq.test(VoterData_Modified$politicalparty, VoterData_Modified$budgetdeficit)
## 
##  Pearson's Chi-squared test
## 
## data:  VoterData_Modified$politicalparty and VoterData_Modified$budgetdeficit
## X-squared = 173.67, df = 3, p-value < 2.2e-16

Based on the chi-square test, the p-value is less than 0.05. This implies that there is a statistically significant relationship between the political party in which a person belongs and his/her opinion about budget deficit.

How Do Democrats and Republicans Differ in Their Perspectives on Taxes? (Crosstab)

prop.table(table(VoterData_Modified$politicalparty, VoterData_Modified$taxes),1)%>%
round(2)
##             
##              Very Important Somewhat Important Not Very Important Unimportant
##   Democrat             0.46               0.41               0.11        0.02
##   Republican           0.71               0.27               0.02        0.00

Based on the crosstab, the issue of taxes is more important to Republicans than Democrats as the combined percentage of Republicans who consider it as “Very Important” and “Somewhat Important” is higher (98% > 87%).

How Do Democrats and Republicans Differ in Their Perspectives on Taxes? (Visualization)

VoterData_Modified%>%
  group_by(politicalparty, taxes)%>%
  summarize(n=n())%>%
  mutate(percent=n/sum(n))%>%
  ggplot()+
  geom_col(aes(x=politicalparty, y=percent, fill=taxes))
## Warning: Factor `taxes` contains implicit NA, consider using
## `forcats::fct_explicit_na`

As shown in the stacked bar chart, Republicans are more likely think that taxes is an important issue of the country than Democrats.

Chi-square test for statistical relationship between people’s political parties and their opinions about taxes

chisq.test(VoterData_Modified$politicalparty, VoterData_Modified$taxes)
## 
##  Pearson's Chi-squared test
## 
## data:  VoterData_Modified$politicalparty and VoterData_Modified$taxes
## X-squared = 310.06, df = 3, p-value < 2.2e-16

Based on the chi-square test, the p-value is less than 0.05. This implies that there is a statistically significant relationship between the political party in which a person belongs and his/her opinion about taxes.

How Do Democrats and Republicans Differ in Their Perspectives on Raising Taxes on People with Incomes over $200,000? (Crosstab)

prop.table(table(VoterData_Modified$politicalparty, VoterData_Modified$taxwealthy),1)%>%
  round(2)
##             
##               Yes   No Don't Know
##   Democrat   0.84 0.07       0.09
##   Republican 0.32 0.55       0.13

According to the crosstab, Democrats and Republicans have different perspectives on raising taxes on wealthy people. Vast majority of Democrats favor raising taxes on wealthy people. On the other hand, majority of Republicans do not favor raising taxes on them.

How Do Democrats and Republicans Differ in Their Perspectives on Raising Taxes on People with Incomes over $200,000? (Visualization)

VoterData_Modified%>%
  group_by(politicalparty, taxwealthy)%>%
  summarize(n=n())%>%
  mutate(percent=n/sum(n))%>%
  ggplot()+
  geom_col(aes(x=politicalparty, y=percent, fill=taxwealthy))
## Warning: Factor `taxwealthy` contains implicit NA, consider using
## `forcats::fct_explicit_na`

The stacked bar chart demonstrates the difference between Democrats’ and Republicans’ view on raising taxes on wealthy people. More than half of the Republicans don’t think that taxes should be raised for wealthy people. However, more than 75% of Democrats believed that wealthy people should pay more taxes.

Chi-square test for statistical relationship between people’s political parties and their perspectives about raising taxes on wealthy people

chisq.test(VoterData_Modified$politicalparty, VoterData_Modified$taxwealthy)
## 
##  Pearson's Chi-squared test
## 
## data:  VoterData_Modified$politicalparty and VoterData_Modified$taxwealthy
## X-squared = 1341.8, df = 2, p-value < 2.2e-16

Based on the chi-square test, the p-value is less than 0.05. This implies that there is a statistically significant relationship between the political party in which a person belongs and his/her opinion about raising taxes on wealthy people.

How Do Democrats and Republicans Differ in Their Feelings Towards Rich White People?

VoterData_Modified%>%
  group_by(politicalparty)%>%
  filter(rwm_2019<=100, rww_2019<=100)%>%
  summarize(avgft_rwm=mean(rwm_2019, na.rm= TRUE), avgft_rww = mean(rww_2019, na.rm = TRUE))
## # A tibble: 2 x 3
##   politicalparty avgft_rwm avgft_rww
##   <chr>              <dbl>     <dbl>
## 1 Democrat            35.1      41.5
## 2 Republican          60.1      62.0

In this table, avgft_rwm means “the average feeling towards rich white men” and avgft_rww means “the average feeling towards rich white women”. Based on the averages computed, there is a significant difference between Democrats and Republicans in their feelings towards rich white men. Republicans gave much higher values for their feelings for rich white men than Democrats. Similarly, they gave much higher values for their feelings for rich white women.

How Do Democrats and Republicans Differ in Their Feelings Towards Rich White Males and Females? (Visualization)

VoterData_Modified%>%
  filter(rwm_2019<=100)%>%
  ggplot()+geom_histogram(aes(x=rwm_2019))+
  facet_wrap(~politicalparty)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

The histograms above show why there was a significant difference between the average feelings towards rich white men. The Republicans’ average was higher because more Republicans gave values of 50 or more compared to Democrats. However, more Democrats provided values of 50 or less.

VoterData_Modified%>%
  filter(rww_2019<=100)%>%
  ggplot()+geom_histogram(aes(x=rww_2019))+
  facet_wrap(~politicalparty)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

The histograms above show why there was a significant difference between the average feelings towards rich white women. The Republicans’ average was higher because more Republicans gave values of 50 or more. However, Democrats’ average was lower since more Democrats gave values of 50 or lower.

T-Test for Testing Statistical Difference between Political Party and the Average Feelings Towards Rich White Men and Rich White Women

VoterData_filtered3<-VoterData_Modified%>%
  filter(rwm_2019<=100, rww_2019<=100)
t.test(rwm_2019~politicalparty, data = VoterData_filtered3)
## 
##  Welch Two Sample t-test
## 
## data:  rwm_2019 by politicalparty
## t = -6.1859, df = 156.47, p-value = 5.17e-09
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -33.01341 -17.03285
## sample estimates:
##   mean in group Democrat mean in group Republican 
##                 35.06383                 60.08696
t.test(rww_2019~politicalparty, data = VoterData_filtered3)
## 
##  Welch Two Sample t-test
## 
## data:  rww_2019 by politicalparty
## t = -5.0822, df = 158.85, p-value = 1.037e-06
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -28.44779 -12.52507
## sample estimates:
##   mean in group Democrat mean in group Republican 
##                 41.54255                 62.02899

Based on the results from the T-test above, there is a statistically significant difference between political parties in which people in their feelings towards rich white men since the p-value is less than 0.05 (0.00000000517 < 0.05). Similary, there is a statistically significant difference between political parties in which they belong and their average feelings towards rich white women since the p-value is less than 0.05 (0.000001037 < 0.05)

Generating Sampling Distributions

In this section, sampling distributions were created for the variables “rwm_2019” and “rww_2019” to confirm the results of the Central Limit Theorem.
VoterData_filtered3a <- VoterData_filtered3%>%
  filter(politicalparty == "Democrat")
VoterData_filtered3b <- VoterData_filtered3%>%
  filter(politicalparty == "Republican")

Sampling distribution for “rwm_2019” for Democrats

  replicate(10000, sample(VoterData_filtered3a$rwm_2019, 40)%>%
                 mean(na.rm=TRUE))%>%
  data.frame()%>%
  rename("mean"=1)%>%
  ggplot()+geom_histogram(aes(x=mean), fill="blue")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Sampling distribution for “rwm_2019” for Republicans

  replicate(10000, sample(VoterData_filtered3b$rwm_2019, 40)%>%
                 mean(na.rm=TRUE))%>%
  data.frame()%>%
  rename("mean"=1)%>%
  ggplot()+geom_histogram(aes(x=mean), fill="red")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Sampling distribution for “rww_2019” for Democrats

  replicate(10000, sample(VoterData_filtered3a$rww_2019, 40)%>%
                 mean(na.rm=TRUE))%>%
  data.frame()%>%
  rename("mean"=1)%>%
  ggplot()+geom_histogram(aes(x=mean), fill="blue")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Sampling distribution for “rww_2019” for Republicans

  replicate(10000, sample(VoterData_filtered3b$rww_2019, 40)%>%
                 mean(na.rm=TRUE))%>%
  data.frame()%>%
  rename("mean"=1)%>%
  ggplot()+geom_histogram(aes(x=mean), fill="red")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Based on the shape of the histograms above, the sampling distributions are normal and this confirms the result of Central Limit Theorem.

How Do Democrats and Republicans Differ in Their Feelings Towards Rich Black Males and Females? (Crosstab)

VoterData_Modified%>%
  group_by(politicalparty)%>%
  filter(rbm_2019<=100, rbw_2019<=100)%>%
  summarize(avgft_rbm=mean(rbm_2019, na.rm= TRUE), avgft_rbw = mean(rbw_2019, na.rm = TRUE))
## # A tibble: 2 x 3
##   politicalparty avgft_rbm avgft_rbw
##   <chr>              <dbl>     <dbl>
## 1 Democrat            64.2      70.8
## 2 Republican          66.5      64.1

In this table, avgft_rbm means “the average feeling towards rich black men” and avgft_rbw means “the average feeling towards rich black women”. Based on the averages computed, in general, Democrats gave lower values for their feelings for rich black men than Republicans. However, in general, they gave higher values for their feelings for rich black women.

How Do Democrats and Republicans Differ in Their Feelings Towards Rich Black Males and Females? (Visualization)

VoterData_Modified%>%
  filter(rbm_2019<=100)%>%
  ggplot()+geom_histogram(aes(x=rbm_2019))+
  facet_wrap(~politicalparty)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

The histograms above why the average was higher for the Republicans. More Republicans gave values of 50 or more compared to Democrats. However, less Democrats provided values of 50 or more.

VoterData_Modified%>%
  filter(rbw_2019<=100)%>%
  ggplot()+geom_histogram(aes(x=rbw_2019))+
  facet_wrap(~politicalparty)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

The histograms above why the average was higher for the Democrats. More Democrats gave values of 50 or more compared to Republicans. However, less Republicans gave values of 50 or more.

T-Test for Testing Statistical Difference between Political Party and the Average Feelings Towards Rich Black Men and Rich Black Women

VoterData_filtered4<-VoterData_Modified%>%
  filter(rbm_2019<=100, rbw_2019<=100)
t.test(rbm_2019~politicalparty, data = VoterData_filtered4)
## 
##  Welch Two Sample t-test
## 
## data:  rbm_2019 by politicalparty
## t = -0.58584, df = 121.19, p-value = 0.5591
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -9.758154  5.301660
## sample estimates:
##   mean in group Democrat mean in group Republican 
##                 64.23077                 66.45902
t.test(rbw_2019~politicalparty, data = VoterData_filtered4)
## 
##  Welch Two Sample t-test
## 
## data:  rbw_2019 by politicalparty
## t = 1.7458, df = 122.78, p-value = 0.08335
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.8849816 14.1063831
## sample estimates:
##   mean in group Democrat mean in group Republican 
##                 70.75824                 64.14754

Based on the results from the T-test above, there is no statistically significant difference between political parties in which people in their feelings towards rich black men since the p-value is greater than 0.05 (0.5591 > 0.05). Also, there is no statistically significant difference between political parties in which they belong and their average feelings towards rich black women since the p-value is more than 0.05 (0.08335 > 0.05)

Generating Sampling Distributions

In this section, sampling distributions were created for the variables “rbm_2019” and “rbw_2019” to confirm the results of the Central Limit Theorem.
VoterData_filtered4a <- VoterData_filtered4%>%
  filter(politicalparty == "Democrat")
VoterData_filtered4b <- VoterData_filtered4%>%
  filter(politicalparty == "Republican")

Sampling distribution for “rbm_2019” for Democrats

  replicate(10000, sample(VoterData_filtered4a$rbm_2019, 40)%>%
                 mean(na.rm=TRUE))%>%
  data.frame()%>%
  rename("mean"=1)%>%
  ggplot()+geom_histogram(aes(x=mean), fill="blue")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Sampling distribution for “rbm_2019” for Republicans

  replicate(10000, sample(VoterData_filtered4b$rbm_2019, 40)%>%
                 mean(na.rm=TRUE))%>%
  data.frame()%>%
  rename("mean"=1)%>%
  ggplot()+geom_histogram(aes(x=mean), fill="red")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Sampling distribution for “rbw_2019” for Democrats

  replicate(10000, sample(VoterData_filtered4a$rbw_2019, 40)%>%
                 mean(na.rm=TRUE))%>%
  data.frame()%>%
  rename("mean"=1)%>%
  ggplot()+geom_histogram(aes(x=mean), fill="blue")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Sampling distribution for “rbw_2019” for Republicans

  replicate(10000, sample(VoterData_filtered4b$rbw_2019, 40)%>%
                 mean(na.rm=TRUE))%>%
  data.frame()%>%
  rename("mean"=1)%>%
  ggplot()+geom_histogram(aes(x=mean), fill="red")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Based on the shape of the histograms above, the sampling distributions are normal and this confirms the result of Central Limit Theorem.

How Do Democrats and Republicans Differ in Their Opinions about Giving Tax Credits to People with Lower Incomes? (Crosstab)

prop.table(table(VoterData_Modified$politicalparty, VoterData_Modified$taxcredit),1)%>%
  round(2)
##             
##              Strongly Support Somewhat Support Neither Support nor Oppose
##   Democrat               0.59             0.29                       0.09
##   Republican             0.23             0.34                       0.23
##             
##              Somewhat Oppose Strongly Oppose
##   Democrat              0.02            0.01
##   Republican            0.12            0.08

Based on the crosstab and by comparing the combined percentages for those who support giving tax credits to people with lower incomes, Democrats are more likely to support it than Republicans .

How Do Democrats and Republicans Differ in Their Opinions about Giving Tax Credits to People with Lower Incomes? (Visualization)

VoterData_Modified%>%
  group_by(politicalparty, taxcredit)%>%
  summarize(n=n())%>%
  mutate(percent=n/sum(n))%>%
  ggplot()+
  geom_col(aes(x=politicalparty, y=percent, fill=taxcredit))
## Warning: Factor `taxcredit` contains implicit NA, consider using
## `forcats::fct_explicit_na`

Based on the stacked bar chart, more than 75% of Democrats support giving tax credits to people with lower incomes whereas more than 50% of Republicans support it.

Chi-square test for statistical relationship between people’s political parties and their perspectives about giving tax credits to people with lower incomes

chisq.test(VoterData_Modified$politicalparty, VoterData_Modified$taxcredit)
## 
##  Pearson's Chi-squared test
## 
## data:  VoterData_Modified$politicalparty and VoterData_Modified$taxcredit
## X-squared = 796.2, df = 4, p-value < 2.2e-16

Based on the chi-square test, the p-value is less than 0.05. This implies that there is a statistically significant relationship between the political party in which a person belongs and his/her opinion about giving tax credits to those with low incomes.

Conclusion

Democrats and Republicans have different perspectives on the important economic issues such as taxes and poverty and different feelings towards rich and poor people. Based on the voter data, Republicans are more optimistic about the economy than Democrats. Democrats are more likely to think that poverty is an important issue and believe that it is the responsibility of the government to reduce the income gap between poor and wealthy people than Republicans. In general, Democrats gave higher values for their feelings towards poor black people than Republicans. On the other hand, Republicans gave higher values for their feelings towards poor white people. Both Democrats and Republicans think social security, budget deficit and taxes are important issues of the country. However, Democrats are less likely to support rich white people and more likely to support raising taxes for wealthy people than Repubicans. They also gave lower values for their feelings toward rich black men and higher values for rich black women than Republicans but there was no significant difference. Republicans are less likely to support giving tax credits to people with lower incomes than Democrats.