Assignment 2: Comparative analyses of immigration enforcement

This assignment is asking you to analyze real-world data on immigrant arrests in the United States The objective of the assignment is to: 1) engage in serious real-world analysis of actual data; 2) create professional-grade plots of data; 3) implement statistical analysis permitting the testing of some hypotheses, and most importantly, 4) interpretation of results. Herein, I give you shell code that you will need to elaborate on in order to produce your analysis. It is assumed that your familiarity with R is much higher now than on the first assignment. It is assumed, and required, that the student independently answers these questions. You may work together on code, but the intepretation of the analysis must be your own interpretation. Exact wording of answers in assignments from two or more students will be viewed as possible evidence of academic dishonesty. Understand further that on quizzes, you will be asked to provide interpretations of similar kinds of analyses and will not have the ability to work with other students on those quizzes; hence, you should get in the practice of writing in your own voice. You should do this assignment using R Markdown and submit the RMD file and the resultant HTML file to Canvas. The due date for this assignment is due on Canvas May 22nd .

Preliminaries

See the code below. You will need to set the working directory to correspond to your computer (so all the output will be saved there) and you need to access the tidyverse library in order to reproduce this RMD file (and execute yours).

knitr::opts_chunk$set(echo = TRUE)

options(scipen = 999)  # turns off scientific notations like 1e+40

rm(list=ls(all=TRUE))

#Below, this is a working directory for my computer.
#Change the contents within the parentheses to correspond
#to YOUR COMPUTER!!!!  Remember: you need the quotes ("....")

setwd("C:/Users/erick_o861k9z/OneDrive/Desktop/POL 51")
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.0     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

Data: ICE arrest data in the Obama Administration

I have assembled a dataset based on Immigration and Customs Enforcement (ICE)/Department of Homeland Security (DHS) statistics on arrests of undocumented immigrants. The data are based on monthly reports starting in October 2008 to June 2018. Thus, the entirety of the Obama Administration is included in this data base (2009-2017). The source of the data is from TRAC (https://trac.syr.edu/), who compiled the data from DHS/ICE reports.

arrests="https://raw.githubusercontent.com/mightyjoemoon/POL51/main/ICEarrests.csv"

arrests<-read_csv(url(arrests))
## Rows: 117 Columns: 11
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): Arrest_Month, President, PresTermYear
## dbl (8): All, Federal_Incarceration, State_Incarceration, Local_Incarceratio...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
summary(arrests)
##  Arrest_Month            All        Federal_Incarceration State_Incarceration
##  Length:117         Min.   : 8005   Min.   :1525          Min.   : 741       
##  Class :character   1st Qu.:12355   1st Qu.:1889          1st Qu.: 917       
##  Mode  :character   Median :17060   Median :2163          Median :1149       
##                     Mean   :17830   Mean   :2179          Mean   :1358       
##                     3rd Qu.:23996   3rd Qu.:2441          3rd Qu.:1802       
##                     Max.   :28767   Max.   :3252          Max.   :3320       
##                                                                              
##  Local_Incarceration  287gProgram   Community_Arrest     Other     
##  Min.   : 2714       Min.   :   5   Min.   :1656     Min.   : 360  
##  1st Qu.: 5093       1st Qu.: 349   1st Qu.:2694     1st Qu.: 621  
##  Median : 8424       Median : 824   Median :3034     Median : 987  
##  Mean   : 8657       Mean   :1229   Mean   :3237     Mean   :1170  
##  3rd Qu.:12843       3rd Qu.:2000   3rd Qu.:3715     3rd Qu.:1555  
##  Max.   :15283       Max.   :3588   Max.   :6001     Max.   :2791  
##                                                                    
##   President           ObamaTerm    PresTermYear      
##  Length:117         Min.   :1.00   Length:117        
##  Class :character   1st Qu.:1.00   Class :character  
##  Mode  :character   Median :1.00   Mode  :character  
##                     Mean   :1.49                     
##                     3rd Qu.:2.00                     
##                     Max.   :2.00                     
##                     NA's   :21

Task 1: Time-series plot of arrests over time (50 points)

Create a professional-grade time-series plot of all arrests over the full time frame. Below is shell code that can be modified. Include your code in the open chunk below my shell plot. Note that you can choose to connect the dates with a line or not. It might look better without a line and simply report the scatterplot.

