Crime Analysis – Denver-Part 3

Marijuana, Alcohol, and Other Drugs


Continuing our Exploration of the Data
After identifying the sources of crime growth, it’s time to investigate specific crime rates. This blog post addresses drug and alcohol crimes in Denver over the past few years.

This is a very simplistic view because it will only focus on trend data, which never tells the whole story.

Crime Analysis of Denver – Part 3

The Itinerary

  • Identify top crimes related to drugs and alcohol
    • Achieved by filtering “drug-alcohol” in the OFFENSE CATEGORY ID
  • Compare most from January – October while excluding November and December to compare apples-to-apples with previous years
    • This adjustment helps simplify things but will also introduce a level of bias

Exploration of Data
Data provided by http://data.denvergov.org

Import the necessary libraries and data

library(dplyr)  
library(lubridate)  
library(ggplot2)  
library(tidyr)  
####
# Data from: http://data.denvergov.org/dataset/city-and-county-of-denver-crime
# File name: crime.csv
CWD = getwd()  
data = read.csv(paste(CWD,'/data/crime.csv',sep=''))  
data.backup=data  
####

Drugs and Alcohol

  • What are the top 15 crimes types (as defined by CRIME TYPE ID)?
  • How have the number of incidents reported changed over the last few years?
topCrimes = data %>%  
  filter(OFFENSE_CATEGORY_ID == 'drug-alcohol') %>%
  filter(year >= 2014) %>%
  filter(month < maxMonthYTD) %>%
  group_by(OFFENSE_TYPE_ID) %>%
  summarise(incidents = sum(incidents)) %>%
  arrange(desc(incidents))
topCrimes = topCrimes$OFFENSE_TYPE_ID[1:15]

df = data %>%  
  filter(OFFENSE_CATEGORY_ID == 'drug-alcohol') %>%
  filter(OFFENSE_TYPE_ID %in% topCrimes) %>%
  filter(year >= 2014) %>%
  filter(month < maxMonthYTD) %>%
  group_by(OFFENSE_TYPE_ID,year) %>%
  summarise(incidents = sum(incidents))

p = ggplot(df,aes(x=reorder(OFFENSE_TYPE_ID,-incidents),y=incidents,group=factor(year),col=factor(year)))  
p + geom_line() + geom_point() + theme(axis.text.x = element_text(angle = 45,hjust=1)) + ggtitle(paste("Annual Incidents Reported")) + labs(x = "OFFENSE CATEGORY")

Observations

  • Liquor possession ranked highest in the drug-alcohol violations
  • Possession of drug paraphernalia ranked second, followed by possession of marijuana
  • Methamphetamine possession breaks the pattern of annual declines in incidents – it actually grew from 2014-2016
  • Cocaine and heroin possession also grew, but at a much smaller volume than methamphetamine

barplotCrime

Marijuana Approved for Recreational Usage

df = data %>%  
  filter(date <= '2016-10-31') %>%
  filter(year >= 2013) %>%
  filter(grepl('marijuana',OFFENSE_TYPE_ID)) %>%
  group_by(OFFENSE_TYPE_ID,year,month) %>%
  summarise(incidents = sum(incidents))
df$yearMonth = as.Date(paste(as.character(df$year),"-",as.character(df$month),"-01",sep=''))  
p = ggplot(df,aes(x=yearMonth,y=incidents,col=OFFENSE_TYPE_ID,fill=OFFENSE_TYPE_ID))  
p + geom_line() + theme(legend.position = 'bottom',legend.title=element_blank()) + ggtitle(expression(atop(paste("Incidents With 'Marijuana' Classification"),atop(italic('Note Spikes in Possession of Marijuana on April 20th of Each Year and Sharp Drop-off in 2016'),"")))) + labs(x='Year by Month')

Observations

  • The middle of 2016 showed a dramatic decrease in incidents
  • Possession incidents were a much larger percentage of the violations until the middle of 2016
    • The timing of the sharp decrease in 2016 seems to be a couple of years too late
    • Marijuana was legalized for recreational purposes in Colorado in 2014. It would make more sense if the drop occurred when this was implemented – Wikipedia Article
    • It’s important to note that this has nothing to do with sentencing and is only what is reported to the police
  • Apparently April 20th (aka 420) is a widely celebrated in the marijuana users community – Wikipedia Article

barplotCrime

What % Changes Occurred

df2 = data %>%  
  filter(date <= '2016-10-31') %>%
  filter(year >= 2013) %>%
  filter(month <= maxMonthYTD) %>%
  filter(grepl('marijuana',OFFENSE_TYPE_ID)) %>%
  group_by(OFFENSE_TYPE_ID,year) %>%
  summarise(incidents = sum(incidents)) %>%
  arrange(OFFENSE_TYPE_ID,year) %>%
  mutate(year,YoYchange=round(100*((incidents-lag(incidents))/lag(incidents))),0) 
df2[is.na(df2)] = 0  
p = ggplot(df2,aes(x=factor(year),y=YoYchange,group=OFFENSE_TYPE_ID,fill=OFFENSE_TYPE_ID,label=YoYchange))  
p + geom_bar(stat='identity',position='dodge') + ggtitle('% Change in Crime Incidents vs Previous Year') + xlab('Year') + ylab('YoY % Change in Incidents') + theme(plot.title = element_text(hjust = 0.5)) + guides(fill = guide_legend(title='Year')) + geom_text(position = position_dodge(width=1),col='black',size=5,fontface='bold')  

