Final Project

Author

Megan Vollbrecht

Part One: Introduction

Background

This data is from The Murder Accountability Project, which takes data from the FBI’s Supplementary Homicide Report and Freedom of Information Act. Thomas Hargrove is the founder of the Murder Accountability Project, and his mission behind his foundation is to help solve homicides as over the years, a growing proportion of murders are going unsolved by police. Hargrove collects and publishes data for the public in order to bring awarness to this issue and provide resources for law enforcement to gain insight into homicides.

Source for the Data

This data is a compilation of data collected by the FBI. The data originally was published in the FBI’s Supplementary Homicide Report from 1976 to the present and the Freedom of Information Act data. These are observational reports. This data relies on agencies willingly supplying the data to the FBI. “For the most part, agencies submit monthly crime reports, using uniform offense definitions, to a centralized repository within their state. The state UCR Program then forwards the data to the FBI’s national UCR Program.2 Agencies in states that do not have a state program submit their data directly to the FBI” (Data Quality Guidelines). This leaves gaps in the data as only crimes reported to official government agencies are accounted for in this data. There is a belief “according to the federal Bureau of Justice Statistics, over 50% of violent crimes and about 70% of property crimes are never reported” (HERNÁNDEZ).

Details of statistics

Variables included in this dataset

Variable in this data set are grouped into categories. The 4 main categories for data collected are agency, crime, victim, and perpetrator. Agency.Code, Agency.Name, and Agency.Type all describe the agency which reported the crime. Crime.Type, Crime.Solved, indicate what category of homicide the crime falls into and whether or not it was solved. Victim.Sex, Victim.Race, Victim.Age, Victim.Ethnicity, all describe demographic information for the victims, and there are equivalent variable for the perpetrators as well. They also assign each crime a specific Record.ID to keep track of the different crimes. Also recorded is information about the time and place of the crime. City, State, Year, Month, and Incident all provide this information. The Relationship of the victim and the perpetrator are also recorded when it is known, as well as the Weapon used during the crime, how many victims and how many perpetrators were involved. Lastly, they record in Record.Source if the data was obtained from the FBI or the Freedom of Information Act.

Background Research

In “What the data says (and doesn’t say) about crime in the United States” John ### Gramlich claims “There were no major differences in victimization rates between male and female respondents or between those who identified as White, Black or Hispanic. But the victimization rate among Asian Americans was substantially lower than among other racial and ethnic groups.”

In order to address issues with their reporting, John Gramlick describes a new system being implemented by the FBI. “The new system, known as the National Incident-Based Reporting System (NIBRS), will provide information on a much larger number of crimes, as well as details such as the time of day, location and types of weapons involved, if applicable. It will also provide demographic data, such as the age, sex, race and ethnicity of victims, known offenders and arrestees.”

Overarching question

Working with the Data

Summary Graphs

Load libraries and import dataset

library(tidyverse)
Warning: package 'ggplot2' was built under R version 4.3.3
Warning: package 'tidyr' was built under R version 4.3.3
── 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
library(tidymodels)
Warning: package 'tidymodels' was built under R version 4.3.3
── Attaching packages ────────────────────────────────────── tidymodels 1.2.0 ──
✔ broom        1.0.5      ✔ rsample      1.2.1 
✔ dials        1.2.1      ✔ tune         1.2.0 
✔ infer        1.0.6      ✔ workflows    1.1.4 
✔ modeldata    1.3.0      ✔ workflowsets 1.1.0 
✔ parsnip      1.2.1      ✔ yardstick    1.3.1 
✔ recipes      1.0.10     
Warning: package 'dials' was built under R version 4.3.3
Warning: package 'infer' was built under R version 4.3.3
Warning: package 'modeldata' was built under R version 4.3.3
Warning: package 'parsnip' was built under R version 4.3.3
Warning: package 'recipes' was built under R version 4.3.3
Warning: package 'rsample' was built under R version 4.3.3
Warning: package 'tune' was built under R version 4.3.3
Warning: package 'workflows' was built under R version 4.3.3
Warning: package 'workflowsets' was built under R version 4.3.3
Warning: package 'yardstick' was built under R version 4.3.3
── Conflicts ───────────────────────────────────────── tidymodels_conflicts() ──
✖ scales::discard() masks purrr::discard()
✖ dplyr::filter()   masks stats::filter()
✖ recipes::fixed()  masks stringr::fixed()
✖ dplyr::lag()      masks stats::lag()
✖ yardstick::spec() masks readr::spec()
✖ recipes::step()   masks stats::step()
• Search for functions across packages at https://www.tidymodels.org/find/
library(openintro)
Loading required package: airports
Loading required package: cherryblossom
Loading required package: usdata

