-
Notifications
You must be signed in to change notification settings - Fork 0
/
outcomes-analysis.R
158 lines (137 loc) · 7.06 KB
/
outcomes-analysis.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
#######################################################################################################
############################################ IMPORT ###################################################
#######################################################################################################
# Set working directory
setwd("~/Desktop/sdut-asylum")
# Import asylum-case.csv
library(readr)
cases <- read_csv("asylum-cases.csv", col_types = cols(CIRCUIT_COURT = col_character(),
IDNCASE = col_character(),
IDNPROCEEDING = col_character(),
X1 = col_skip()))
View(cases)
# Row count == 146348
#######################################################################################################
########################################### ANALYSIS ##################################################
#######################################################################################################
# The following calculates outcomes depending on variables that may impact an asylum seeker's case
## Findings were used in interactive chart published in Part 2 of "Returned" series
# Calculate outcomes with no variables
library(dplyr)
library(scales)
outcomes_overall <- cases %>%
summarise(ORDERED_DEPORTED = mean(ORDERED_DEPORTED),
RELIEF_GRANTED = mean(RELIEF_GRANTED),
VOLUNTARY_DEPARTURE = mean(VOLUNTARY_DEPARTURE),
OTHER_OUTCOME = mean(OTHER_OUTCOME),
COUNT = n()) %>%
mutate(ORDERED_DEPORTED = percent(ORDERED_DEPORTED, .1),
RELIEF_GRANTED = percent(RELIEF_GRANTED, .1),
VOLUNTARY_DEPARTURE = percent(VOLUNTARY_DEPARTURE, .1),
OTHER_OUTCOME = percent(OTHER_OUTCOME, .1))
# Calculate outcomes by nationality, only including top 10 countries with most cases
# Determine 10 countries with most cases
nations_count <- table(cases$NATIONALITY) %>% as.data.frame()
# Create new table of the top 10 countries with most cases
nations_list <- nations_count %>% filter(Freq > 2208)
# Filter cases df to countries that appear in final_nations
nations_final <- cases[cases$NATIONALITY %in% nations_list$Var1, ]
# Row count == 128,928
# Calculate outcomes by top 10 most frequent nationalities
outcomes_nationality <- nations_final %>%
group_by(NATIONALITY) %>%
summarise(ORDERED_DEPORTED = mean(ORDERED_DEPORTED),
RELIEF_GRANTED = mean(RELIEF_GRANTED),
VOLUNTARY_DEPARTURE = mean(VOLUNTARY_DEPARTURE),
OTHER_OUTCOME = mean(OTHER_OUTCOME),
COUNT = n()) %>%
mutate(ORDERED_DEPORTED = percent(ORDERED_DEPORTED, .1),
RELIEF_GRANTED = percent(RELIEF_GRANTED, .1),
VOLUNTARY_DEPARTURE = percent(VOLUNTARY_DEPARTURE, .1),
OTHER_OUTCOME = percent(OTHER_OUTCOME, .1))
remove(nations_count, nations_list, nations_final)
# Calculate outcomes by circuit court
outcomes_circuit <- cases %>%
group_by(CIRCUIT_COURT) %>%
summarise(ORDERED_DEPORTED = mean(ORDERED_DEPORTED),
RELIEF_GRANTED = mean(RELIEF_GRANTED),
VOLUNTARY_DEPARTURE = mean(VOLUNTARY_DEPARTURE),
OTHER_OUTCOME = mean(OTHER_OUTCOME),
COUNT = n()) %>%
mutate(ORDERED_DEPORTED = percent(ORDERED_DEPORTED, .1),
RELIEF_GRANTED = percent(RELIEF_GRANTED, .1),
VOLUNTARY_DEPARTURE = percent(VOLUNTARY_DEPARTURE, .1),
OTHER_OUTCOME = percent(OTHER_OUTCOME, .1))
# Calculate outcomes by representation or no representation
## 0 = The asylum seeker did not have legal representation
## 1 = The asylum seeker had legal representation
outcomes_representation <- cases %>%
group_by(REPRESENTED) %>%
summarise(ORDERED_DEPORTED = mean(ORDERED_DEPORTED),
RELIEF_GRANTED = mean(RELIEF_GRANTED),
VOLUNTARY_DEPARTURE = mean(VOLUNTARY_DEPARTURE),
OTHER_OUTCOME = mean(OTHER_OUTCOME),
COUNT = n()) %>%
mutate(ORDERED_DEPORTED = percent(ORDERED_DEPORTED, .1),
RELIEF_GRANTED = percent(RELIEF_GRANTED, .1),
VOLUNTARY_DEPARTURE = percent(VOLUNTARY_DEPARTURE, .1),
OTHER_OUTCOME = percent(OTHER_OUTCOME, .1))
# Calculate outcomes by custody status
outcomes_custody <- cases %>%
group_by(CUSTODY) %>%
summarise(ORDERED_DEPORTED = mean(ORDERED_DEPORTED),
RELIEF_GRANTED = mean(RELIEF_GRANTED),
VOLUNTARY_DEPARTURE = mean(VOLUNTARY_DEPARTURE),
OTHER_OUTCOME = mean(OTHER_OUTCOME),
COUNT = n()) %>%
mutate(ORDERED_DEPORTED = percent(ORDERED_DEPORTED, .1),
RELIEF_GRANTED = percent(RELIEF_GRANTED, .1),
VOLUNTARY_DEPARTURE = percent(VOLUNTARY_DEPARTURE, .1),
OTHER_OUTCOME = percent(OTHER_OUTCOME, .1))
# Calculate outcomes by the fiscal year the case was decided
outcomes_year <- cases %>%
group_by(COMP_FISCAL_YEAR) %>%
summarise(ORDERED_DEPORTED = mean(ORDERED_DEPORTED),
RELIEF_GRANTED = mean(RELIEF_GRANTED),
VOLUNTARY_DEPARTURE = mean(VOLUNTARY_DEPARTURE),
OTHER_OUTCOME = mean(OTHER_OUTCOME),
COUNT = n()) %>%
mutate(ORDERED_DEPORTED = percent(ORDERED_DEPORTED, .1),
RELIEF_GRANTED = percent(RELIEF_GRANTED, .1),
VOLUNTARY_DEPARTURE = percent(VOLUNTARY_DEPARTURE, .1),
OTHER_OUTCOME = percent(OTHER_OUTCOME, .1))
# Calculate outcomes for cases with a judge who used to work for ICE/INS
## 0 = The asylum seeker was assigned a judge who did not previously work for ICE/INS
## 1 = The asylum seeker was assigned a judge who previously worked for ICE/INS
outcomes_ice <- cases %>%
group_by(ICE_OR_INS) %>%
summarise(ORDERED_DEPORTED = mean(ORDERED_DEPORTED),
RELIEF_GRANTED = mean(RELIEF_GRANTED),
VOLUNTARY_DEPARTURE = mean(VOLUNTARY_DEPARTURE),
OTHER_OUTCOME = mean(OTHER_OUTCOME),
COUNT = n()) %>%
mutate(ORDERED_DEPORTED = percent(ORDERED_DEPORTED, .1),
RELIEF_GRANTED = percent(RELIEF_GRANTED, .1),
VOLUNTARY_DEPARTURE = percent(VOLUNTARY_DEPARTURE, .1),
OTHER_OUTCOME = percent(OTHER_OUTCOME, .1))
# Calculate outcomes by base city (court location), only including top 15 with most cases
# Determine top 15
base_count <- table(cases$BASE_CITY) %>% as.data.frame()
# Create new table of the top 15 base cities
base_list <- base_count %>% filter(Freq > 2415)
# Filter cases df to base cities that appear in base_list
base_final <- cases[cases$BASE_CITY %in% base_list$Var1, ]
# Row count == 97,793
# Calculate outcomes for top 15 base cities
outcomes_base <- base_final %>%
group_by(BASE_CITY) %>%
summarise(ORDERED_DEPORTED = mean(ORDERED_DEPORTED),
RELIEF_GRANTED = mean(RELIEF_GRANTED),
VOLUNTARY_DEPARTURE = mean(VOLUNTARY_DEPARTURE),
OTHER_OUTCOME = mean(OTHER_OUTCOME),
COUNT = n()) %>%
mutate(ORDERED_DEPORTED = percent(ORDERED_DEPORTED, .1),
RELIEF_GRANTED = percent(RELIEF_GRANTED, .1),
VOLUNTARY_DEPARTURE = percent(VOLUNTARY_DEPARTURE, .1),
OTHER_OUTCOME = percent(OTHER_OUTCOME, .1))
remove(base_count, base_list, base_final)