knitr::opts_knit$set(root.dir = 'C:/Users/jkempke/Box Sync/Side Projects/MCOD/Tidy Data')
knitr::opts_chunk$set(warning = F)
library(leaflet)
library(dplyr)
library(ggplot2)
library(knitr)

Description

The CDC WONDER data sets aggregate statistics from US death certificates. In the below descriptive analyses I start with the colloquial question: “are there states where there are higher incidences of sepsis mortality?”. While others have demosntrated sepsis mortality clusters in the US, one important method that was not accounted for was whether this reflected the elevated underlying all cause mortality or was specific to sepsis. Therefore in the below analyses I calculate mortality ratios of the age-adjusted cause specific mortality rate divided by the state’s all cause age-adjusted mortality rate to examine if this highlights where there may be excess sepsis mortality. Sepsis is ill-defined in ICD-10 coding for death certificates so I use alternative case definitions of septicemia only (A40-A41), influenza and pneumonia (J09-J18), and a combined definition.

In conjunction with analyses we published in Critical Care, these data can help to make decisions about which state’s HCUP SIDs to buy to examine the effect of SEP-1 and AHA variables on septicemia mortality. Teh HCUP 2017 SID catalog available for purchase is available here.

Data sets Construction

Select button on the right to expand code.

states.map <- 
  geojsonio::geojson_read("F:/Side Projects 2019/Medicare/data/json/gz_2010_us_040_00_5m.json", what = "sp")


sepsis2017 <- read.csv('MCOD 2017 Septicemia States.csv',
                       stringsAsFactors = T)

sepsis2017 <- sepsis2017 %>%
  rename(
    NAME = State,
    sepsis.adjusted = Age.Adjusted.Rate,
    sepsis.deaths = Deaths
  ) %>%
  select(
    NAME,
    sepsis.adjusted,
    sepsis.deaths)
all2017 <- read.csv("MCOD 2017 All Cause States.csv",
                    stringsAsFactors = T)

flupna2017 <- read.csv('MCOD 2017 flupna States.csv',
                       stringsAsFactors = T)

flupna2017 <- flupna2017 %>%
  rename(
    NAME = State,
    flupna.adjusted = Age.Adjusted.Rate
  ) %>%
  select(
    NAME,
    flupna.adjusted)

both2017 <- read.csv('MCOD 2017 Septicemia n Flupna States.csv',
                       stringsAsFactors = T)

both2017 <- both2017 %>%
  rename(
    NAME = State,
    both.adjusted = Age.Adjusted.Rate
  ) %>%
  select(
    NAME,
    both.adjusted)

all2017 <- all2017 %>%
  rename(
    NAME = State,
    all.adjusted = Age.Adjusted.Rate
  ) %>%
  select(
    NAME,
    all.adjusted)

mcod2017 <- left_join(both2017, all2017, by = 'NAME')

mcod2017 <- left_join(sepsis2017, mcod2017, by = 'NAME')

mcod2017 <- left_join(flupna2017, mcod2017, by = 'NAME')

mcod2017 <- mcod2017 %>%
  mutate(
    sepsis.adjusted.ratio = round(sepsis.adjusted/all.adjusted, digits = 2),
    flupna.adjusted.ratio = round(flupna.adjusted/all.adjusted, digits = 2),
    both.adjusted.ratio = round(both.adjusted/all.adjusted, digits = 2)
  ) %>%
  arrange(flupna.adjusted.ratio)

states.map@data <- left_join(
  states.map@data,
  mcod2017,
  by = "NAME")

All Cause Mortality

This is a state-level map of the Age-Adjusted Mortality Rates per100,000 persons in the year of 2017. This serves as a visualization of the denominator for each of the calculated ratios below.

pal0 <- colorNumeric(palette = "magma", 
                     domain = states.map@data$all.adjusted) 

leaflet(data=states.map)%>%
 addProviderTiles(providers$Esri.WorldGrayCanvas)%>%
  addPolygons(fillColor = ~pal0(all.adjusted),
             color = "black",
            weight = 1,
           smoothFactor = 0.2,
          fillOpacity = 0.75,
         stroke = TRUE,
        label = ~paste(NAME, all.adjusted, " per100K"),
       highlight = highlightOptions(
        weight = 5,
       color="black",
      bringToFront = TRUE))%>%