#This code should be left alone
arrests$Date<-lubridate::ym(arrests$Arrest_Month)
plot(arrests$All~arrests$Date)

plot(arrests$All~arrests$Date,
     main="Ice Arrests under the Obama Administration",
     frame = FALSE,
     xlab="Year",
     ylab="Number of Arrests",
     pch=19,
     col="skyblue")

Task 2: Interpretation (50 points)

In one succinct paragraph, provide an interpretation of this plot. What do we learn about immigrant arrests over time? What pattern is there?

Over the course of the Obama administration, the number of immigrants arrested goes from very high to much lower.From when Obama came into office in 2009, the average arrests was up in the 25000, and dipped down below 10000 in the year 2016, before rising again to 15000 in 2018. So we see that Obama came in implementing strong ICE deportation enforcement from the moment he came into office. Less immigrants were caught as Obama progressed in his terms in office. And as Obama left office, we can see how the number immigrants being arrested rises again, presumably from another president again enforcing more drastic anti immigration measures. The pattern we can see here is that presidents tend to enter office presumably after they promised to increase the amount of border protection, and deliver.

Task 3: Time-series plot of the use of 287g Program (50 points)

Create a professional-grade time-series plot of arrests made under the 287g Program. Below is shell code that can be modified. Include your code in the open chunk below my shell plot. Note that you can choose to connect the dates with a line or not. It might look better without a line and simply report the scatterplot.

plot(arrests$"287gProgram"~arrests$Date)

plot(arrests$"287gProgram"~arrests$Date,
     main = "Number of arrests made under the 287g Program",
     xlab= "year",
     ylab="Immigrants Arrested",
     pch=19,
     col="skyblue")

Task 4: Interpretation (100 points)

In the first pargraph, explain what the 287g Program is, when it first started, and how it works. In real research, the researcher needs to clearly explain the data they are interpreting. In the second plot, provide a substantive interpretation of what the data show. By way of background, 287g Agreements were not widely used until Obama took office. ICE during the first term of the Obama Presidency made extensive use of 287g Agreements but began to curtail the use of them in the second term. Do the data reflect this?

287g Program is a Section 287(g) of Immigration and Nationality Act of 1996. This program legitimates local and state agencies using their resources to arrest individuals based on suspicion of being undocumented. This power comes from Memorandum of Agreements with ICE and is often unchecked and used to profile BIPOC. It rose to prominence and widespread use during Obama’s first term of presidency. 287(g) received its first bit of federal funding just prior in 2006. During Trump’s term as president, the number of MOAs grew significantly. Now, there are 142 agreements giving local law enforcement unfettered apprehension power over suspicion on undocumented status. Most of these agreements are in Texas.

During President Obama’s second term, there was a sharp decrease in the number of arrests made with the 287G program. In his first term, there was a clear upward trend in the number of arrests till near 2012. 2012 was the start of his second term, and the number of arrests began decreasing on the time plot. The plot shows that during Obama’s first term, starting in 2008, ICE used 287G extensively and more than ever before. This suddenly changed after 2012 and there was a clear downward trend in the number of arrests beginning Obama’s second term. This provides evidence for the fact that ICE used 287G heavily during Obama’s first term and curtailed it during his second term. If we look into political motives there could be a possible explanation behind the phenomena the graph shows. We can’t say there is a causal relationship, but it would make sense for Obama to be more harsh towards immigrants during his first term to make himself look more electable towards Republicans. Republicans tend to have anti-immigrant, especially undocumented immigrant, platforms. After winning reelection and securing his final term, it would make sense that he aligns himself with the more Democrat viewpoint of being sympathetic towards undocumented immigrants.

Task 5: Boxplots of total arrests and 287g Agreements (100 points)

Create 4 boxplots of total arrests and arrests under the 287g Agreement “controlling” for the term of the Obama Presidency. There is a variable in the data set called “ObamaTerm” and is coded “1” for the first term (2009-2013) and “2” for the second term (2013-2017). Below is shell code to do this. In addition to the box plot, include code to plot the means in each plot. Include your code in the open chunk below my shell plot.

#Step 1: Compute means for all arrests and 287g arrests by term
#of the Obama Presidency

#To help get you started, this will get you the mean number of arrests in Obama's first term:

all_Obama1<-mean(arrests$All[arrests$ObamaTerm==1], na.rm=TRUE)
all_Obama2<-mean(arrests$All[arrests$ObamaTerm==2], na.rm=TRUE)

