The map to the left shows drug overdose deaths per 10,000 people per year averaged over 8 years from 2015 to 2022.
You can zoom in and out of this map, move around, and highlight each county to see its exact rate.
The map to the left shows the unemployement rate for each Indiana county.
You can zoom in and out of this map, move around, and highlight each county to see its exact rate.
This scatterplot shows each Indiana county’s unemployment rate by its overdose rate per 10,000 people with the size of each dot corresponding to that county’s population. You can see the exact numbers by hovering or clicking on each dot.
We can see that overdose deaths are not very correlated with unemployment rate in Indiana. In fact the correlation coefficient \(R = 0.3571757\).
This means that the unemployment rate only explains \(R^2 \approx\) 13% of the variance of the overdose rate using a linear model.
---
title: "Indiana Overdose Deaths and Unemployment"
output:
flexdashboard::flex_dashboard:
storyboard: true
social: menu
source: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(scales)
```
### Map of drug overdose death rate for Indiana counties
```{r map data}
od_all_years <- read_rds("data/od_all_years.RData")
od_by_year <- read_csv("data/od_by_year.csv")
years = unique(od_by_year$year)
n_years = length(years)
min_year = min(years)
max_year = max(years)
```
```{r overdose_map}
library(leaflet)
pal <- colorNumeric("viridis", NULL)
leaflet(od_all_years) %>%
addTiles() %>%
addPolygons(stroke = FALSE, smoothFactor = 0.3, fillOpacity = 0.5,
fillColor = ~pal(od_all_years$od_rate),
label = ~str_glue("{od_all_years$county}: {od_all_years$od_rate}")) %>%
addLegend(pal = pal, values=od_all_years$od_rate, opacity = 1.0)
```
***
The map to the left shows drug overdose deaths per 10,000 people per year averaged over 8 years from `r min_year` to `r max_year`.
You can zoom in and out of this map, move around, and highlight each county to see its exact rate.
### Map of the unemployment rate for Indiana counties.
```{r unemployment map}
library(leaflet)
pal <- colorNumeric("viridis", NULL)
leaflet(od_all_years) %>%
addTiles() %>%
addPolygons(stroke = FALSE, smoothFactor = 0.3, fillOpacity = 0.5,
fillColor = ~pal(od_all_years$unemp_rate),
label = ~str_glue("{od_all_years$county}: {od_all_years$unemp_rate}")) %>%
addLegend(pal = pal, values=od_all_years$unemp_rate, opacity = 1.0)
```
***
The map to the left shows the unemployement rate for each Indiana county.
You can zoom in and out of this map, move around, and highlight each county to see its exact rate.
### Scatterplot comparing overdose death and unemployment in Indiana counties.
```{r scatterplot}
library(plotly)
p <- od_all_years %>%
ggplot() +
aes(x = unemp_rate, y = od_rate, size=population,
text = str_glue("{county}
population : {population}
unemployment rate : {unemp_rate}
overdoses per 10K : {od_rate}")) +
geom_point() +
labs(x="Unemployment rate",
y = "Overdoses per 10,000",
title = "Drug Overdose Deaths vs. Unemployment Rate")
ggplotly(p, tooltip = "text")
```
***
This scatterplot shows each Indiana county's unemployment rate by its overdose rate per 10,000 people with the size of each dot corresponding to that county's population. You can see the exact numbers by hovering or clicking on each dot.
We can see that overdose deaths are not very correlated with unemployment rate in Indiana. In fact the correlation coefficient $R = `r cor(od_all_years$unemp_rate, od_all_years$od_rate)`$.
This means that the unemployment rate only explains $R^2 \approx$
`r label_percent()(cor(od_all_years$unemp_rate, od_all_years$od_rate)^2)` of the variance of the overdose rate using a linear model.
### About the author
```{r about-me}
knitr::include_graphics("images/ryan-PR.jpg")
```
***
Each drug overdose is a tragedy, but hopefully more transparency will help more people collaborate to bring those numbers down.
My name is Dr. Ryan T. Johnson. I'm a professor at Grace College during the school year, and during the summer I work as a data science consultant at Toby Lemon https://www.tobylemon.com/.