V201606 is a pre-election variable asking respondents if they have any money invested in the stock market. V201502 is a pre-election variable asking respondents how much better or worse off they are now versus a year ago.
Yes, the results do suggest an association. If you have money invested in the stock market you are most likely to be feel you are better off than the year prior. The results also show that those who had not invested in stocks were more likely to feel worse off than the following year.
table(ANES2020$V201606, ANES2020$V201502)
##
## 1 2 3 4 5
## 1 392 904 2180 590 144
## 2 196 468 1520 657 389
stock_market <- table(ANES2020$V201606, ANES2020$V201502)
chisq.test(ANES2020$V201606, ANES2020$V201502)
##
## Pearson's Chi-squared test
##
## data: ANES2020$V201606 and ANES2020$V201502
## X-squared = 314.2, df = 4, p-value < 2.2e-16
expected_values <- matrix(nrow = 2, ncol = 5)
for(i in 1:nrow(stock_market)){
for(j in (1:ncol(stock_market))){
expected_values[i,j] <- (sum(stock_market[i,]) *
sum(stock_market[,j]))/sum(stock_market)
}
}
stock_market - expected_values
##
## 1 2 3 4 5
## 1 59.27419 127.63978 86.31720 -115.62769 -157.60349
## 2 -59.27419 -127.63978 -86.31720 115.62769 157.60349
differences <- stock_market - expected_values
V201549x is a pre-election variable asking respondents their race/ethnicity. V201502 is a pre-election variable asking respondents how much better or worse off they are now versus a year ago.
Yes, the results do suggest there is an association between race/ethnicity and whether respondents were likely to feel better or worse off than the previous year.
table(ANES2020$V201549x, ANES2020$V201502)
##
## 1 2 3 4 5
## 1 473 1121 3044 949 366
## 2 57 89 358 132 90
## 3 73 129 355 144 59
## 4 15 67 144 43 15
## 5 7 18 86 41 19
## 6 20 38 133 44 35
chisq.test(ANES2020$V201549x, ANES2020$V201502)
##
## Pearson's Chi-squared test
##
## data: ANES2020$V201549x and ANES2020$V201502
## X-squared = 105.86, df = 20, p-value = 1.112e-13
preelec_race <- table(ANES2020$V201549x, ANES2020$V201502)
expected_values <- matrix(nrow = 6, ncol = 5)
for(i in 1:nrow(preelec_race)){
for(j in (1:ncol(preelec_race))){
expected_values[i,j] <- (sum(preelec_race[i,]) *
sum(preelec_race[,j]))/sum(preelec_race)
}
}
preelec_race - expected_values
##
## 1 2 3 4 5
## 1 2.6809162 54.9434101 39.7912788 -37.5763106 -59.8392945
## 2 -0.3579128 -41.0112690 -8.3792259 11.6817736 38.0666340
## 3 12.9559040 -7.0999510 -28.5374816 18.0470358 4.6344929
## 4 -7.4375306 16.1415973 0.6780990 -4.0666340 -5.3155316
## 5 -6.5099216 -12.6224890 -0.2959334 12.6605830 6.7677609
## 6 -1.3314552 -10.3512984 -3.2567369 -0.7464478 15.6859383
V201255 is a pre-election variable asking respondents about the degree to which they think government should make sure people have jobs and a good standard of living versus let people get ahead on their own. V201502 is a pre-election variable asking respondents how much better or worse off they are now versus a year ago.
Yes, the results do suggest there is an association between people who valued getting ahead on their own and the likelihood that they will be better off now versus a year ago.
table(ANES2020$V201255, ANES2020$V201502)
##
## 1 2 3 4 5
## 1 57 122 408 190 144
## 2 40 121 401 145 60
## 3 42 160 532 218 66
## 4 93 192 820 263 88
## 5 61 180 538 155 62
## 6 94 253 472 102 37
## 7 198 316 521 125 33
chisq.test(ANES2020$V201255, ANES2020$V201502)
##
## Pearson's Chi-squared test
##
## data: ANES2020$V201255 and ANES2020$V201502
## X-squared = 530.57, df = 24, p-value < 2.2e-16
govjobs <- table(ANES2020$V201255, ANES2020$V201502)
expected_values <- matrix(nrow = 7, ncol = 5)
for(i in 1:nrow(govjobs)){
for(j in (1:ncol(govjobs))){
expected_values[i,j] <- (sum(govjobs[i,]) *
sum(govjobs[,j]))/sum(govjobs)
}
}
govjobs - expected_values
##
## 1 2 3 4 5
## 1 -16.715283 -47.356136 -57.225339 39.041182 82.255575
## 2 -21.389383 -20.038172 13.564783 19.282939 8.579833
## 3 -39.478998 -27.192776 17.776987 51.142154 -2.247366
## 4 -23.535778 -75.733479 84.529758 24.350664 -9.611164
## 5 -18.718156 -3.147353 34.889862 -8.251881 -4.772472
## 6 17.323300 76.840197 -11.915173 -55.023396 -27.224928
## 7 102.514297 96.627719 -81.620878 -70.541661 -46.979477
V202187 is a post-election feeling thermometer asking respondents how they feel about people who identify as gay or lesbian. V202172 is a post-election feeling thermometer asking respondents how they feel about people who identify as transgender.
Test Statistic = 2.3663 The conclusion that can be made is that there is a clear relationship between how respondents feel about gay or lesbian individuals and how they will feel about transgender individuals.
cor.test(ANES2020$V202187, ANES2020$V202172, use="complete.obs")
##
## Pearson's product-moment correlation
##
## data: ANES2020$V202187 and ANES2020$V202172
## t = 2.3663, df = 7304, p-value = 0.018
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.004748795 0.050575504
## sample estimates:
## cor
## 0.02767669
V202171 is a post-election feeling thermometer asking respondents how they feel about the police. V202173 is a post-election feeling thermometer asking respondents how they feel about the Black Lives Matter movement.
Test Statistic = -4.2962 The conclusion we should make based on this statistic is their is no correlation between how respondents feel about police and how they feel about the Black Lives Matter movement.
cor.test(ANES2020$V202171, ANES2020$V202173, use="complete.obs")
##
## Pearson's product-moment correlation
##
## data: ANES2020$V202171 and ANES2020$V202173
## t = -4.2962, df = 7386, p-value = 1.76e-05
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.07264795 -0.02715500
## sample estimates:
## cor
## -0.04992737
Can we compare the two correlation coefficients from Questions 4 and 5? Why or why not? If we can, what comparison(s) can we make?
We cannot compare the two correlation coefficients as one suggests no correlation given the negative value of the coefficient.