g287_Obama1<-mean(arrests$"287gProgram"[arrests$ObamaTerm==1], na.rm=TRUE)
g287_Obama2<-mean(arrests$"287gProgram"[arrests$ObamaTerm==2], na.rm=TRUE)


#Extend this logic to obtain the other 3 means. 
#The line of code below will coerce R into putting two plots on a in a single plot space

par(mfrow=c(1,2))

#Shell code to obtain the boxplots
boxplot(arrests$All~arrests$ObamaTerm,
        names=c("First term", "Second term"))
#Shell code to put means in the boxplots
points(c(all_Obama1, all_Obama1), pch=19, col=c("black", "black"))

boxplot(arrests$"287gProgram"~arrests$ObamaTerm)

par(mfrow=c(1,2))

boxplot(arrests$All~arrests$ObamaTerm,
        names=c("First term", "Second term"),
        main="Arrests Under Obama Adminsitration",
        xlab="Term",
        ylab="Number Arrested",
        col="skyblue")

points(c(all_Obama1, all_Obama2), pch=19, col=c("black", "black"))

boxplot(arrests$"287gProgram"~arrests$ObamaTerm,
        names=c("First term", "Second term"),
        main= "Arrests Under the 287g program",
        xlab="Term",
        ylab="Number Arrested",
        col="red")
points(c(g287_Obama1, g287_Obama2), pch=19, col=c("black", "black"))

par(mfrow=c(1,1))

Task 6: Interpretation (50 points)

Is there evidence that total arrests and 287G arrests declined over the Obama Presidency? Explain in a well-written paragraph what this plot shows.

The boxplots show that the total number of arrests and the number of 287G arrests declined over Obama’s Presidency. Both the total and 287G boxplots have lower medians during the 2nd term. This means the direct middle value for both categories of arrests is less during the 2nd term compared to the first. Additionally, the quartile values (1st and 3rd both) are lower during the 2nd term compared to the 1st term for both boxplot sets. That means the upper and lower 25% of values are less during the 2nd term for both all arrests and 287G arrests. The highest value is also lower on both boxplots in the 2nd term, meaning that the maximum number of total and 287G arrests during the 2nd term is never higher than the maximum number of arrests during the 1st term. The whiskers are also shorter in both boxplots correlating to the 2nd term. This means there is more consistency and less outliers in Obama’s 2nd term. That means there is less variation in the amount of arrests which would mean the amount of arrests is consistently lower. That means there is an unvarying, consistently low number of arrests compared to Obama’s 1st term. In conclusion, the boxplots prove that Obama’s 2nd term saw a decrease in the number of arrests compared to his 1st term.

Task 7: Difference-in-means test (50 points)

Using a difference-in-means test (two-group t-test), can we conclude there is a significant difference in total arrests and 287G arrests between Obama’s first and second terms? Provide the code in the chunk below and then provide a clear interpretation as to what the statistical tests reveal. Assume the alternative hypothesis is that arrests should be lower in the second term compared to the first term, or equivalently, arrests should be higher in the first term compared to the second term.

t.test(arrests$All[arrests$ObamaTerm==1],arrests$All[arrests$ObamaTerm==2])
## 
##  Welch Two Sample t-test
## 
## data:  arrests$All[arrests$ObamaTerm == 1] and arrests$All[arrests$ObamaTerm == 2]
## t = 18.984, df = 82.26, p-value < 0.00000000000000022
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  10934.02 13493.64
## sample estimates:
## mean of x mean of y 
##  24538.49  12324.66
t.test(arrests$"287gProgram"[arrests$ObamaTerm==1],arrests$"287gProgram"[arrests$ObamaTerm==2])
## 
##  Welch Two Sample t-test
## 
## data:  arrests$"287gProgram"[arrests$ObamaTerm == 1] and arrests$"287gProgram"[arrests$ObamaTerm == 2]
## t = 7.7742, df = 64.607, p-value = 0.00000000007622
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  1004.596 1699.286
## sample estimates:
## mean of x mean of y 
## 2018.8776  666.9362