Attaching package: 'openintro'

The following object is masked from 'package:modeldata':

    ames
library(skimr)
Warning: package 'skimr' was built under R version 4.3.3
crimedataset <- read.csv("crimedataset.csv")
glimpse(crimedataset)
Rows: 638,454
Columns: 24
$ Record.ID             <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1…
$ Agency.Code           <chr> "AK00101", "AK00101", "AK00101", "AK00101", "AK0…
$ Agency.Name           <chr> "Anchorage", "Anchorage", "Anchorage", "Anchorag…
$ Agency.Type           <chr> "Municipal Police", "Municipal Police", "Municip…
$ City                  <chr> "Anchorage", "Anchorage", "Anchorage", "Anchorag…
$ State                 <chr> "Alaska", "Alaska", "Alaska", "Alaska", "Alaska"…
$ Year                  <int> 1980, 1980, 1980, 1980, 1980, 1980, 1980, 1980, …
$ Month                 <chr> "January", "March", "March", "April", "April", "…
$ Incident              <int> 1, 1, 2, 1, 2, 1, 2, 1, 2, 3, 1, 2, 3, 1, 2, 3, …
$ Crime.Type            <chr> "Murder or Manslaughter", "Murder or Manslaughte…
$ Crime.Solved          <chr> "Yes", "Yes", "No", "Yes", "No", "Yes", "Yes", "…
$ Victim.Sex            <chr> "Male", "Male", "Female", "Male", "Female", "Mal…
$ Victim.Age            <int> 14, 43, 30, 43, 30, 30, 42, 99, 32, 38, 36, 20, …
$ Victim.Race           <chr> "Native American/Alaska Native", "White", "Nativ…
$ Victim.Ethnicity      <chr> "Unknown", "Unknown", "Unknown", "Unknown", "Unk…
$ Perpetrator.Sex       <chr> "Male", "Male", "Unknown", "Male", "Unknown", "M…
$ Perpetrator.Age       <int> 15, 42, 0, 42, 0, 36, 27, 35, 0, 40, 0, 49, 39, …
$ Perpetrator.Race      <chr> "Native American/Alaska Native", "White", "Unkno…
$ Perpetrator.Ethnicity <chr> "Unknown", "Unknown", "Unknown", "Unknown", "Unk…
$ Relationship          <chr> "Acquaintance", "Acquaintance", "Unknown", "Acqu…
$ Weapon                <chr> "Blunt Object", "Strangulation", "Unknown", "Str…
$ Victim.Count          <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
$ Perpetrator.Count     <int> 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, …
$ Record.Source         <chr> "FBI", "FBI", "FBI", "FBI", "FBI", "FBI", "FBI",…
unique(crimedataset$Record.Source)
[1] "FBI"  "FOIA"

Year versus the race of homicide victims reported

victim_race_year <- crimedataset |>
  group_by(Year) |>
  count(Victim.Race) |>
  mutate(prop_race = n/sum(n))
victim_race_year
# A tibble: 175 × 4
# Groups:   Year [35]
    Year Victim.Race                       n prop_race
   <int> <chr>                         <int>     <dbl>
 1  1980 Asian/Pacific Islander          168   0.00728
 2  1980 Black                          9842   0.426  
 3  1980 Native American/Alaska Native   154   0.00667
 4  1980 Unknown                         658   0.0285 
 5  1980 White                         12270   0.531  
 6  1981 Asian/Pacific Islander          191   0.00901
 7  1981 Black                          9335   0.440  
 8  1981 Native American/Alaska Native   136   0.00641
 9  1981 Unknown                         134   0.00632
