-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcleaned_final_latino_models.R
360 lines (305 loc) · 17.9 KB
/
cleaned_final_latino_models.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
### CLEANED FINAL MODELS
mismatches <- data.frame(zips = c(96704,13456, 10001, 15001, 98104, 33101,
33122, 28304, 56230, 40214, 33327, 84047), num = c(1:12))
cleaned_full <- full_cmps_lat %>% filter(! zips %in% mismatches$zips)
cleaned <- cleaned_full[!cleaned_full$State == 1 | cleaned_full$State == 12,]
cleaned_states <- cleaned %>% filter(State == 3 | State == 5 | State == 32 |
State == 44)
cleaned_states$Remittances_Index <- ifelse(cleaned_states$Remit_Children == 1 |
cleaned_states$Remit_Friends == 1 |
cleaned_states$Remit_Grandparents == 1 |
cleaned_states$Remit_OtherFam == 1 |
cleaned_states$Remit_Parents == 1, 1,
0)
cleaned_states <- cleaned_states %>% mutate(
Remittances_Scale = (Remit_Children + Remit_Friends + Remit_Grandparents +
Remit_OtherFam + Remit_Parents)
)
cleaned_states$border_security_recoded
### Rescaling ------
scaled_cleaned <- cleaned_states %>% mutate(distance_km = rescale(distance_km, to = c(0,1)))
### List of models --------
short_ivs <- list()
short_ivs[[1]] <- c("distance_km","Party_5pt", "linked",
"Education", "age_sqd", "Income")
# short_ivs[[2]] <- c("dist_sqd","Party_5pt", "linked",
# "Education", "Age", "Income")
short_ivs[[2]] <- c("family_birth", "missing_birth", "Party_5pt", "linked",
"Education", "age_sqd", "Income")
# short_ivs[[3]] <- c("Psych_Distance","Party_5pt", "linked",
# "Education", "Age", "Income")
short_ivs[[3]] <- c("distance_km*family_birth", "missing_birth", "linked",
"Party_5pt",
"Education", "age_sqd", "Income")
# short_ivs[[5]] <- c("distance_km*Psych_Distance", "linked", "Party_5pt",
# "Education", "Age", "Income")
short_ivs[[4]] <- c("distance_km*family_birth*Inclusive", "missing_birth", "linked",
"Party_5pt",
"Education", "age_sqd", "Income")
no_nas_ivs <- list()
no_nas_ivs[[1]] <- c("log_dist","Party_5pt", "linked",
"Education", "age_sqd", "Income")
no_nas_ivs[[2]] <- c("family_birth", "missing_birth", "Party_5pt", "linked",
"Education", "age_sqd", "Income")
no_nas_ivs[[3]] <- c("log_dist","family_birth", "missing_birth", "Party_5pt", "linked",
"Education", "age_sqd", "Income")
no_nas_ivs[[4]] <- c("log_dist*family_birth", "missing_birth", "linked", "Party_5pt",
"Education", "age_sqd", "Income")
no_nas_ivs[[5]] <- c("log_dist","family_birth", "missing_birth", "Party_5pt", "linked",
"Education", "age_sqd", "Income", "Inclusive")
no_nas_ivs[[6]] <- c("log_dist*family_birth*Inclusive", "missing_birth", "linked", "Party_5pt",
"Education", "age_sqd", "Income")
# ### Setting up exclusive vs inclusive ------
# incl <- subset(cleaned, subset = cleaned$State == 32 | cleaned$California == 1)
# excl <- subset(cleaned, subset = cleaned$State == 3 | cleaned$Texas == 1)
# ## Excluding the mis-matches
### Survey designs ------------------
new_cmps <- svydesign(id = ~ 1, weights = ~race_weight, data = cleaned_states)
incl <- subset(new_cmps, subset = new_cmps$variables$State == 32 | new_cmps$variables$California == 1)
excl <- subset(new_cmps, subset = new_cmps$variables$State == 3 | new_cmps$variables$Texas == 1)
### Running the models ---------------
### running on full sample to focus on null results -
bin_function(dvs_binomial, short_ivs, new_cmps,new_cmps, "full_sample_bin")
ols_function(dvs_ols, short_ivs, new_cmps, new_cmps,"full_sample_ols")
bin_function(dvs_binomial, short_ivs[1:3], incl, incl, "incl_runs")
bin_function(dvs_binomial, short_ivs[1:3], excl, excl, "excl_runs")
ols_function(dvs_ols, short_ivs[1:3], incl, incl, "incl_runs_sec")
ols_function(dvs_ols, short_ivs[1:3], excl, excl, "excl_runs_sec")
### no nas--- all models except the full sample 3-way interaction
bin_function(dvs_binomial, no_nas_ivs[1:4], incl, incl, "incl_runs_nas")
bin_function(dvs_binomial, no_nas_ivs[1:4], excl, excl, "excl_runs_nas")
ols_function(dvs_ols, no_nas_ivs, incl, incl, "incl_runs_sec_nas")
ols_function(dvs_ols, no_nas_ivs, excl, excl, "excl_runs_sec_nas")
### Clustering standard errors at the state level for the interaction models ----
incl_cmps <- svydesign(id = ~ 1, weights = ~race_weight, data = incl)
excl_cmps <- svydesign(id = ~ 1, weights = ~race_weight, data = excl)
mod1 <- coeftest(incl_runs$Increase_Border_Spending[[3]],
vcov. = vcovCL(incl_runs$Increase_Border_Spending[[3]],
cluster = ~State))
mod2 <- coeftest(excl_runs$Increase_Border_Spending[[3]],
vcov. = vcovCL(excl_runs$Increase_Border_Spending[[3]],
cluster = ~State))
stargazer(mod1, mod2, type = "latex",
dep.var.labels = "Increase Border Spending, Including A Border Wall",
covariate.labels = c("Distance (in km)",
"Acculturation",
"Party",
"Linked Fate",
"Education","Age",
"Income",
"Distance (in km): Acculturation",
"Constant"), column.labels = c("Most Inclusive",
"Least Inclusive"),
column.separate = c(1,1))
### Producing the tables -------------
stargazer(full_sample_bin$Increase_Border_Spending[c(1,2,4,6)], type = "latex",
dep.var.labels = "Increase Border Spending, Including A Border Wall",
covariate.labels = c("Distance Logged",
"Acculturation", "Inclusive", "Missing Acculturation",
"Party",
"Linked Fate",
"Education","Age",
"Income", "Distance (Logged): Acculturation",
"Distance (Logged): Inclusive",
"Acculturation: Inclusive",
"Distance (Logged): Acculturation: Inclusive",
"Constant"))
stargazer(full_sample_ols$border_security_recoded[c(1,2,4,6)], type = "latex",
dep.var.labels = "Increase Border Spending, Including A Border Wall",
covariate.labels = c("Distance (in km)",
"Acculturation", "Inclusive", "Missing Acculturation",
"Party",
"Linked Fate",
"Education","Age",
"Income", "Distance (in km): Acculturation",
"Distance (in km): Inclusive",
"Acculturation: Inclusive",
"Distance (in km): Acculturation: Inclusive",
"Constant"))
stargazer(incl_runs, excl_runs, type = "latex",
dep.var.labels = "Increase Border Spending, Including A Border Wall",
covariate.labels = c("Distance (in km)",
"Acculturation", "Missing Acculturation",
"Party",
"Linked Fate",
"Education","Age",
"Income",
"Distance (in km): Acculturation",
"Constant"), column.labels = c("Most Inclusive",
"Least Inclusive"),
column.separate = c(3,3))
stargazer(incl_runs_sec, excl_runs_sec, type = "latex",
dep.var.labels = "Border Security as a National Priority",
covariate.labels = c("Distance (in km)",
"Acculturation","Missing Acculturation",
"Party",
"Linked Fate",
"Education","Age",
"Income",
"Distance (in km): Acculturation",
"Constant"), column.labels = c("Most Inclusive",
"Least Inclusive"),
column.separate = c(3,3))
### Testing the Border on the Full Sample ----
border_ivs <- list()
border_ivs[[1]] <- c("border_state","Party_5pt", "linked",
"Education", "age_sqd", "Income")
# short_ivs[[2]] <- c("dist_sqd","Party_5pt", "linked",
# "Education", "Age", "Income")
border_ivs[[2]] <- c("family_birth", "missing_birth", "Party_5pt", "linked",
"Education", "age_sqd", "Income")
# short_ivs[[3]] <- c("Psych_Distance","Party_5pt", "linked",
# "Education", "Age", "Income")
border_ivs[[3]] <- c("inclusivity*family_birth", "missing_birth", "linked",
"Party_5pt",
"Education", "age_sqd", "Income")
# short_ivs[[5]] <- c("border_state*Psych_Distance", "linked", "Party_5pt",
# "Education", "Age", "Income")
border_ivs[[4]] <- c("border_state*family_birth*inclusivity", "missing_birth", "linked",
"Party_5pt",
"Education", "age_sqd", "Income")
full_cmps_survey <- svydesign(id = ~ 1, weights = ~race_weight, data = full_cmps_latino)
bin_function(dvs_binomial, border_ivs, full_cmps_survey, full_cmps_survey, "full_border_bin")
ols_function(dvs_ols, border_ivs, full_cmps_survey, full_cmps_survey,"full_border_ols")
## Making the Table
stargazer(full_border_bin, type = "latex",
dep.var.labels = "Increase Border Spending, Including A Border Wall",
covariate.labels = c("Border State",
"Acculturation",
"Missing Acculturation",
"Party",
"Linked Fate",
"Education","Age",
"Income",
"Border State: Acculturation",
"Constant"))
stargazer(full_border_ols, type = "latex",
dep.var.labels = "Make Border Security a National Priority",
covariate.labels = c("Border State",
"Acculturation",
"Missing Acculturation",
"Party",
"Linked Fate",
"Education","Age",
"Income",
"Border State: Acculturation",
"Constant"))
### Testing the individual vars for the index -----
index_ivs <- list()
index_ivs[[1]] <- c("distance_km*Spanish", "Party_5pt", "linked",
"Education", "Age", "Income")
index_ivs[[2]] <- c("distance_km*Imm_Comm","Party_5pt", "linked",
"Education", "Age", "Income")
index_ivs[[3]] <- c("distance_km*Psych_Distance", "linked", "Party_5pt",
"Education", "Age", "Income")
bin_function(dvs_binomial, index_ivs, incl_cmps, incl, "incl_runs_index")
bin_function(dvs_binomial, index_ivs, excl_cmps, excl, "excl_runs_index")
ols_function(dvs_ols, index_ivs, incl_cmps, incl, "incl_runsind_sec")
ols_function(dvs_ols, index_ivs, excl_cmps, excl, "excl_runsind_sec")
#### Tables for Appendix ----
stargazer(incl_runs_index, excl_runs_index, type = "latex",
dep.var.labels = "Increase Border Spending, Including A Border Wall",
covariate.labels = c("Distance (in km)",
"Spanish",
"Part of Immigrant Community",
"Acculturation Index (Generation)",
"Party",
"Linked Fate",
"Education","Age",
"Income",
"Distance (in km): Spanish",
"Distance (in km): Part of Immigrant Community",
"Distance (in km): Psych. Distance",
"Constant"), column.labels = c("Most Inclusive",
"Least Inclusive"),
column.separate = c(3,3))
stargazer(incl_runsind_sec, excl_runsind_sec, type = "latex",
dep.var.labels = "Make Border Security a National Priority",
covariate.labels = c("Distance (in km)",
"Spanish",
"Part of Immigrant Community",
"Acculturation Index (Generation)",
"Party",
"Linked Fate",
"Education","Age",
"Income",
"Distance (in km): Spanish",
"Distance (in km): Part of Immigrant Community",
"Distance (in km): Generation",
"Constant"), column.labels = c("Most Inclusive",
"Least Inclusive"),
column.separate = c(3,3))
#### Testing other specifications for distance --------
alt_ivs <- list()
alt_ivs[[1]] <- c("I(log(distance_km))","Party_5pt", "linked",
"Education", "age_sqd", "Income")
alt_ivs[[2]] <- c("dist_sqd","Party_5pt", "linked",
"Education", "age_sqd", "Income")
# alt_ivs[[3]] <- c("psych_dist_lang","Party_5pt", "linked",
# "Education", "age_sqd", "Income")
alt_ivs[[3]] <- c("I(log(distance_km))", "psych_dist_lang", "Party_5pt", "linked",
"Education", "age_sqd", "Income")
alt_ivs[[4]] <- c("I(log(distance_km))*psych_dist_lang", "linked", "Party_5pt",
"Education", "age_sqd", "Income")
alt_ivs[[5]] <- c("dist_sqd*psych_dist_lang", "linked", "Party_5pt",
"Education", "age_sqd", "Income")
# running the models
bin_function(dvs_binomial, alt_ivs, incl_cmps, incl, "incl_runs_alt")
bin_function(dvs_binomial, alt_ivs, excl_cmps, excl, "excl_runs_alt")
ols_function(dvs_ols, alt_ivs, incl_cmps, incl, "incl_runs_sec_alt")
ols_function(dvs_ols, alt_ivs, excl_cmps, excl, "excl_runs_sec_alt")
##### Appendix Tables ------
stargazer(incl_runs_alt, excl_runs_alt, type = "latex",
dep.var.labels = "Most Inclusive - Increase Border Spending, Including A Border Wall",
covariate.labels = c("Distance (in km) Logged",
"Distance Sqd",
"Acculturation",
"Party",
"Linked Fate",
"Education","Age",
"Income",
"Distance (in km) Logged: Acculturation",
"Distance (in km) Sqd: Acculturation",
"Constant"),column.labels = c("Most Inclusive",
"Least Inclusive"),
column.separate = c(5,5))
stargazer(incl_runs_sec_alt, excl_runs_sec_alt, type = "latex",
dep.var.labels = "Most Inclusive - Make Border Security a National Priority",
covariate.labels = c("Distance (in km) Logged",
"Distance Sqd",
"Acculturation",
"Party",
"Linked Fate",
"Education","Age",
"Income",
"Distance (in km) Logged: Acculturation",
"Distance (in km) Sqd: Acculturation",
"Constant"),column.labels = c("Most Inclusive",
"Least Inclusive"),
column.separate = c(5,5))
##### Scaled Runs for Presentation ----
new_cmps_scaled <- svydesign(id = ~ 1, weights = ~race_weight, data = scaled_cleaned)
incl_scaled <- subset(new_cmps_scaled,
subset = new_cmps_scaled$variables$State == 32 | new_cmps_scaled$variables$California == 1)
excl_scaled <- subset(new_cmps_scaled, subset = new_cmps_scaled$variables$State == 3 | new_cmps_scaled$variables$Texas == 1)
bin_function(dvs_binomial, short_ivs, new_cmps_scaled,new_cmps_scaled, "full_sample_bin_re")
ols_function(dvs_ols, short_ivs, new_cmps_scaled, new_cmps_scaled,"full_sample_ols_re")
bin_function(dvs_binomial, short_ivs[1:3], incl_scaled, incl_scaled, "incl_runs_re")
bin_function(dvs_binomial, short_ivs[1:3], excl_scaled, excl_scaled, "excl_runs_re")
ols_function(dvs_ols, short_ivs[1:3], incl_scaled, incl_scaled, "incl_runs_sec_re")
ols_function(dvs_ols, short_ivs[1:3], excl_scaled, excl_scaled, "excl_runs_sec_re")
##### LPM Results Border Spending -----
ols_function(dvs_binomial, short_ivs[1:3], incl, incl, "incl_runs_ols")
ols_function(dvs_binomial, short_ivs[1:3], excl, excl, "excl_runs_ols")
stargazer(incl_runs, excl_runs, type = "latex",
dep.var.labels = "Increase Border Spending, Including A Border Wall",
covariate.labels = c("Distance (in km)",
"Acculturation", "Missing Acculturation",
"Party",
"Linked Fate",
"Education","Age",
"Income",
"Distance (in km): Acculturation",
"Constant"), column.labels = c("Most Inclusive",
"Least Inclusive"),
column.separate = c(3,3))