The null hypothesis (H0), there is no difference in means between the average number of 287G arrests in Obama’s first and second term. The alternative hypothesis (H1), there is a difference in means between the two term averages. The p-value is the probability of observing the data assuming the null hypothesis is true. If the p-value is less than 0.05, we reject the null hypothesis. The p-value is much smaller than 0.05 (0.00000000007622). Based on this low p-value and high t-score, 7.7742, we conclude that the difference in means is statistically significant. This means that there is near certainty that the average number of 287G arrests in Obama’s first term is more than the average number of arrests in Obama’s second term. We do not have convincing evidence that the mean number of 287G arrests is the same throughout the two terms of Obama’s presidency.

Task 8: Difference-in-means test (100 points)

There is a variable in the dataset called “PresTermYear” named such that it records each year of the Presidency for a given President. Tabularly, this variable looks like:

table(arrests$PresTermYear)
## 
##  Bush8 Obama1 Obama2 Obama3 Obama4 Obama5 Obama6 Obama7 Obama8 Trump1 Trump2 
##      3     12     12     12     12     12     12     12     12     12      6

Given this, we can identify each year of each President’s time-in-office. For this task, I want you to evaluate the following claim: Upon entry into office, Trump pledged to ramp up immigration enforcement, including restarting the widespread use of the 287g Program and increasing the number of arrrests generally. A natural question to explore is whether not we observe a significant increase in arrests in Trump’s first year in office compared to Obama’s last term in office. Conduct a two-group t-test to assess this claim for total arrests and 287g arrests. Fully and substantively interpret what the results show.

#Helping you out: Create a dummy variable for the last 12 months 
#of the Obama Presidency and the first 12 months of the Trump Presidency (Obama8 implies the "8th" year of Obama's Presidency and Trump1 implies the "1st" year of Trump's Presidency.)

arrests$bodt[arrests$PresTermYear == "Obama8"] <- 1
## Warning: Unknown or uninitialised column: `bodt`.
arrests$bodt[arrests$PresTermYear == "Trump1"] <- 2
t.test(arrests$All[arrests$bodt==1],arrests$All[arrests$bodt==2])
## 
##  Welch Two Sample t-test
## 
## data:  arrests$All[arrests$bodt == 1] and arrests$All[arrests$bodt == 2]
## t = -8.8265, df = 14.932, p-value = 0.0000002605
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -4668.441 -2851.726
## sample estimates:
## mean of x mean of y 
##  9166.333 12926.417
t.test(arrests$"287gProgram"[arrests$bodt==1],arrests$"287gProgram"[arrests$bodt==2])
## 
##  Welch Two Sample t-test
## 
## data:  arrests$"287gProgram"[arrests$bodt == 1] and arrests$"287gProgram"[arrests$bodt == 2]
## t = -10.959, df = 18.424, p-value = 0.000000001659
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -461.2652 -313.0681
## sample estimates:
## mean of x mean of y 
##  303.1667  690.3333

President Trump’s platform was rooted heavily on increasing immigration enforcement against undocumented migrants. He started the revitalization of the 287(g) program. To evaluate how quickly he enacted these changes, we can compare the number of 287(g) arrests during Trump’s first year in office with those from the last year of President Obama’s administration. This comparison will highlight the impact and immediacy of Trump’s policy implementation. The null hypothesis (H0) is that there is no difference in means between the average number of 287G arrests in Trump’s term and Obama’s second term. The alternative hypothesis (H1) is that there is a difference in means between the two term averages. The p-value is the probability of observing the data assuming the null hypothesis is true. If the p-value is less than 0.05, we reject the null hypothesis. In this case, the p-value is much smaller than 0.05 (0.0000002605). Based on this low p-value and high (absolute value) t-score, -8.8265, we conclude that the difference in means is statistically significant. This means that there is near certainty that the average number of 287G arrests in Trump’s first term is more than the average number of 287G arrests in Obama’s second term. We do not have convincing evidence that the mean number of arrests is the same throughout the terms of the two Presidents.

Task 9: Repeat task (50 points)

Repeat task 8 but this time, compare the first year of Trump’s Presidency to the 4th year of Obama’s Presidency (i.e. the final year of Obama’s first term). In the context of immigration enforcement, which President seemed “more active” in terms of immigrant arrests? Provide your code and interpretation below.

#Insert code for Task 9 here

arrests$bodt[arrests$PresTermYear == "Obama4"] <- 1

arrests$bodt[arrests$PresTermYear == "Trump1"] <- 2