10  1981 White                         11412   0.538  
# ℹ 165 more rows

Plot the proportion of homicide victims based on race over the years

ggplot(data = victim_race_year, aes(x = Year, y = prop_race,  color = factor(Victim.Race))) +
  geom_point() +
  geom_smooth()
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'

Proportion of homicide victims based on gender by year

Look at the proportion of homicide victims for Male, Female, and Unknown

victim_gender_year <- crimedataset |>
  group_by(Year) |>
  count(Victim.Sex) |>
  # Create new variable, prop, using mutate
  mutate(prop = n/sum(n))
victim_gender_year
# A tibble: 105 × 4
# Groups:   Year [35]
    Year Victim.Sex     n     prop
   <int> <chr>      <int>    <dbl>
 1  1980 Female      5059 0.219   
 2  1980 Male       18014 0.780   
 3  1980 Unknown       19 0.000823
 4  1981 Female      4627 0.218   
 5  1981 Male       16564 0.781   
 6  1981 Unknown       17 0.000802
 7  1982 Female      4806 0.234   
 8  1982 Male       15723 0.765   
 9  1982 Unknown       15 0.000730
10  1983 Female      4615 0.235   
# ℹ 95 more rows

Filter out just the portion of homicide victims who were Male

prop_male <- victim_gender_year |>
  filter(Victim.Sex == "Male")
prop_male
# A tibble: 35 × 4
# Groups:   Year [35]
    Year Victim.Sex     n  prop
   <int> <chr>      <int> <dbl>
 1  1980 Male       18014 0.780
 2  1981 Male       16564 0.781
 3  1982 Male       15723 0.765
 4  1983 Male       15019 0.764
 5  1984 Male       13595 0.751
 6  1985 Male       13775 0.749
 7  1986 Male       15234 0.757
 8  1987 Male       13963 0.743
 9  1988 Male       14133 0.753
10  1989 Male       15280 0.769
# ℹ 25 more rows

Make a plot of the proportion of male victims as it changed over time.

ggplot(data = prop_male, aes(x = Year, y = prop)) +
  geom_point() +
  geom_smooth()
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'

Proportion of homicide victims who are over 50 years older year

Started by looking at the proportion of homicide victim for every age by year

victim_age_year <- crimedataset |>
  group_by(Year) |>
  count(Victim.Age) |>
  mutate(prop_age = n/sum(n))
victim_age_year
# A tibble: 3,490 × 4
# Groups:   Year [35]
    Year Victim.Age     n prop_age
   <int>      <int> <int>    <dbl>
 1  1980          0   227 0.00983 
 2  1980          1   115 0.00498 
 3  1980          2   103 0.00446 
 4  1980          3    66 0.00286 
 5  1980          4    59 0.00255 
 6  1980          5    48 0.00208 
 7  1980          6    31 0.00134 
 8  1980          7    32 0.00139 
 9  1980          8    19 0.000823
10  1980          9    26 0.00113 
# ℹ 3,480 more rows

Looking at the proportion who are over 50

victim_age_year1 <- crimedataset %>% 
  group_by(Year) %>%
  mutate(age_50plus = if_else(Victim.Age > 50, "yes", "no")) %>%
  count(age_50plus) %>%
  mutate(prop_age_50plus = n/sum(n))
head(victim_age_year1)
# A tibble: 6 × 4
# Groups:   Year [3]
   Year age_50plus     n prop_age_50plus
  <int> <chr>      <int>           <dbl>
1  1980 no         19159           0.830
2  1980 yes         3933           0.170
3  1981 no         17446           0.823
4  1981 yes         3762           0.177
5  1982 no         16916           0.823
6  1982 yes         3628           0.177
ggplot(data = victim_age_year1, aes(x = Year, y = prop_age_50plus)) +
  geom_point()

Mean age of victims

mean_victim_age <- crimedataset %>%
     group_by(Year) %>%
     summarise(mean_age = mean(Victim.Age))