addLegend("bottomright",
         pal = pal0,
        values = ~all.adjusted,
       title = "All Cause Age-Adj Deaths",
      labFormat = labelFormat(suffix = " per100K"),
     opacity = 1)%>%
  setView(-90, 40, 4)

Septicemia

These represent deaths with diagnostic codes for septicemia (A40-A41) among any of the listed causes of death. The first map is the age-adjusted death rates while the second map is the ratio of this age-adjusted septicemia death rate to the all-cause age-adjusted death rate o the state.

pal1 <- colorNumeric(palette = "magma", 
                     domain = states.map@data$sepsis.adjusted) 

leaflet(data=states.map)%>%
 addProviderTiles(providers$Esri.WorldGrayCanvas)%>%
  addPolygons(fillColor = ~pal1(sepsis.adjusted),
             color = "black",
            weight = 1,
           smoothFactor = 0.2,
          fillOpacity = 0.75,
         stroke = TRUE,
        label = ~paste(NAME, sepsis.adjusted, " per100K"),
       highlight = highlightOptions(
        weight = 5,
       color="black",
      bringToFront = TRUE))%>%
addLegend("bottomright",
         pal = pal1,
        values = ~sepsis.adjusted,
       title = "Sepsis Age-Adj Deaths",
      labFormat = labelFormat(suffix = " per100K"),
     opacity = 1)%>%
  setView(-90, 40, 4)
pal1 <- colorNumeric(palette = "magma", 
                     domain = states.map@data$sepsis.adjusted.ratio) 

leaflet(data=states.map)%>%
 addProviderTiles(providers$Esri.WorldGrayCanvas)%>%
  addPolygons(fillColor = ~pal1(sepsis.adjusted.ratio),
             color = "black",
            weight = 1,
           smoothFactor = 0.2,
          fillOpacity = 0.75,
         stroke = TRUE,
        label = ~paste(NAME, "<br>ratio =", sepsis.adjusted.ratio),
       highlight = highlightOptions(
        weight = 5,
       color="black",
      bringToFront = TRUE))%>%
addLegend("bottomright",
         pal = pal1,
        values = ~sepsis.adjusted.ratio,
       title = "Sepsis to All Cause Age-Adj Ratios",
     opacity = 1)%>%
  setView(-90, 40, 4)

Influenza and Pneumonia

These represent deaths with diagnostic codes for influenza and pneumonia (J09-J18) among any of the listed causes of death. The first map is the age-adjusted death rates while the second map is the ratio of this age-adjusted influenza and pneumonia death rate to the all-cause age-adjusted death rate o the state.

pal2 <- colorNumeric(palette = "magma", 
                     domain = states.map@data$flupna.adjusted) 

leaflet(data=states.map)%>%
 addProviderTiles(providers$Esri.WorldGrayCanvas)%>%
  addPolygons(fillColor = ~pal2(flupna.adjusted),
             color = "black",
            weight = 1,
           smoothFactor = 0.2,
          fillOpacity = 0.75,
         stroke = TRUE,
        label = ~paste(NAME, "ratio =", flupna.adjusted),
       highlight = highlightOptions(
        weight = 5,
       color="black",
      bringToFront = TRUE))%>%
addLegend("bottomright",
         pal = pal2,
        values = ~flupna.adjusted,
       title = "Flu & Pna Age-Adj Deaths",
      labFormat = labelFormat(suffix = " per100K"),
     opacity = 1)%>%
  setView(-90, 40, 4)
pal2 <- colorNumeric(palette = "magma", 
                     domain = states.map@data$flupna.adjusted.ratio) 

leaflet(data=states.map)%>%
 addProviderTiles(providers$Esri.WorldGrayCanvas)%>%
  addPolygons(fillColor = ~pal2(flupna.adjusted.ratio),
             color = "black",
            weight = 1,
           smoothFactor = 0.2,
          fillOpacity = 0.75,
         stroke = TRUE,
        label = ~paste(NAME, "ratio =", flupna.adjusted.ratio),
       highlight = highlightOptions(
        weight = 5,
       color="black",
      bringToFront = TRUE))%>%
