This project investigates the Heat Hypothesis, also known as the Temperature-Aggression Hypothesis, which posits that higher temperatures correlate with an increase in violent crime rates. Using data from New York City spanning the years 2013 to 2023, we analyze crime and temperature data to assess whether this hypothesis holds merit.
The analysis was conducted using Jupyter Notebook for data extraction, transformation, visualization, and statistical evaluation.
Our visualizations are both presented in the form of graphs/charts as well as a heat map of Manhattan for an interactive breakdown of the data.
In conducting this analysis, we ensured that only the relevant data required to answer the specific research questions was utilized.
To avoid potential personal biases, we intentionally excluded and dropped columns of data present in the API datasets that were not relevant to the project's scope. This careful selection of data helps maintain focus on the analysis while adhering to ethical research practices.
-
analysis.ipynb
:- Main notebook for data analysis and visualization.
- Integrates processed temperature and crime data.
- Generates scatter plots and statistical results to test the Heat Hypothesis.
-
data_extraction_manhattan_temperatures.ipynb
:- Processes and extracts temperature data for NYC locations.
- Transforms weather JSON into structured formats for analysis.
-
data_extraction_nyc_crime.ipynb
:- Processes and extracts NYC crime data.
- Maps geospatial and time-series crime details.
-
crime and weather.sql
:- SQL queries for merging crime and weather data.
- Defines structured datasets for analysis.
-
Output/data.json
:- Raw JSON dataset containing NYC crime data.
-
Output/weather.json
:- Raw JSON dataset containing NYC weather data.
-
Output/Manhattan_Temperatures_2013-2023.csv
:- Processed temperature dataset for Manhattan, including daily high, low, and mean temperatures.
-
Output/NYPD_Complaints_01-01-13_12-31-23_v2.csv
:- Processed dataset of NYPD complaints with geolocation and offense details.
-
leaflet_map/static/index.html
:- HTML file for rendering the heat map visualization of crime and temperature data.
- Links to necessary JavaScript and CSS files for the map.
-
leaflet_map/static/css/style.css
:- CSS file defining styles for the heat map, including legend and map element formatting.
-
leaflet_map/static/js/data.js
:- JavaScript file containing the crime and temperature datasets for visualization.
-
leaflet_map/static/js/logic.js
:- JavaScript file implementing map layers, marker clustering, and interactive elements for the heat map visualization.
-
Crime Data Transformation:
- Filters and aggregates NYC crime data.
- Categorizes crimes by severity and type.
- Maps complaints to geographic locations (e.g., Manhattan, Bronx).
-
Weather Data Transformation:
- Converts temperature data from JSON to tabular formats.
- Handles location-specific data (e.g., Central Park, Midtown).
- SQL Merging:
- Combines processed crime and weather datasets based on date and location.
- Ensures temporal alignment for cross-analysis.
- Correlation Testing:
- Assesses statistical correlation between daily temperature peaks and violent crime counts.
- Tests hypotheses using linear regression and visualization techniques.
- Visualization:
- Interactive heat map of crime rates over Manhattan, NYC.
- Temporal trends of temperature and crime.
This project is focused on New York City, specifically the borough of Manhattan, and examines:
- The correlation of temperature and crime rates.
- Compare findings to existing findings on the Heat Hypothesis.
- Python: Data processing and visualization (Pandas, Matplotlib, Seaborn).
- SQL: Data integration and preprocessing.
- Jupyter Notebook: Interactive analysis.
- JSON & CSV: Data storage and representation.
- Leaflet.js: Interactive mapping and heat map generation.
- D3.js: Data-driven visualizations for markers and legends.
- Open the Jupyter notebooks
data_extraction_manhattan_temperatures.ipynb
anddata_extraction_nyc_crime.ipynb
in a Python environment with the required dependencies. Run these notebooks to process and prepare the temperature and crime datasets. - Run the SQL queries in
crime and weather.sql
to merge the processed datasets, ensuring alignment by date and location. - Open
analysis.ipynb
and execute the cells to analyze the merged data, generate visualizations. - Click here to View the Leaflet Map!
Select a date from the Leaflet Map in the collapsed layer selection menu to display crime incidents across Manhattan as well as a temperature readings and a brief summary.
Findings of this analysis are available in the analysis.ipynb
notebook and the heat map visualization, showcasing whether temperature fluctuations significantly impact crime rates in New York City.
As this project is limited in both the scope of our data and the questions we wish to answer, we were not expecting a definitive answer on the Heat Hypothesis. We do feel that, while our data does not show enough statistical significance to prove a correlation there are many confounding variables so further study with a more limited timeframe and controlled setting might yeild more specific results.
- Open-Meteo API: https://openweathermap.org/api
- NYC Open Data - NYPD Complaint Data Historic: https://data.cityofnewyork.us/Public-Safety/NYPD-Complaint-Data-Historic/qgea-i56i/data_preview
- Craig A. Anderson. "Temperature and Aggression: Ubiquitous Effects of Heat on Occurrence of Human Violence." Psychological Bulletin, 1989. DOI: 10.1037//0033-2909.106.1.74
- Anderson, Craig A., et al. "Temperature and Aggression." Advances in Experimental Social Psychology, Vol. 32, 2000. DOI: 10.1016/S0065-2601(00)80004-0