head(mean_victim_age)
# A tibble: 6 × 2
   Year mean_age
  <int>    <dbl>
1  1980     35.4
2  1981     36.1
3  1982     35.7
4  1983     35.9
5  1984     37.1
6  1985     36.2
ggplot(data = mean_victim_age, aes(x = Year, y = mean_age)) +
  geom_point() + geom_smooth()
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'

Compare the proportion of victims who are white in 1980 and 2014. d_hat is the difference in the proportions from the dataset

p_hats <- crimedataset |>
 group_by(Year) |>
 summarize(mean(Victim.Race == "White", na.rm = TRUE)) |>
 pull()

p_hats_1980 = p_hats[1]
p_hats_2014 = p_hats[34]
p_hats_1980
[1] 0.5313528
p_hats_2014
[1] 0.4647283
d_hat <- p_hats_1980 - p_hats_2014
d_hat
[1] 0.06662457

Difference in proportions is 0.066

I think i am having difficulty because year is an int and not a char

#victim_race_1980_2014 <- victim_race_year |>
 # filter(Year == 1980 | Year == 2014) |>
#victim_race_1980_2014

#null <- victim_race_1980_2014 |>
 #specify(Victim.Race ~ Year, success == "White") |>
 #hypothesize(null = "independence") |>
 #generate(reps = 500, type = "permute") |>
 #calculate(stat = "diff in props", order = c("1980", "2014"))
#null
#null <- victim_race_1980_2014 |>
# specify(prop_race ~ Victim.Race, success = "White") |>
 #hypothesize(null = "independence") |>
 #generate(reps = 500, type = "permute") |>
 #calculate(stat = "diff in props", order = c("1980", "2014"))
#null

Logistic regression for proportion of victims which were male.

Null hypothesis is that there is no difference based on year for the proportion of victims which are male.

Alternative hypothesis is that this is a difference based on year for the proportion of victims which are male.

fit1 <- lm(data = victim_gender_year, Year ~ prop)
summary(fit1)

Call:
lm(formula = Year ~ prop, data = victim_gender_year)

Residuals:
   Min     1Q Median     3Q    Max 
   -17     -9      0      9     17 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)  1.997e+03  1.426e+00    1400   <2e-16 ***
prop        -4.112e-14  3.065e+00       0        1    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 10.2 on 103 degrees of freedom
Multiple R-squared:  1.395e-27, Adjusted R-squared:  -0.009709 
F-statistic: 1.437e-25 on 1 and 103 DF,  p-value: 1

Based on the p-value of 1, we fail to reject the null hypothesis. It seems very likely that there is not a significant difference based on year for the proportion of victims which are male.

ANOVA test for mean victim age

Need to change year to a char?

#obs_stat <- mean_victim_age |>
# specify(Year ~ mean_age) |>
# calculate(stat = "F")
#obs_stat

Conclusion

General Conclusion

Important results

Specific conclusions

Opinion on how it went

Bibliography

Cooper, Alexia D., and Erica L. Smith. “Homicide Trends in the United States, 1980-2008.” Bureau of Justice Statistics, Nov. 2011, bjs.ojp.gov/library/publications/homicide-trends-united-states-1980-2008, https://doi.org/Homicide%20Trends%20in%20the%20United%20States,%201980-2008.

“Expanded Homicide Data.” FBI, ucr.fbi.gov/crime-in-the-u.s/2011/crime-in-the-u.s.-2011/offenses-known-to-law-enforcement/expanded/expanded-homicide-data.

Gramlich, John. “What the Data Says (and Doesn’t Say) about Crime in the United States.” Pew Research Center, 20 Nov. 2020, www.pewresearch.org/short-reads/2020/11/20/facts-about-crime-in-the-u-s/.

Grawert, Ames, and Noah Kim. “Myths and Realities: Understanding Recent Trends in Violent Crime | Brennan Center for Justice.” Www.brennancenter.org, 12 July 2022, www.brennancenter.org/our-work/research-reports/myths-and-realities-understanding-recent-trends-violent-crime.

Murder Accountability Project. www.murderdata.org/.