addLegend("bottomright",
         pal = pal2,
        values = ~flupna.adjusted.ratio,
       title = "Flu & Pna to All Cause Age-Adj Ratios",
     opacity = 1)%>%
  setView(-90, 40, 4)

Septicemia, Influenza, or Pneumonia

These represent deaths with diagnostic codes for septicemia (A40-A41) or influenza and pneumonia (J09-J18)among any of the listed causes of death. The first map is the age-adjusted death rates while the second map is the ratio of this age-adjusted death rate to the all-cause age-adjusted death rate o the state.

pal3 <- colorNumeric(palette = "magma", 
                     domain = states.map@data$both.adjusted) 

leaflet(data=states.map)%>%
 addProviderTiles(providers$Esri.WorldGrayCanvas)%>%
  addPolygons(fillColor = ~pal3(both.adjusted),
             color = "black",
            weight = 1,
           smoothFactor = 0.2,
          fillOpacity = 0.75,
         stroke = TRUE,
        label = ~paste(NAME, both.adjusted, " per100K"),
       highlight = highlightOptions(
        weight = 5,
       color="black",
      bringToFront = TRUE))%>%
addLegend("bottomright",
         pal = pal3,
        values = ~both.adjusted,
       title = "Sepsis or Flu & Pna Deaths",
      labFormat = labelFormat(suffix = " per100K"),
     opacity = 1)%>%
  setView(-90, 40, 4)
pal3 <- colorNumeric(palette = "magma", 
                     domain = states.map@data$both.adjusted.ratio) 

leaflet(data=states.map)%>%
 addProviderTiles(providers$Esri.WorldGrayCanvas)%>%
  addPolygons(fillColor = ~pal3(both.adjusted.ratio),
             color = "black",
            weight = 1,
           smoothFactor = 0.2,
          fillOpacity = 0.75,
         stroke = TRUE,
        label = ~paste(NAME, "ratio =", both.adjusted.ratio),
       highlight = highlightOptions(
        weight = 5,
       color="black",
      bringToFront = TRUE))%>%
addLegend("bottomright",
         pal = pal3,
        values = ~both.adjusted.ratio,
       title = "Sepsi or Flu & Pna to All Cause Age-Adj Ratios",
     opacity = 1)%>%
  setView(-90, 40, 4)

States Septicemia Death Totals

sepsis2017 <- arrange(sepsis2017, desc(sepsis.deaths))

kable(sepsis2017, type="markdown", caption = "Total Number of Septicemia Deaths by State")
Total Number of Septicemia Deaths by State
NAME sepsis.adjusted sepsis.deaths
California 51.4 22301
Texas 66.1 17955
Florida 43.5 13351
New York 44.6 11190
Pennsylvania 50.8 8990
Illinois 52.3 7998
Ohio 53.0 7857
North Carolina 58.1 7032
New Jersey 57.4 6480
Georgia 59.7 6381
Michigan 48.3 6108
Tennessee 65.8 5252
Virginia 53.3 5135
Indiana 60.3 4702
Kentucky 83.7 4448
South Carolina 67.3 4141
Massachusetts 46.8 4081
Washington 48.5 4043
Alabama 65.7 3912
Missouri 48.3 3703
Louisiana 68.2 3593
Maryland 47.3 3341
Arizona 38.5 3311
Oklahoma 71.4 3267
Wisconsin 38.9 2861
Mississippi 78.3 2701
Arkansas 69.5 2557
Colorado 43.6 2537
Connecticut 50.5 2447
Minnesota 34.0 2295
Nevada 60.9 2023
West Virginia 77.1 1943
Oregon 36.0 1865
Iowa 45.1 1848
Kansas 52.2 1844
New Mexico 50.9 1270
Utah 45.2 1164
Nebraska 42.7 1004
Idaho 38.5 738
Maine 36.7 714
New Hampshire 38.7 693
Rhode Island 46.0 652
Delaware 48.5 621
Hawaii 31.6 599
Montana 41.6 571
South Dakota 48.1 515
District of Columbia 63.0 426
North Dakota 39.6 366
Wyoming 49.9 339
Vermont 30.2 264
Alaska 39.9 247