Project_Milestone4

Author

Liza Lutker and Emily Liu

Joining Data

Code to join data sets and provide appropriate labels for table output.

# names(ed_summary)

# Join datasets using variable "county_name"
# NOTES:(1) Drop small racial and ethnic groups with suppressed cells. Keep White, Black, and Hispanic, and overall ED asthma rates. (2) Add labels to table variables. 

joined_data <- ces_score_summary %>% 
  left_join(., ces_measures_summary, by = "county_name") %>%
  left_join(., ed_summary, by = "county_name") %>%
  select(-c(api, aian, nhpi, multi)) %>% 
  set_variable_labels(
  median_ces_perc_county = "Median CES score percentile", 
  median_ces_abv_perc_50th = "Median CES score, 50th percentile and above", 
  pm_25_mean = "Mean PM2.5",
  traffic_median = "Traffic median",
  poverty_perc_mean = "Mean poverty",
  poverty_abv_75th = "Mean poverty above 75th percentile",
  total = "Total age-adjusted rate of ED asthma visits",
  white = "Age-adjusted rate of ED asthma visits - White patients",
  black = "Age-adjusted rate of ED asthma visits - Black patients",
  hisp = "Age-adjusted rate of ED asthma visits - Hispanic patients"
)

str(joined_data)
tibble [58 × 13] (S3: tbl_df/tbl/data.frame)
 $ county_name             : chr [1:58] "ALAMEDA" "ALPINE" "AMADOR" "BUTTE" ...
 $ median_ces_perc_county  : num [1:58] 39.2 22 36.6 41 28.3 ...
  ..- attr(*, "label")= chr "Median CES score percentile"
 $ median_ces_abv_perc_75th: Factor w/ 2 levels "Below","Above": 1 1 1 1 1 1 1 1 1 2 ...
 $ median_ces_abv_perc_50th: Factor w/ 2 levels "Below","Above": 1 1 1 1 1 2 1 1 1 2 ...
  ..- attr(*, "label")= chr "Median CES score, 50th percentile and above"
 $ median_ces_blw_perc_25th: Factor w/ 2 levels "Below","Above": 1 2 1 1 1 1 1 1 2 1 ...
 $ pm_25_mean              : num [1:58] 8.87 3.05 8.01 8.22 8.12 ...
  ..- attr(*, "label")= chr "Mean PM2.5"
 $ traffic_median          : num [1:58] 928 70.2 212.7 455.3 214.8 ...
  ..- attr(*, "label")= chr "Traffic median"
 $ poverty_perc_mean       : num [1:58] 34.6 67.4 43.5 64.6 48.8 ...
  ..- attr(*, "label")= chr "Mean poverty"
 $ poverty_abv_75th        : Factor w/ 2 levels "No","Yes": 1 1 1 1 1 1 1 2 1 1 ...
  ..- attr(*, "label")= chr "Mean poverty above 75th percentile"
 $ total                   : num [1:58] 25.8 0 31.2 24.2 30.4 24 27.5 40.6 20.6 34 ...
  ..- attr(*, "label")= chr "Total age-adjusted rate of ED asthma visits"
 $ white                   : num [1:58] 13.1 0 37.6 21.4 30 30.6 15 50.3 20.6 26.3 ...
  ..- attr(*, "label")= chr "Age-adjusted rate of ED asthma visits - White patients"
 $ black                   : num [1:58] 89.8 0 NA 134.4 NA ...
  ..- attr(*, "label")= chr "Age-adjusted rate of ED asthma visits - Black patients"
 $ hisp                    : num [1:58] 23.4 0 NA 19.7 30.2 15.2 28.9 34.1 19.8 34.7 ...
  ..- attr(*, "label")= chr "Age-adjusted rate of ED asthma visits - Hispanic patients"

Table 1

Code for output table.

#Table Output
joined_data %>% 
  select(-c(county_name, median_ces_abv_perc_75th, median_ces_blw_perc_25th)) %>% 
  tbl_summary(by = median_ces_abv_perc_50th,
              missing_text = "Rate suppressed for small cell count") %>% 
  add_overall() %>%
  add_n() %>%
  modify_header(label ~ "**Variable**") %>%
  modify_spanning_header(c("stat_1", "stat_2") ~ 
  "**Median CES score above 50th percentile**") %>%
  modify_footnote(
    all_stat_cols() ~ "Median (IQR) or Frequency (%)"
  ) %>%
  modify_caption("**Table 1. County Characteristics**") %>%
  bold_labels()
Table 1. County Characteristics
Variable N Overall, N = 581 Median CES score above 50th percentile
Below, N = 411 Above, N = 171
Median CES score percentile 58 36 (26, 52) 31 (25, 36) 71 (57, 77)
Mean PM2.5 58 8.16 (6.57, 9.10) 7.62 (5.97, 8.52) 11.07 (8.18, 11.70)
Traffic median 58 516 (268, 719) 455 (215, 805) 533 (435, 567)
Mean poverty 58 57 (44, 68) 49 (39, 59) 68 (64, 72)
Mean poverty above 75th percentile 58 4 (6.9%) 2 (4.9%) 2 (12%)
Total age-adjusted rate of ED asthma visits 57 25 (20, 33) 25 (17, 32) 28 (25, 33)
    Rate suppressed for small cell count
1 1 0
Age-adjusted rate of ED asthma visits - White patients 57 22 (16, 29) 21 (15, 30) 26 (22, 27)
    Rate suppressed for small cell count
