odd_dat_raw = read.csv('VSRR_Provisional_Drug_Overdose_Death_Counts.csv', stringsAsFactors=TRUE)
odd_dat_robustnessCheck_temp = odd_dat_raw %>%
filter(Indicator !='Percent with drugs specified' & State != 'US') %>%
mutate(month_year = as.Date(paste(as.character(Year), '-', Month, sep=''))) %>%
select(State, Year, month_year, Indicator, Data.Value)
#transform PA data
PA_data = subset(odd_dat_robustnessCheck_temp, State == "PA") %>%
filter(Indicator == "Number of Drug Overdose Deaths" & Year < 2025) %>%
mutate(Data.Value = ifelse(Year == 2015, Data.Value * 0.266,
ifelse(Year == 2016, Data.Value * 0.469,
ifelse(Year == 2017, Data.Value * 0.665,
ifelse(Year == 2018, Data.Value * 0.699,
ifelse(Year == 2019, Data.Value * 0.69,
ifelse(Year == 2020, Data.Value * 0.77,
ifelse( Year == 2021 | Year == 2022, Data.Value * 0.78,
ifelse(Year == 2023, Data.Value * 0.77,
ifelse(Year == 2024, Data.Value * 0.673, NA)))))))))) %>%
mutate(Indicator = "Synthetic opioids, excl. methadone (T40.4)")
#transform LA data
LA_data = read.csv('Louisiana_fentanylDeaths.csv') %>%
pivot_longer(cols = starts_with("X"), names_to = "month", values_to = "Raw.Value") %>%
mutate(month = str_extract(month, "\\d{2}") |> as.integer(), month_year = make_date(Year, month, 1)) %>%
arrange(month_year) %>%
mutate(Data.Value = slide_dbl(Raw.Value, sum, .before = 11, .complete = TRUE, na.rm = TRUE),
State = "LA",
Indicator = "Synthetic opioids, excl. methadone (T40.4)") %>%
select(Year, month_year, Data.Value, State, Indicator)
#combine original data, LA transformed and PA transformed data
odd_allDat = rbind(odd_dat_robustnessCheck_temp, PA_data, LA_data) %>%
filter(month_year < '2025-08-01' & Year >2016 & Indicator == 'Synthetic opioids, excl. methadone (T40.4)') %>%
aggregate(Data.Value ~ month_year, FUN=sum) %>%
mutate(variable = 'W/ LA and PA patched') %>%
rename(date = month_year, count = Data.Value)
odd_CDC = odd_dat_robustnessCheck_temp %>%
filter(month_year < '2025-08-01' & Indicator == 'Synthetic opioids, excl. methadone (T40.4)') %>%
aggregate(Data.Value ~ month_year, FUN=sum) %>%
mutate(variable = 'Original CDC data') %>%
rename(date = month_year, count = Data.Value)
odd_dat_robustnessCheck = rbind(odd_allDat, odd_CDC)
ggplot(data = odd_dat_robustnessCheck, aes(x = date, color=variable, y = count)) +
geom_line(linewidth = 1.5)+
labs(title="Original CDC data vs Patched data to include PA and LA", y = 'Overdose Deaths', x = '', color='', subtitle = 'Rolling 12-month sum') +
scale_x_date(date_breaks = "6 months", date_labels = "%b %Y", limits = as.Date(c("2015-12-01","2025-06-01")))+
theme_minimal(base_size=15)+
theme(axis.ticks.length = unit(0.2, "cm"), axis.text.x = element_text(angle = 45, hjust = 1))+
geom_vline(xintercept=as.numeric(as.Date('2022-08-01')), linetype='dashed')+
geom_text(x = as.numeric(as.Date('2022-07-01')), y = 40000, label = "Operation Mongoos Azeteca begins", angle=90, color='black', check_overlap = TRUE, size=3.5)+
geom_vline(xintercept=as.numeric(as.Date('2023-01-05')), linetype='dashed')+
geom_text(x = as.numeric(as.Date('2022-12-01')), y = 50000, label = "El Raton captured", angle=90, color='#0B1F3A', check_overlap = TRUE, size=3.5)+
geom_vline(xintercept=as.numeric(as.Date('2023-05-01')), linetype='dashed')+
geom_text(x = as.numeric(as.Date('2023-04-01')), y = 55000, label = "Los Chapitos bans fentanyl", angle=90, color='#0B1F3A', check_overlap = TRUE, size=3.5)