Executive Summary: This analysis identifies a critical seasonal trend in NYC shootings that correlates with economic downturns. By filtering out pandemic-era anomalies (2020-2023), I isolated a pattern showing that summer unemployment is a primary driver of anxiety-driven crime. Recommendation: Shift resources from reactive policing to proactive Summer Job Programs and Homeless Shelter expansion as well as Recreational/Mental Health Facilities in high-risk zones.
# Critical filter: Exclude Pandemic Years ( 2020-2023)
#Reason: Policy changes and lockdowns would confound the biopsychosocial model
nycfiredcopy4D<- nycfiredcopy4D %>% #filter out years 2020-2023 as confound variables
filter(year<=2019) %>%
select(-c(occur_date, precinct,jurisdiction_code,boro,perp_age_group,longitude,latitude,perp_sex,perp_race,vic_age_group,vic_sex,vic_race,incident_key)) # removing unwanted fields
I made a deliberate decision to exclude 2020-2023 data. The pandemic introduced massive confounding variables (lockdowns, policy shifts) that would skew the correlation between economic recession and crime. By isolating 2006-2019, we get a clearer view of the natural biopsychosocial cycle.
I found July of 2007 to be an outlier with a zscore
greater than 3 standard deviations and after doing a deeper dive, I
found that this was due to people response to a police shooting
#Faceted Heatmap: Seasonal Patterns
nycplotting %>%
ggplot(aes(y=month,x=year,fill=cases))+geom_tile(linewidth = 1.2,linetype = 1,col='black')+geom_text(aes(label=totalshooting),col='white',size=3)+scale_x_continuous (breaks=seq(2006,2019,1))+
ggtitle("NYC Shootings by Month & Year (2008-2019)", subtitle = "Summer spikes are consistent across recession years"
)+facet_wrap(~season,scales="free_y")+ theme_classic()+ theme(legend.position= "bottom")+ theme(axis.text.x = element_text(angle=90,vjust=.3))+theme(plot.title = element_text(color = "blue", size = 15, face = "bold",hjust=.5))+theme(
plot.subtitle = element_text(
size = 10, # font size in points
face = "italic", # style: plain, bold, italic
color = "black", # text color
hjust = 0.5 # horizontal alignment
)
)
The Geom_tile heatmap reveals a consistent ‘Summer Peak’ (June-August) across all years, which intensifies during recession years (e.g.2008-2009). This Visual evidence supports the hypothesis that loss of income/housing drives desperation and crime during warmer months when social interaction is higher.
Section 4: The Business Recommendation