1 1 0
Age-adjusted rate of ED asthma visits - Black patients 42 80 (56, 100) 66 (52, 99) 100 (81, 111)
    Rate suppressed for small cell count
16 12 4
Age-adjusted rate of ED asthma visits - Hispanic patients 51 25 (20, 31) 22 (18, 29) 26 (24, 32)
    Rate suppressed for small cell count
7 7 0
1 Median (IQR) or Frequency (%)

TABLE INTERPRETATION: Counties with CES median scores above the 50th percentile appear to have higher mean PM 2.5, higher median traffic, and more poverty. Additionally, these counties have higher age-adjusted rates of ED asthma visits total and stratified by racial and ethnic group.

Plots

Figures 1-3

Code for output figures.

race.lab <- c("White", "Black", "Hispanic", "All Races")
names(race.lab) <- c("white", "black", "hisp", "total")

ces50_plot <- joined_data %>% 
  select(c(county_name, median_ces_abv_perc_50th, total, white, black, hisp)) %>% 
  pivot_longer(!c(county_name, median_ces_abv_perc_50th), 
               names_to = "race", values_to = "rates") %>% 
  mutate(across(race, ~factor(., levels=c("white", "black", "hisp", "total")))) %>% 
  ggplot(aes(x = median_ces_abv_perc_50th, y = rates)) +
           geom_boxplot(aes(fill = race, alpha = median_ces_abv_perc_50th)) +
            facet_grid(. ~ race, labeller = labeller(race = race.lab)) + 
              scale_alpha_discrete(
     range = c(0.5, 1.3),
     guide = guide_legend(override.aes = list(fill = "black"))) +
  ggtitle("Fig. 1: County-Level ED Asthma Rates and CalEnviroScreen (CES) \nScores above/below the 50th Percentile, by Race/Ethnicity, 2020") +
  xlab("County Median CES Score compared to the Statewide 50th Percentile") + ylab("Age-Adjusted ED Asthma Rates") + 
  labs(fill = "Race/Ethnicity", alpha = "CES Score relative to 50th %ile") +
       scale_fill_discrete(labels=c("White", "Black", "Hispanic", "All Races")) + 
  theme(legend.position = "none")
ces50_plot

ces75_plot <- joined_data %>% 
  select(c(county_name, median_ces_abv_perc_75th, total, white, black, hisp)) %>% 
  pivot_longer(!c(county_name, median_ces_abv_perc_75th), 
               names_to = "race", values_to = "rates") %>% 
  mutate(across(race, ~factor(., levels=c("white", "black", "hisp", "total")))) %>% 
  ggplot(aes(x = median_ces_abv_perc_75th, y = rates)) +
           geom_boxplot(aes(fill = race, alpha = median_ces_abv_perc_75th)) +
            facet_grid(. ~ race, labeller = labeller(race = race.lab)) + 
              scale_alpha_discrete(
     range = c(0.5, 1.3),
     guide = guide_legend(override.aes = list(fill = "black")))  +
  ggtitle("Fig. 2: County-Level ED Asthma Rates and CalEnviroScreen (CES) \nScores above/below the 75th Percentile, by Race/Ethnicity, 2020") +
  xlab("County Median CES Score compared to the Statewide 75th Percentile") + ylab("Age-Adjusted ED Asthma Rates") + 
  labs(fill = "Race/Ethnicity", alpha = "CES Score relative to 75th %ile") +
       scale_fill_discrete(labels=c("White", "Black", "Hispanic", "All Races"))  + 
  theme(legend.position = "none")
ces75_plot

pov_plot <- joined_data %>% 
  select(c(county_name, poverty_abv_75th, total, white, black, hisp)) %>% 
  pivot_longer(!c(county_name, poverty_abv_75th), 
               names_to = "race", values_to = "rates") %>% 
  mutate(across(race, ~factor(., levels=c("white", "black", "hisp", "total")))) %>% 
  ggplot(aes(x = poverty_abv_75th, y = rates)) +
           geom_boxplot(aes(fill = race, alpha = poverty_abv_75th)) +
            facet_grid(. ~ race, labeller = labeller(race = race.lab)) + 
              scale_alpha_discrete(
     range = c(0.5, 1.3),
     guide = guide_legend(override.aes = list(fill = "black")))  +
  ggtitle("Fig. 3: County-Level ED Asthma Rates and Poverty \nabove the 75th Percentile, by Race/Ethnicity, 2020") +
  xlab("County Mean Poverty above the Statewide 75th Percentile") + ylab("Age-Adjusted ED Asthma Rates") + 
  labs(fill = "Race/Ethnicity", alpha = "Poverty above the 75th %ile") +
       scale_fill_discrete(labels=c("White", "Black", "Hispanic", "All Races"))  + 
  theme(legend.position = "none")
pov_plot

INTERPRETATION OF FIGURES: Overall, asthma ED rates are much higher among Black Californians compared to White or Hispanic Californians, and also compared to all races combined, and asthma ED rates are consistently higher in those counties with higher environmental burden (measured by median CES values above either the statewide 50th or 75th percentile) and those counties with higher levels of poverty (measured as mean poverty above the statewide 75th percentile). The interactive effect between race and either environmental burden or poverty is most pronounced for Black Californians and across both environmental measures, for Hispanic Californians and median CES values above the statewide 75th percentile measure, and for all Californians (both overall and for all three race/ethnicities examined) and the poverty measure.