What factors will affect the probability of people being killed during interactions with police?

In the following analysis, we will use data to do analysis and answer this question.

tidycensus::census_api_key(Sys.getenv("census_api"))
library(tmap)
library(jsonlite)
library(tidyverse)
library(tidycensus)
library(scales)
library(ggplot2)
library(sf)

Data Preparation

# Clean Fatal Encounters data
data <- read.csv("data.csv")
data$Latitude = as.numeric(data$Latitude)
data$Longitude = as.numeric(data$Longitude)

data <- data %>% filter(!(Race.with.imputations %in% c("european-American/White", "HIspanic/Latino"))) %>%
    filter(!is.na(Race.with.imputations) & nchar(trimws(Race.with.imputations)) > 0)
# Get state level census data
state <- suppressMessages(
  get_acs(geography = "state",
          variables = c(hhincome = 'B19019_001',
                        race.tot = "B02001_001",
                        race.white = "B02001_002",
                        race.black = "B02001_003"
          ),
          year = 2020,
          survey = "acs5", # American Community Survey 5-year estimate
          geometry = TRUE, # returns sf objects
          output = "wide") # wide vs. long
)

state <- state %>%
  select(GEOID,
         hhincome = hhincomeE, # New name = old name
         race.tot = race.totE,
         race.white = race.whiteE,
         race.black = race.blackE)

Race

First, we take a look at the race. There are 6 races included in the dataset (also one category for those records doesn’t have race information): [1] “African-American/Black”
[2] “European-American/White”
[3] “Hispanic/Latino”
[4] “Asian/Pacific Islander”
[5] “Native American/Alaskan”
[6] “Middle Eastern”
[7] “Race unspecified”

Total amount

From the total amount perspective, whites make up the largest proportion, followed by blacks and Latinos which is consistent with our intuition of racial proportions.

data1 <- data %>% group_by(Race.with.imputations) %>% summarize(count = n()) %>%
          arrange(count/sum(count))

ggplot(data1, aes(x = reorder(Race.with.imputations, count), y = count)) +
  geom_bar(stat = "identity", fill = "skyblue") +
  geom_text(aes(label = count, hjust = 0.5), vjust = 0.3, size = 3, color = "black") +
  theme_minimal() +
  labs(title = "Race Distribution", x = "Race", y = "Count") +
  coord_flip()

Percentage

But can total number tell everything? Usually, percentage will tells us more.

In theory, any one race’s share of total kills should be close to that race’s share of the total population. If one race’s share of total kills is higher than its share of the total population, there is inequality. Now let’s calculate percentages for Blacks.

Formula:

percentage of Blacks in people killed = Blacks killed/total killed

percentage of Blacks in total population = total Blacks/total population

percentage difference = percentage of Blacks in people killed - percentage of Blacks in total population

If percentage difference > 0, Blacks have a higher probability killed than other races. The higher the difference, the higher the probability of Blacks being killed.

data2 <- data %>% filter(!is.na(data$Longitude) & !is.na(data$Latitude))

data_sf <- st_as_sf(data2, coords = c("Longitude", "Latitude"), crs = 4269)
join <- st_join(data_sf,state)

kill_total <- st_drop_geometry(join) %>% group_by(State) %>%
                          summarize(kill_total = n(),
                                    GEOID = first(GEOID))

kill_black <- st_drop_geometry(join) %>% group_by(State,Race.with.imputations) %>%
                          summarize(kill_black = n()) %>%
                          filter(Race.with.imputations == "African-American/Black")
## `summarise()` has grouped output by 'State'. You can override using the
## `.groups` argument.
killcombine <- left_join(kill_total, kill_black, by = "State")

# Join State information      
Addpercent <- left_join(killcombine,state, by = "GEOID") %>%
                mutate(kill_black_percent = (kill_black/kill_total)*100,
                       kill_percent = (kill_total/race.tot)*100,
                       pop_percent = (race.black/race.tot)*100,
                       dif_percent = kill_black_percent - pop_percent)

The map below shows that the percentage difference > 0 in most of the states (except 5 states) which means that black people have much higher probability being killed than other races. For example, in Illinois, the percentage of black people being killed is 34 percentage point higher than the normal level (their percentage in the total population).And we can find that this inequality pattern is more significant in northeast area.

tmap_mode("view")
## tmap mode set to interactive viewing
visual <- st_as_sf(Addpercent[!(Addpercent$State %in% c("AK","HI")),])
visual$dif_percent <- ifelse(is.na(visual$dif_percent), 0, visual$dif_percent)

tm_shape(visual) +
  tm_polygons(col = "dif_percent", palette = "-RdYlGn")
## Variable(s) "dif_percent" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.

Region

Next, let’s look at how places affect the probability. We calculate the percentage of people killed during interactions with police in different states.

The map shows that New Mexico has the highest percentage, following by Oklahoma and Missouri. Most of the states have high percentage are at the West and South while northeastern area have a relatively low percentage. This is an interesting contrast to the last map.

tm_shape(visual) +
  tm_polygons(col = "kill_percent")

Time

We are also interested in how the pattern changed in the past 20 years.

data$year <- substr(data$Date.of.injury.resulting.in.death..month.day.year., nchar(data$Date.of.injury.resulting.in.death..month.day.year.) - 3, nchar(data$Date.of.injury.resulting.in.death..month.day.year.))

Despite fluctuations, the total number of killings continues to rise. There was a big drop in 2021, probably related to data collection.

trend1 <- data %>% group_by(year) %>%
                  summarize(count = n())
                  
ggplot(trend1, aes(x = year, y = count)) +
  geom_bar(stat = "identity", fill = "green") +
  labs(x = "Year", y = "Total Count") +
  ggtitle("Total Count by Year") +
  theme_minimal()

The composition of different races has remained roughly same. Looks like there is no clear trend.

trend2 <- data %>% group_by(Race.with.imputations, year) %>%
                  summarize(count = n()) %>%
                  group_by(year) %>%
                  mutate(Percentage = count / sum(count) * 100)
## `summarise()` has grouped output by 'Race.with.imputations'. You can override
## using the `.groups` argument.
ggplot(trend2, aes(x = year, y = Percentage, color = Race.with.imputations, group = Race.with.imputations)) +
  geom_line() +
  labs(x = "Year", y = "Percentage", title = "Race Percentage Over Time") +
  scale_y_continuous(labels = scales::percent_format(scale = 1))+
  scale_color_brewer(palette = "Set1") +
  theme_minimal()+
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) # Adjust the angle and hjust as needed

Conclusion

The analysis above shows that probability of people being killed during the interaction with police is affected by race, region and time. And there is clear inequality among different races and regions.