A. Introduction

Is there a significant difference in the average age of murder victims between Westminster and Croydon?

The dataset used for this project is called London Murders, 2006–2011, which has 838 rows (observations) and 5 columns (variables) covering murders recorded by the Metropolitan Police in Greater London from January 1, 2006, to September 7, 2011. The five variables of the dataset are the forename of the victims, age of the victims, date of murder, year of murder, and the borough where the murder happened. The analysis focuses on the variables age, which is a numerical variable, and borough, a categorical variable, specifically comparing the Westminster and Croydon boroughs. The dataset was obtained from the OpenIntro website, which lists The Guardian Datablog as the original source. (accessible at: https://www.openintro.org/data/index.php?data=london_murders)

B. Data Analysis

To answer the research question, I first inspected the dataset’s size, structure, and column names, and checked for missing values. I found that this dataset does not have any missing values, so none needed to be removed. Next, I used the dplyr functions select() and filter() to focus only on Westminster and Croydon, and then used group_by() and summarise() to find their averages and standard deviations. These results showed that Croydon’s average victim age was 32.08 years with a standard deviation of 16.38 years, while Westminster’s average age was 28.70 years with a standard deviation of 16.64 years. Finally, I created a side-by-side boxplot to compare the age distributions of both boroughs, which shows that Croydon has a slightly higher median line and a wider middle box, whereas Westminster’s ages are more tightly grouped in the 20s and early 30s with a few older outliers and one younger outlier.

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## âś” forcats   1.0.1     âś” readr     2.2.0
## âś” ggplot2   4.0.3     âś” stringr   1.6.0
## âś” lubridate 1.9.5     âś” tibble    3.3.1
## âś” purrr     1.2.2     âś” tidyr     1.3.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
lm <- read.csv("london_murders.csv")
# inspect the dataset
head(lm)
##             forename age       date year    borough
## 1 Barrington Derrick  19 2006-01-02 2006    Hackney
## 2              Aaron  24 2006-01-02 2006   Lewisham
## 3        Christopher  22 2006-01-03 2006 Hillingdon
## 4      Thomas Philip  18 2006-01-04 2006     Camden
## 5             Amanda  26 2006-01-04 2006     Camden
## 6         Siva-Kumar  44 2006-01-05 2006      Brent
tail(lm)
##             forename age       date year   borough
## 833    Kelvin Robert  17 2011-08-15 2011 Redbridge
## 834            Leroy  14 2011-08-18 2011   Enfield
## 835 Jonathan Anthony  20 2011-08-24 2011   Croydon
## 836           Steven  21 2011-08-31 2011   Enfield
## 837          Maymoun  39 2011-09-02 2011 Islington
## 838     Michael John  44 2011-09-06 2011     Brent
colnames(lm)
## [1] "forename" "age"      "date"     "year"     "borough"
str(lm)
## 'data.frame':    838 obs. of  5 variables:
##  $ forename: chr  "Barrington Derrick" "Aaron" "Christopher" "Thomas Philip" ...
##  $ age     : int  19 24 22 18 26 44 39 21 78 27 ...
##  $ date    : chr  "2006-01-02" "2006-01-02" "2006-01-03" "2006-01-04" ...
##  $ year    : int  2006 2006 2006 2006 2006 2006 2006 2006 2006 2006 ...
##  $ borough : chr  "Hackney" "Lewisham" "Hillingdon" "Camden" ...
dim(lm)
## [1] 838   5
# check for missing values
sum(is.na(lm$age))
## [1] 0
sum(is.na(lm$borough))
## [1] 0
# creating a new dataset with only needed columns
lm_subset <- lm|> select(age, borough) |> filter(borough %in% c("Westminster", "Croydon"))

# group the data by borough and calculate the count, mean age, and standard deviation
lm_groupby <- lm_subset |> group_by(borough) |> summarise(count = n(), mean_age= mean(age), sd_age= sd(age))

# display the summary table
lm_groupby
## # A tibble: 2 Ă— 4
##   borough     count mean_age sd_age
##   <chr>       <int>    <dbl>  <dbl>
## 1 Croydon        38     32.1   16.4
## 2 Westminster    23     28.7   16.6
# boxplot of victim age by borough
ggplot(lm_subset, aes(x = factor(borough), y = age)) +
  geom_boxplot(fill = c("#1f77b4", "#ff7f0e")) +
  labs(
    title = "Boxplot of Murder Victim Age by Borough",
    x = "London Borough",
    y = "Victim Age (Years)"
  ) +
  theme_minimal()

C. Statistical Analysis

\(H_0: \mu_1 - \mu_2 = 0\)

\(H_a: \mu_1 - \mu_2 \neq 0\)

My null hypothesis is that there is no difference in the true mean age of murder victims between Westminster and Croydon, and my alternative hypothesis is that there is a significant difference in the true mean age between the two boroughs. I conducted an independent Welch Two-Sample t-test at a 99% confidence level (significance level \(\alpha = 0.01\)) because I am comparing the numerical mean of age across two independent groups, Westminster and Croydon. From the test, I obtained \(t = -0.774\), \(df = 45.98\), a 99% confidence interval of \([-15.13, 8.36]\), and a p-value of \(0.4428\). Because the p-value (\(0.4428\)) is much greater than \(\alpha = 0.01\), I fail to reject the null hypothesis. Therefore, there is not enough statistical evidence to conclude that the true average age of murder victims differs between Westminster and Croydon.

# separate the dataset into two subsets for Westminster and Croydon
westminster <- lm_subset |>
  filter(borough == "Westminster")

croydon <- lm_subset |>
  filter(borough == "Croydon")
# run the t-test
t.test(westminster$age, croydon$age, conf.level = 0.99, alternative = "two.sided")
## 
##  Welch Two Sample t-test
## 
## data:  westminster$age and croydon$age
## t = -0.77417, df = 45.976, p-value = 0.4428
## alternative hypothesis: true difference in means is not equal to 0
## 99 percent confidence interval:
##  -15.126455   8.359864
## sample estimates:
## mean of x mean of y 
##  28.69565  32.07895

D. Conclusion and Future Directions

From my analysis, I found that even though Croydon’s average victim age (\(32.08\) years) was slightly higher than Westminster’s (\(28.70\) years), the t-test (\(p = 0.4428\)) showed that this difference is not statistically significant. I also found that victims in both boroughs tended to be young adults in their late 20s to early 30s, which shows that the age patterns of victims were pretty similar in both areas from 2006 to 2011.

For further analysis, we could run an ANOVA test to compare victim ages across all 32 London boroughs at once, or check if the average victim age changed over time across different years. We could also look into population size or income levels in each borough to help explain why Croydon had more total cases (\(38\)) than Westminster (\(23\)).

E. Reference

OpenIntro. (n.d.). London Murders. https://www.openintro.org/data/index.php?data=london_murders

The Guardian Datablog. https://www.theguardian.com/news/datablog/2011/oct/05/murder-london-list#data