In my analysis, I will look at seven variables and there relationships with feelings toward immigration.
MyVoterData <- FullVoterData %>%
mutate(Immigration_Should_Be = ifelse(immi_makedifficult_2018 == 1, "Much Easier",
ifelse(immi_makedifficult_2018 == 2, "Slightly Easier",
ifelse(immi_makedifficult_2018 == 3, "No Change",
ifelse(immi_makedifficult_2018 == 4, "Slightly Harder",
ifelse(immi_makedifficult_2018 == 5, "Much Harder",
ifelse(immi_makedifficult_2018 == 8, "Don't Know", NA)))))),
Raised_In_US = ifelse(childhood_2018 == 1, "Yes",
ifelse(childhood_2018 == 2, "No", NA)),
Relig_Importance = ifelse(pew_religimp_2018 == 1, "Very Important",
ifelse(pew_religimp_2018 == 2, "Somewhat Important",
ifelse(pew_religimp_2018 == 3, "Not Too Important",
ifelse(pew_religimp_2018 == 4, "Not at All Important", NA)))),
Occupation = ifelse(occupationcat_baseline == 1, "Professional/Technical",
ifelse(occupationcat_baseline == 2, "Management",
ifelse(occupationcat_baseline == 3, "Management",
ifelse(occupationcat_baseline == 4, "Sales",
ifelse(occupationcat_baseline == 5, "Business Owner/Self-Employed",
ifelse(occupationcat_baseline == 6, "Clerical/Administrative",
ifelse(occupationcat_baseline == 7, "Military/Civilian Uniform Services",
ifelse(occupationcat_baseline == 8, "Retired",
ifelse(occupationcat_baseline == 9, "Other",
ifelse(occupationcat_baseline == 10, "Student",
ifelse(occupationcat_baseline == 11, "Unemployed",
ifelse(occupationcat_baseline == 12, "Other", NA)))))))))))),
FT_Trump = ifelse(trumpfeel_2018 == 1, "Like and Approve of his Policies",
ifelse(trumpfeel_2018 == 2, "Like but Disapprove of his Policies",
ifelse(trumpfeel_2018 == 3, "Dislike but Approve of his Policies",
ifelse(trumpfeel_2018 == 4, "Dislike and Disapprove of his Policies", NA)))),
Politics_OR_Current_Events = ifelse(polinterest_baseline == 1, "Very Interested",
ifelse(polinterest_baseline == 2, "Somewhat Interested",
ifelse(polinterest_baseline == 3, "Not Very Interested",
ifelse(polinterest_baseline == 4, "Nothing", NA))))) %>%
filter(!is.na(ft_immig_2017),ft_immig_2017<=100) %>%
select(Immigration_Should_Be, Raised_In_US, Relig_Importance, Occupation, FT_Trump, Politics_OR_Current_Events, ft_immig_2017)
head(MyVoterData)
MyVoterData <- MyVoterData %>%
mutate(Immigration_Should_Be = factor(Immigration_Should_Be, levels = c("Much Easier",
"Slightly Easier",
"No Change",
"Slightly Harder",
"Much Harder",
"Don't Know"
)),
Raised_In_US = factor(Raised_In_US, levels = c("Yes",
"No")),
Occupation = factor(Occupation, levels = c("Professional/Technical",
"Management",
"Sales",
"Business Owner/Self-Employed",
"Clerical/Administrative",
"Military/Civilian Uniform Services",
"Retired",
"Student",
"Unemployed",
"Other")),
Politics_OR_Current_Events = factor(Politics_OR_Current_Events, levels = c("Very Interested",
"Somewhat Interested",
"Not Very Interested",
"Nothing")))
kable(round(prop.table(table(MyVoterData$Raised_In_US, MyVoterData$Immigration_Should_Be),1),2)) %>%
kable_styling(bootstrap_options = c("striped", "condensed"), full_width = T) %>%
column_spec(1, bold = T)
| Much Easier | Slightly Easier | No Change | Slightly Harder | Much Harder | Don't Know | |
|---|---|---|---|---|---|---|
| Yes | 0.09 | 0.17 | 0.26 | 0.19 | 0.24 | 0.05 |
| No | 0.09 | 0.20 | 0.29 | 0.18 | 0.20 | 0.04 |
# Observed Frequencies
chisq.test(MyVoterData$Raised_In_US, MyVoterData$Immigration_Should_Be)[6]
$observed
MyVoterData$Raised_In_US Much Easier Slightly Easier No Change Slightly Harder Much Harder Don't Know
Yes 386 741 1096 823 1023 211
No 16 34 50 30 34 7
# Expected Frequencies
chisq.test(MyVoterData$Raised_In_US, MyVoterData$Immigration_Should_Be)[7]
$expected
MyVoterData$Raised_In_US Much Easier Slightly Easier No Change Slightly Harder Much Harder Don't Know
Yes 386.55583 745.22579 1101.97259 820.22916 1016.39182 209.624803
No 15.44417 29.77421 44.02741 32.77084 40.60818 8.375197
# Chi-Squared Test
chisq.test(MyVoterData$Raised_In_US, MyVoterData$Immigration_Should_Be)
Pearson's Chi-squared test
data: MyVoterData$Raised_In_US and MyVoterData$Immigration_Should_Be
X-squared = 3.0839, df = 5, p-value = 0.6871
There is no statistically significant relationship between being raised in the U.S. and one’s feelings toward changing immigration laws.
kable(MyVoterData %>%
group_by(Raised_In_US) %>%
filter(!is.na(Raised_In_US)) %>%
summarize(avg_ft_immig = mean(ft_immig_2017, na.rm = TRUE))
) %>%
kable_styling(bootstrap_options = c("striped", "condensed"), full_width = T) %>%
column_spec(1, bold = T)
| Raised_In_US | avg_ft_immig |
|---|---|
| Yes | 61.09127 |
| No | 72.05848 |
# T-Test
t.test(ft_immig_2017~Raised_In_US, data = MyVoterData)
Welch Two Sample t-test
data: ft_immig_2017 by Raised_In_US
t = -5.6801, df = 187.14, p-value = 0.00000005077
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-14.776177 -7.158242
sample estimates:
mean in group Yes mean in group No
61.09127 72.05848
The table shows that on average, people who were raised outside of the US have higher feelings toward immigrants than people raised within the US. The t-test shows that there is a statistically significant difference between people raised within and outside the US and their average feelings toward immigrants.
kable(round(prop.table(table(MyVoterData$Relig_Importance, MyVoterData$Immigration_Should_Be),1),2)) %>%
kable_styling(bootstrap_options = c("striped", "condensed"), full_width = T) %>%
column_spec(1, bold = T)
| Much Easier | Slightly Easier | No Change | Slightly Harder | Much Harder | Don't Know | |
|---|---|---|---|---|---|---|
| Not at All Important | 0.16 | 0.26 | 0.26 | 0.14 | 0.14 | 0.05 |
| Not Too Important | 0.08 | 0.18 | 0.27 | 0.20 | 0.21 | 0.05 |
| Somewhat Important | 0.07 | 0.16 | 0.26 | 0.21 | 0.24 | 0.05 |
| Very Important | 0.07 | 0.13 | 0.25 | 0.21 | 0.30 | 0.04 |
# Observed Frequencies
chisq.test(MyVoterData$Relig_Importance, MyVoterData$Immigration_Should_Be)[6]
$observed
MyVoterData$Relig_Importance Much Easier Slightly Easier No Change Slightly Harder Much Harder Don't Know
Not at All Important 157 253 254 134 140 53
Not Too Important 51 115 169 124 133 30
Somewhat Important 75 175 284 224 264 59
Very Important 119 232 440 371 525 77
# Expected Frequencies
chisq.test(MyVoterData$Relig_Importance, MyVoterData$Immigration_Should_Be)[7]
$expected
MyVoterData$Relig_Importance Much Easier Slightly Easier No Change Slightly Harder Much Harder Don't Know
Not at All Important 89.36339 172.2802 254.9747 189.6193 236.0794 48.68304
Not Too Important 56.08883 108.1314 160.0345 119.0144 148.1750 30.55585
Somewhat Important 97.47914 187.9262 278.1308 206.8401 257.5195 53.10431
Very Important 159.06864 306.6622 453.8600 337.5262 420.2261 86.65680
# Ch-Squared Test
chisq.test(MyVoterData$Relig_Importance, MyVoterData$Immigration_Should_Be)
Pearson's Chi-squared test
data: MyVoterData$Relig_Importance and MyVoterData$Immigration_Should_Be
X-squared = 215.64, df = 15, p-value < 0.00000000000000022
There is a strong statistical association between religious importance and feelings toward changing immigration laws. 29% of respondents who believe religion is very important also believe that immigration should be much harder, while only 14% of respondents who believe religion is not at all important believe that immigration should be much harder.
kable(MyVoterData %>%
group_by(Relig_Importance) %>%
filter(!is.na(Relig_Importance)) %>%
summarize(avg_ft_immig = mean(ft_immig_2017, na.rm = TRUE))
) %>%
kable_styling(bootstrap_options = c("striped", "condensed"), full_width = T) %>%
column_spec(1, bold = T)
| Relig_Importance | avg_ft_immig |
|---|---|
| Not at All Important | 67.81635 |
| Not Too Important | 61.97428 |
| Somewhat Important | 58.97138 |
| Very Important | 59.35730 |
NA
The table shows that on average, people who believe religion is not so important have higher feelings toward immigrants than people who believe religion is important.
kable(round(prop.table(table(MyVoterData$Occupation, MyVoterData$Immigration_Should_Be),1),2)) %>%
kable_styling(bootstrap_options = c("striped", "condensed"), full_width = T) %>%
column_spec(1, bold = T)
| Much Easier | Slightly Easier | No Change | Slightly Harder | Much Harder | Don't Know | |
|---|---|---|---|---|---|---|
| Professional/Technical | 0.12 | 0.21 | 0.26 | 0.17 | 0.20 | 0.04 |
| Management | 0.10 | 0.16 | 0.24 | 0.25 | 0.21 | 0.04 |
| Sales | 0.07 | 0.17 | 0.24 | 0.19 | 0.29 | 0.04 |
| Business Owner/Self-Employed | 0.05 | 0.22 | 0.30 | 0.18 | 0.22 | 0.03 |
| Clerical/Administrative | 0.08 | 0.16 | 0.26 | 0.18 | 0.25 | 0.06 |
| Military/Civilian Uniform Services | 0.08 | 0.13 | 0.23 | 0.27 | 0.25 | 0.04 |
| Retired | 0.10 | 0.16 | 0.25 | 0.21 | 0.25 | 0.03 |
| Student | 0.21 | 0.31 | 0.15 | 0.10 | 0.15 | 0.07 |
| Unemployed | 0.10 | 0.14 | 0.25 | 0.18 | 0.25 | 0.08 |
| Other | 0.06 | 0.15 | 0.26 | 0.18 | 0.28 | 0.07 |
# Observed Frequencies
chisq.test(MyVoterData$Occupation, MyVoterData$Immigration_Should_Be)[6]
$observed
MyVoterData$Occupation Much Easier Slightly Easier No Change Slightly Harder Much Harder
Professional/Technical 110 196 247 158 184
Management 56 89 128 133 112
Sales 15 36 52 41 61
Business Owner/Self-Employed 14 61 81 49 60
Clerical/Administrative 29 63 101 71 96
Military/Civilian Uniform Services 4 7 12 14 13
Retired 72 116 188 156 188
Student 14 21 10 7 10
Unemployed 29 42 75 52 74
Other 58 135 241 161 257
MyVoterData$Occupation Don't Know
Professional/Technical 40
Management 22
Sales 8
Business Owner/Self-Employed 9
Clerical/Administrative 24
Military/Civilian Uniform Services 2
Retired 23
Student 5
Unemployed 24
Other 61
# Expected Frequencies
chisq.test(MyVoterData$Occupation, MyVoterData$Immigration_Should_Be)[7]
$expected
MyVoterData$Occupation Much Easier Slightly Easier No Change Slightly Harder Much Harder
Professional/Technical 84.884537 162.148517 240.25923 178.23636 223.32465
Management 49.024225 93.647272 138.75934 102.93865 128.97894
Sales 19.337333 36.938646 54.73285 40.60358 50.87503
Business Owner/Self-Employed 24.875255 47.517319 70.40752 52.23183 65.44487
Clerical/Administrative 34.861671 66.593616 98.67331 73.20082 91.71836
Military/Civilian Uniform Services 4.720851 9.017885 13.36201 9.91261 12.42019
Retired 67.453702 128.851709 190.92257 141.63595 177.46547
Student 6.082635 11.619199 17.21644 12.77202 16.00294
Unemployed 26.872538 51.332579 76.06067 56.42563 70.69957
Other 82.887254 158.333258 234.60607 174.04256 218.06996
MyVoterData$Occupation Don't Know
Professional/Technical 46.146706
Management 26.651573
Sales 10.512565
Business Owner/Self-Employed 13.523206
Clerical/Administrative 18.952230
Military/Civilian Uniform Services 2.566448
Retired 36.670591
Student 3.306769
Unemployed 14.609011
Other 45.060901
# Chi-Squared Test
chisq.test(MyVoterData$Occupation, MyVoterData$Immigration_Should_Be)
Pearson's Chi-squared test
data: MyVoterData$Occupation and MyVoterData$Immigration_Should_Be
X-squared = 128.6, df = 45, p-value = 0.000000000558
There is a statically significant association between occupation and feelings toward changing immigration laws. The crosstab shows that students are the only occupation category in which the majority respondents believe immigration should be made easier.
kable(MyVoterData %>%
group_by(Occupation) %>%
filter(!is.na(Occupation)) %>%
summarize(avg_ft_immig = mean(ft_immig_2017, na.rm = TRUE))
) %>%
kable_styling(bootstrap_options = c("striped", "condensed"), full_width = T) %>%
column_spec(1, bold = T)
| Occupation | avg_ft_immig |
|---|---|
| Professional/Technical | 63.96885 |
| Management | 63.45352 |
| Sales | 59.72628 |
| Business Owner/Self-Employed | 62.69412 |
| Clerical/Administrative | 63.05165 |
| Military/Civilian Uniform Services | 55.06579 |
| Retired | 60.78330 |
| Student | 67.74074 |
| Unemployed | 57.83690 |
| Other | 59.89817 |
The table shows that on average, students have the highest feelings toward immigrants.
kable(round(prop.table(table(MyVoterData$Politics_OR_Current_Events, MyVoterData$Immigration_Should_Be),1),2)) %>%
kable_styling(bootstrap_options = c("striped", "condensed"), full_width = T) %>%
column_spec(1, bold = T)
| Much Easier | Slightly Easier | No Change | Slightly Harder | Much Harder | Don't Know | |
|---|---|---|---|---|---|---|
| Very Interested | 0.11 | 0.20 | 0.25 | 0.18 | 0.23 | 0.03 |
| Somewhat Interested | 0.06 | 0.14 | 0.27 | 0.22 | 0.25 | 0.07 |
| Not Very Interested | 0.05 | 0.10 | 0.24 | 0.22 | 0.28 | 0.11 |
| Nothing | 0.07 | 0.04 | 0.22 | 0.26 | 0.19 | 0.22 |
# Observed Frequencies
chisq.test(MyVoterData$Politics_OR_Current_Events, MyVoterData$Immigration_Should_Be)[6]
$observed
Much Easier Slightly Easier No Change Slightly Harder Much Harder Don't Know
Very Interested 306 563 715 501 655 92
Somewhat Interested 81 181 358 284 325 90
Not Very Interested 13 28 64 60 77 30
Nothing 2 1 6 7 5 6
# Expected Frequencies
chisq.test(MyVoterData$Politics_OR_Current_Events, MyVoterData$Immigration_Should_Be)[7]
$expected
Much Easier Slightly Easier No Change Slightly Harder Much Harder Don't Know
Very Interested 255.834607 491.940674 727.410337 542.216629 675.861573 138.736180
Somewhat Interested 119.154607 229.120674 338.790337 252.536629 314.781573 64.616180
Not Very Interested 24.571685 47.248539 69.864270 52.077303 64.913258 13.324944
Nothing 2.439101 4.690112 6.935056 5.169438 6.443596 1.322697
# Chi-Squared Test
chisq.test(MyVoterData$Politics_OR_Current_Events, MyVoterData$Immigration_Should_Be)
Pearson's Chi-squared test
data: MyVoterData$Politics_OR_Current_Events and MyVoterData$Immigration_Should_Be
X-squared = 136.2, df = 15, p-value < 0.00000000000000022
There is a statisticaly significant association between following politics or current events and feelings toward changing immigration laws. The crosstabs reveal that respondents who are more interested in politics or current events are more likely to believe that immigration should be easier, while respondents who have no interest have the highest proportion of respondents who do not know how they feel toward immigration policies.
kable(MyVoterData %>%
group_by(Politics_OR_Current_Events) %>%
filter(!is.na(Politics_OR_Current_Events)) %>%
summarize(avg_ft_immig = mean(ft_immig_2017, na.rm = TRUE))
) %>%
kable_styling(bootstrap_options = c("striped", "condensed"), full_width = T) %>%
column_spec(1, bold = T)
| Politics_OR_Current_Events | avg_ft_immig |
|---|---|
| Very Interested | 63.45345 |
| Somewhat Interested | 59.21726 |
| Not Very Interested | 55.12607 |
| Nothing | 60.68571 |
The table shows that on average, people who are very interested in politics or current events have the highest feelings toward immigrants; however, people who have no interest have the second highest feelings toward immigrants.