Data analysis focusing on the viewpoints on the government and today’s economy based on party identification. Data was obtained from the 2018 voter survey conducted firm YouGov. The survey studied the responses of 6,005 adults of varying ages and gender on common issues. This data analysis research intends to determine if a respondents’ political identification affects their view on the government and the economy. The variables being used to determine if there is any correlation between party identification and government and economy views are as follows:
Variables Used:
pid3_2018 - asking respondents how they identify themselves politically. Recoded to partyid
trustgovt_2018 - asking respondents how often they think the government should be trusted. Recoded to govtrust
track_2018 - respondents views on the direction the country- Recoded to contrack
econtrend_2018 - respondents views on the state of the economy - Recoded to econtrend
life_2018 - asking respondents their views regarding the state of the country today vs fifty years ago - Recoded to lifeview
governed_2018 – a continuous variable asking respondents how important it is to live in a democratic country. Recoded to governview
To begin a crosstabulation was conducted to determine respondents’ views on how important it was for them to live in a country that is governed democratically based on their party identification. The null hypothesis analysis was also conducted for comparison. Subsequently after the sample distribution was conducted for those who are democrats and those that are republican, the actual frequency distribution study was conducted and the null hypothesis was tested for each of the variables selected for the study to see what the result would be. Here are the results as follows:
As it is shown in the results below the null hypothesis for each variable those value percent will be obtained if there is no statistical significance between party identification and the government and economy variables selected. Each variable is completely independent of each other, in short no dependence. If the actual distribution is the same then we will have to accept the null hypothesis however, if the numbers are significantly different we will have to reject the null hypothesis.
All these aforementioned variables after being recoded were analyzed to determine if there was any statistical significance between the independent variable party identification and the dependent variables government and economy. Using the summarize command, the average from one to ten to rate how important is it to the respondent to live in a country that is governed democratically based on their party identification. A T.test was also conducted to determine statistical significance. See table and data below:
votecensus%>%
group_by(partyid)%>%
summarize(avg_ft_gov= mean(governview, na.rm = TRUE))%>%
kable()%>%
kable_styling(bootstrap_options = c("striped", "hover"))%>%
column_spec(1, bold = T)%>%
row_spec(1, background="blue")%>%
row_spec(2, background="red")
| partyid | avg_ft_gov |
|---|---|
| Democrat | 9.356268 |
| Republican | 8.943454 |
t.test(governview~partyid, data = votecensus)
##
## Welch Two Sample t-test
##
## data: governview by partyid
## t = 7.8185, df = 2772.9, p-value = 0.000000000000007531
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.3092833 0.5163436
## sample estimates:
## mean in group Democrat mean in group Republican
## 9.356268 8.943454
table(votecensus$partyid)%>%
prop.table()%>%
round(2)%>%
kable()%>%
kable_styling(bootstrap_options = c("striped", "hover"))%>%
row_spec(1, background="blue")%>%
row_spec(2, background="red")
| Var1 | Freq |
|---|---|
| Democrat | 0.57 |
| Republican | 0.43 |
If the median score is five which indicates neutrality we can see that there is some correlation between party identification and government view. The data shows that those who are democrats had an average of 9.3 which is positively skewed. Those who are republicans had an average of 8.9 which is also positively skewed. This tells us that both democrats and republicans think it is very important to live in a country that is governed democratically. The p-value result obtained from the t-test conducted is less that .05 which means there is statistical significance between respondents’ party identification and their views of the government. It also should be noted that those numbers are far different from the null hypothesis shown above for democrats and for republicans. Secondly, a sample distribution was conducted by selecting random forty samples and replicating the results ten thousand times. Many samples were drawn from a set of numbers with variance taking the average of each sample to see the normal distribution. The sample distribution was conducted for both democrats and republicans. See histograms below:
voterdemocrat <-votecensus%>%
filter(partyid == "Democrat")
replicate(10000, sample(voterdemocrat$governview,40)%>%mean(na.rm=TRUE))%>%
data.frame()%>%
rename("mean"=1)%>%
ggplot()+
geom_histogram(aes(x=mean), fill ="blue")+
labs(x= "Democrat Average", y= "Trust Thermometer",
title="Democrat Views on Government Trust")+
theme_minimal()
voterrepublican <-votecensus%>%
filter(partyid == "Republican")
replicate(10000, sample(voterrepublican$governview,40)%>%mean(na.rm=TRUE))%>%
data.frame()%>%
rename("mean"=1)%>%
ggplot()+
geom_histogram(aes(x=mean), fill ="red")+
labs(x= "Republican Average ", y= "Trust Thermometer",
title="Republican Views on Government Trust")+
theme_minimal()
The sample distribution for democrats is indicated by the color blue. As shown in the histogram the responses from respondents who fall in this category spreads mostly between the means of 9.2 and 9.6. Most of the distribution is spread mostly over the neutral mark of five which indicates that democrats have positive views of being governed democratically. The sample distribution for republicans is indicated by the color red. As shown by the histogram the scores from respondents hover between the scores 8.5 and 9.5. Most of the distribution is spread mostly over the neutrality mark of five which indicates that republican also have positive views on a democratic society. Next a series of crosstabs were conducted between the categorical variable “party identification” and other government and economy related categorical variables to determine if the actual frequency distribution is different that the null hypothesis above. Additionally, Chi Square tests were conducted to determine in each instance if those two categorical variables had any correlation. The first crosstab was conducted between party identification and the recoded variable government trust “govtrust” which determines respondents’ feelings towards trusting the government . See below:
table(votecensus$govtrust, votecensus$partyid)%>%
prop.table(2)%>%
round(2)%>%
kable()%>%
kable_styling(bootstrap_options = c("striped", "hover"))%>%
column_spec(1, bold = T)%>%
column_spec(2, background="blue")%>%
column_spec(3, background="red")
| Democrat | Republican | |
|---|---|---|
| Just about always | 0.02 | 0.02 |
| Most of the time | 0.15 | 0.21 |
| Some of the time | 0.84 | 0.76 |
chisq.test(votecensus$partyid, votecensus$govtrust)
##
## Pearson's Chi-squared test
##
## data: votecensus$partyid and votecensus$govtrust
## X-squared = 30.522, df = 2, p-value = 0.0000002356
table(votecensus$govtrust)%>%
prop.table()%>%
round(2)%>%
kable()%>%
kable_styling(bootstrap_options = c("striped", "hover"))%>%
column_spec(1, bold = T)
| Var1 | Freq |
|---|---|
| Just about always | 0.02 |
| Most of the time | 0.18 |
| Some of the time | 0.80 |
The results of the crosstabulation indicated that eighty four percent of democrats trusted the government “Some of the time” While republicans had seventy six percent trust. Therefore there was not much difference in respondents trust in the government based on party identification. However when looking at the null hypothesis we see that the results obtained are different therefore, the correlation is substantial. The chi-square test conducted indicates that there is statistical significance between respondents’ party identification and their trust in the government as the p-value was 0.0000002356 which is less that .05. The next cross-tabulation was conducted to see if there is any correlation between respondents’ views on the country’s direction to see if their views are affected by their party identification. See table below:
table(votecensus$contrack, votecensus$partyid)%>%
prop.table(2)%>%
round(2)%>%
kable()%>%
kable_styling(bootstrap_options = c("striped", "hover"))%>%
column_spec(1, bold = T)%>%
column_spec(2, background="blue")%>%
column_spec(3, background="red")
| Democrat | Republican | |
|---|---|---|
| Don’t know | 0.08 | 0.08 |
| Generally headed in the right direction | 0.10 | 0.70 |
| Off on the wrong track | 0.83 | 0.22 |
chisq.test(votecensus$partyid, votecensus$contrack)
##
## Pearson's Chi-squared test
##
## data: votecensus$partyid and votecensus$contrack
## X-squared = 1529, df = 2, p-value < 0.00000000000000022
table(votecensus$contrack)%>%
prop.table()%>%
round(2)%>%
kable()%>%
kable_styling(bootstrap_options = c("striped", "hover"))%>%
column_spec(1, bold = T)
| Var1 | Freq |
|---|---|
| Don’t know | 0.08 |
| Generally headed in the right direction | 0.36 |
| Off on the wrong track | 0.56 |
As shown by the table 83 percent of democrats believe that the country is off on the wrong track. While 70 percent of republicans are of the view that generally the country is headed in the right direction. While 10 percent of democrats believe that the country is headed in the right direction while 22 percent of republicans believe that the country is headed off track. There is clearly some relationship between the independent variable party identification and the dependent variable in this cross-tabulation country direction. As it is shown the values for both headed in the right direction and headed off track are over the null hypothesis in each instance and the chi-square test conducted indicates significance. The next cross-tabulation conducted was to see if respondent views towards the country’s economic state based on their party identification. See table below:
table(votecensus$econtrend, votecensus$partyid)%>%
prop.table(2)%>%
round(2)%>%
kable()%>%
kable_styling(bootstrap_options = c("striped", "hover"))%>%
column_spec(1, bold = T)%>%
column_spec(2, background="blue")%>%
column_spec(3, background="red")
| Democrat | Republican | |
|---|---|---|
| About the same | 0.44 | 0.23 |
| Don’t know | 0.07 | 0.04 |
| Getting better | 0.10 | 0.67 |
| Getting worse | 0.38 | 0.06 |
chisq.test(votecensus$partyid, votecensus$econtrend)
##
## Pearson's Chi-squared test
##
## data: votecensus$partyid and votecensus$econtrend
## X-squared = 1353.8, df = 3, p-value < 0.00000000000000022
table(votecensus$econtrend)%>%
prop.table()%>%
round(2)%>%
kable()%>%
kable_styling(bootstrap_options = c("striped", "hover"))%>%
column_spec(1, bold = T)
| Var1 | Freq |
|---|---|
| About the same | 0.35 |
| Don’t know | 0.06 |
| Getting better | 0.35 |
| Getting worse | 0.24 |
The cross-tabulation between party identification and the recoded variable economic trends “econtrend” indicates that democrats believe that the economy is about the same with 44 while 38 percent of democrats believe the economy is getting worse. 67 percent of republicans believe that the economy is getting better while 23 percent believe that it is about the same. Here again the actual distribution differs from the null hypothesis proving that there must be some relationship. The final cross tabulation conducted was to determine if there was any connection between a respondent’s party identification and their views on the country’s state now compared to fifty years ago The following were the results:
table(votecensus$lifeview, votecensus$partyid)%>%
prop.table(1)%>%
round(2)%>%
kable()%>%
kable_styling(bootstrap_options = c("striped", "hover"))%>%
column_spec(1, bold = T)%>%
column_spec(2, background="blue")%>%
column_spec(3, background="red")
| Democrat | Republican | |
|---|---|---|
| About the same | 0.59 | 0.41 |
| Better | 0.50 | 0.50 |
| Don’t know | 0.63 | 0.37 |
| Worse | 0.60 | 0.40 |
chisq.test(votecensus$partyid, votecensus$lifeview)
##
## Pearson's Chi-squared test
##
## data: votecensus$partyid and votecensus$lifeview
## X-squared = 31.104, df = 3, p-value = 0.0000008081
table(votecensus$lifeview)%>%
prop.table()%>%
round(2)%>%
kable()%>%
kable_styling(bootstrap_options = c("striped", "hover"))%>%
column_spec(1, bold = T)
| Var1 | Freq |
|---|---|
| About the same | 0.19 |
| Better | 0.34 |
| Don’t know | 0.07 |
| Worse | 0.40 |
Democrats with 59 percent are of the view that the country compared to fifty years ago is worse in comparison while the republicans with 41 percent of the view that the country’s state today is about the same when compared to fifty years ago. 60 percent of democrats believe the country is better in comparison while 40 percent of republicans believe it is worse in comparison. Chi-square test where conducted for all these cross tabulation aforementioned and in each instance the p-value was less than .05 which indicates statistical significance for each categorical variable when it was cross-tabulated with the independent variable party identification. Once again the actual frequency distribution differs from the null hypothesis. Therefore, these variables are not independent of each other. The null hypothesis tables when compared to the actual distribution in each instance prove that there is a relationship with party identification and all the variables selected when looking at government and the economy. All these generated crosstabs, tables and average indicates to the researcher that there is statistical significance as a respondents’ party identification does affect how they view the government has a whole and the current economy. Perhaps this is due to whichever party is in office at the time of survey and if the respondent identifies with that party they will be more favorable with their responses. On the other hand if the respondent does not identify with the party in office then perhaps their response will be less favorable.
votecensus%>%
filter(lifeview %in% c("Better", "About the same", "Worse"))%>%
group_by(lifeview, partyid)%>%
summarise(n=n())%>%
mutate(percent=n/sum(n))%>%
ggplot()+
geom_col(aes(lifeview, y=percent, fill=partyid))+
labs(x= "Responses to Country's Status", y= "Percent",
title="Repondents thoughts on the Country's Status Today")+
theme_minimal()
The visualization shown shown indicate democrats are of the view that the country is about the same or getting worse in comparison with the view of the country 50 years ago with 59 and 60 percent. While republicans are of the view that the country is about the same or getting worse with 41 and 40 percent respectively.After looking at a series of variables and running various statistical test it leads only to one conclusion that one’s party identification does determine how one view the government and economic issues.
In closing, this study finds that there is statistical significance in the relationship between the party a respondent identifies with and their views an attitude towards the government and the economy. Based on the data it can be determined that whichever party is in office at the time of survey and if the respondent identifies with that party they will be more favorable with their responses. On the other hand if the respondent does not identify with the party in office then perhaps their response will be less favorable. This was determined by filtering respondents based on their party identification whether they are a democrat and comparing them to the views of a republican. Based on the variables selected and the chi-square tests in each instance, and t. test conducted the p-value was less than .05 every time. Therefore, the correlation is deemed statistically significant. The independent variable X= party identification does correlate to the dependent variables selected based on government and the economy. Therefore, the null hypothesis has to be rejected.