t.test(arrests$All[arrests$bodt==1],arrests$All[arrests$bodt==2])
## 
##  Welch Two Sample t-test
## 
## data:  arrests$All[arrests$bodt == 1] and arrests$All[arrests$bodt == 2]
## t = 1.8888, df = 26.404, p-value = 0.06995
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -239.9153 5726.9986
## sample estimates:
## mean of x mean of y 
##  15669.96  12926.42
t.test(arrests$"287gProgram"[arrests$bodt==1],arrests$"287gProgram"[arrests$bodt==2])
## 
##  Welch Two Sample t-test
## 
## data:  arrests$"287gProgram"[arrests$bodt == 1] and arrests$"287gProgram"[arrests$bodt == 2]
## t = 2.5272, df = 24.26, p-value = 0.01842
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##   84.57241 835.76092
## sample estimates:
## mean of x mean of y 
## 1150.5000  690.3333

President Trump’s platform was rooted heavily on increasing immigration enforcement against undocumented migrants. President Obama was vying for reelection and swaying Republican voters. Both Presidents had staunch anti-undocumented migrant platforms during their first terms. To evaluate who had more active immigrant policy, we can compare 287(g) arrests during Trump’s first year in office with those from the first year of President Obama’s administration. The null hypothesis (H0) is that there is no difference in means between the average number of 287G arrests in Obama’s first and second. The alternative hypothesis (H1) is that there is a difference in means between the two term averages. The p-value is the probability of observing the data assuming the null hypothesis is true. If the p-value is less than 0.05, we reject the null hypothesis. In this case, the p-value is larger than 0.05 (0.06995). Based on this low p-value and high (absolute value) t-score, 1.8888, we conclude that the difference in means is statistically insignificant. This means that there is no convincing evidence that the average number of 287G arrests in Trump’s first term is more than the average number of 287G arrests in Obama’s first term. We have convincing evidence that the number of arrests is similar throughout the terms of the two Presidents.

Task 10: Regression (30 points)

Below is code to estimate a very simple linear regression model. For this task, estimate the model, create a plot from the model, and provide a brief short paragraph attempt at interpretation of the plot.

regmodel<-lm(All~PresTermYear, data=arrests)
summary(regmodel)
## 
## Call:
## lm(formula = All ~ PresTermYear, data = arrests)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4807.6  -960.8   149.3  1009.7  3960.4 
## 
## Coefficients:
##                    Estimate Std. Error t value             Pr(>|t|)    
## (Intercept)         22907.7      984.8  23.260 < 0.0000000000000002 ***
## PresTermYearObama1   2547.4     1101.1   2.314               0.0226 *  
## PresTermYearObama2   2660.4     1101.1   2.416               0.0174 *  
## PresTermYearObama3   2568.2     1101.1   2.332               0.0216 *  
## PresTermYearObama4   -734.1     1101.1  -0.667               0.5064    
## PresTermYearObama5  -5453.9     1101.1  -4.953  0.00000277417035038 ***
## PresTermYearObama6  -9351.3     1101.1  -8.493  0.00000000000013535 ***
## PresTermYearObama7 -13286.3     1101.1 -12.067 < 0.0000000000000002 ***
## PresTermYearObama8 -13741.3     1101.1 -12.480 < 0.0000000000000002 ***
## PresTermYearTrump1  -9981.3     1101.1  -9.065  0.00000000000000713 ***
## PresTermYearTrump2  -9479.5     1206.2  -7.859  0.00000000000339307 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1706 on 106 degrees of freedom
## Multiple R-squared:  0.9391, Adjusted R-squared:  0.9334 
## F-statistic: 163.5 on 10 and 106 DF,  p-value: < 0.00000000000000022
#install.packages("sjPlot")
library(sjPlot)
## Install package "strengejacke" from GitHub (`devtools::install_github("strengejacke/strengejacke")`) to load all sj-packages at once!
plot_model(regmodel, type = "pred", terms = c("PresTermYear"), ci.lvl = .95, 
title="Arrests by Year",
axis.title=c("Year by President", "Number of arrests"))

Looking at the graph, we can see that at the end of the Bush administration the number arrests was already at a pretty high number, around 23000. Infamously Obama’s first three terms had the highest number of arrests, averaging over 24000 arrests per term. Over the rest of his 5 terms the amount of arrests the number of arrests stoops down to below 10000 arrests by his very last term.