Observations

  • Marijuana cultivation grew each year (no pun intended)
  • Incidents of marijuana possession dropped by 51% from 2015 to 2016
  • Incidents of marijuana sales dropped by 12% from 2015 to 2016
    • This makes sense – if there are legal channels, it would make sense to take advantage of them as long as the financial incentives are in place

barplotCrime

Liquor & Alcohol

df = data %>%  
  filter(date <= '2016-10-31') %>%
  filter(year >= 2013) %>%
  filter(grepl('alcohol|liquor',OFFENSE_TYPE_ID)) %>%
  group_by(OFFENSE_TYPE_ID,year,month) %>%
  summarise(incidents = sum(incidents))
df$yearMonth = as.Date(paste(as.character(df$year),"-",as.character(df$month),"-01",sep=''))  
p = ggplot(df,aes(x=yearMonth,y=incidents,col=OFFENSE_TYPE_ID,fill=OFFENSE_TYPE_ID))  
p + geom_line() + theme(legend.position = 'right',legend.title=element_blank()) + ggtitle(expression(atop(paste("Incidents With 'Liquor' Classification"),atop(italic('Note Declining Trend in Liquor Incidents'),"")))) + labs(x='Year by Month')

Observations

  • With incidents of liquor manufacturing so low, it appears as if bootleggers and moonshiners probably don’t thrive in Colorado
  • There’s a downward trend in the number of incidents each year

Liquor ranked as #1 in the “drug-alcohol” Category

barplotCrime

What About Methamphetamine?

df = data %>%  
  filter(date <= '2016-10-31') %>%
  filter(year >= 2012) %>%
  filter(grepl('methamphetamine|methampetamine',OFFENSE_TYPE_ID)) %>%
  group_by(OFFENSE_TYPE_ID,year,month) %>%
  summarise(incidents = sum(incidents))
df$yearMonth = as.Date(paste(as.character(df$year),"-",as.character(df$month),"-01",sep=''))  
p = ggplot(df,aes(x=yearMonth,y=incidents,col=OFFENSE_TYPE_ID,fill=OFFENSE_TYPE_ID))  
p + geom_line() + theme(legend.position = 'bottom',legend.title=element_blank()) + ggtitle(expression(atop(paste("Incidents With 'Methamphetamine' Classification"),atop(italic('Note Posession Increasing Much Faster Than Selling'),"")))) + labs(x='Year by Month')  

Observations

  • There has been a rapid and steady growth in methamphetamine incidents since 2012
    • Possession had a monthly minimum of 11 incidents back in 2012 and grew to a maximum of 87 in 2016
  • FYI – I didn’t misspell methamphetamine, as methampetamine (it exists in the data that way)

barplotCrime

Growth % for Methamphetamines

df2 = data %>%  
  filter(year >= 2012) %>%
  filter(month <= maxMonthYTD) %>%
  filter(grepl('methamphetamine|methampetamine',OFFENSE_TYPE_ID)) %>%
  group_by(OFFENSE_TYPE_ID,year) %>%
  summarise(incidents = sum(incidents)) %>%
  arrange(OFFENSE_TYPE_ID,year) %>%
  mutate(year,YoYchange=round(100*((incidents-lag(incidents))/lag(incidents))),0) 
df2[is.na(df2)] = 0  
p = ggplot(df2,aes(x=factor(year),y=YoYchange,group=OFFENSE_TYPE_ID,fill=OFFENSE_TYPE_ID,label=YoYchange))  
p + geom_bar(stat='identity',position='dodge') + ggtitle('% Change in Crime Incidents vs Previous Year') + xlab('Year') + ylab('YoY % Change in Incidents') + theme(plot.title = element_text(hjust = 0.5)) + guides(fill = guide_legend(title='Year')) + geom_text(position = position_dodge(width=1),col='black',size=5,fontface='bold')  

Observations

  • While the growth in terms of percentage was very high for manufacturing, the volume was very low (change of 1-2 incidents per year)
  • Large percentage growth occurred in possession but not in sales crimes
  • When did Breaking Bad end? Perhaps this is more than a coincidence…

barplotCrime

Final Thoughts (for now)

The population of Denver has been increasing at a large rate for the last decade or so. None of this data has been population adjusted which could be painting the wrong picture. However, it’s interesting to notice alcohol and marijuana incidents on the decline with methamphetamine and heroin incidents increasing. According to what I remember from D.A.R.E., meth and heroin are pretty nasty drugs, which is worrisome for the area. However, issues with liquor and alcohol still rank #1 for now.

Colorado is well known for large growth in the microbrewery and marijuana industries. The crime data seems to indicate a downward trend in both alcohol and marijuana related violations. Perhaps a negative correlation between marijuana and alcohol crime incidents and business openings in those industries exists. Once you can sell and purchase something legally it may reduce those crimes but may not reduce consumption.

Up Next:

  • Identify patterns by location
  • Geo-Spatial crime visualization

Feel free to comment and take some of this data and run with some ideas of your own!

Code used in this post is on my GitHub