1. Final Dataset Integration and Epidemiological Metrics

Final datasets are joined into the morbidity_popclean_combined dataset based on the code below, with calculation of any remaining data elements needed for analysis.

To prevent many-to-many row duplication, pop_clean.csv is aggregated across single-year ages to match the unique demographic strata (county, age_cat, sex, and race_ethnicity) in morbidity_combined.csv, followed by joining the datasets and calculating incidence rates and case severity proportions.

# 1. FIX: Aggregate pop_clean across single-year ages so each demographic 
# group appears once (3,248 rows)
pop_clean_grouped <- pop_clean %>%
  mutate(county = trimws(county)) %>%
  group_by(county, health_officer_region, age_cat, sex, race_ethnicity) %>%
  summarise(pop = sum(pop, na.rm = TRUE), .groups = "drop")

# 2. Join datasets cleanly without duplicating rows (100,688 rows)
morbidity_popclean_combined <- morbidity_combined %>%
  mutate(county = trimws(county)) %>%
  left_join(
    pop_clean_grouped,
    by = c("county", "age_cat", "sex", "race_ethnicity") ) %>%
  mutate(
    # Recode race_ethnicity codes to readable labels
    race_label = case_when(
      race_ethnicity == 1 ~ "White, Non-Hispanic",
      race_ethnicity == 2 ~ "Black, Non-Hispanic",
      race_ethnicity == 3 ~ "American Indian / Alaska Native",
      race_ethnicity == 4 ~ "Asian",
      race_ethnicity == 5 ~ "Native Hawaiian / Pacific Islander",
      race_ethnicity == 6 ~ "Multiracial",
      race_ethnicity == 7 ~ "Hispanic / Latino",
      TRUE ~ "Unknown" ),
    
    # Capture both "18-49" and "50-64" so Adults are not turned into NA
    age_group = case_when(
      age_cat == "0-17" ~ "Children",
      age_cat %in% c("18-49", "50-64") ~ "Adults",
      age_cat == "65+" ~ "Older adults",
      TRUE ~ NA_character_  ),
    
# 3. Calculate Rates per 100,000 population
    incidence_rate = (new_infections / pop) * 100000,
    cumulative_rate = (cumulative_infected / pop) * 100000,
    severe_rate = (new_severe / pop) * 100000,
    cumulative_severe_rate = (cumulative_severe / pop) * 100000,
    # Case severity proportions
    severe_proportion = if_else(new_infections > 0, 
                                new_severe / new_infections, NA_real_),
    cumulative_severe_proportion = if_else(cumulative_infected > 0, 
    cumulative_severe / cumulative_infected, NA_real_))

# 4. Summary object name pointing to the fixed dataset
morbidity_summaries <- morbidity_popclean_combined

# 5. Check structure (should show 100,688 obs., NOT 2.7 million)
str(morbidity_popclean_combined)
## tibble [100,688 × 23] (S3: tbl_df/tbl/data.frame)
##  $ county                      : chr [1:100688] "Alameda" "Alameda" "Alameda" "Alameda" ...
##  $ age_cat                     : chr [1:100688] "0-17" "0-17" "0-17" "0-17" ...
##  $ sex                         : chr [1:100688] "Female" "Female" "Female" "Female" ...
##  $ race_ethnicity              : num [1:100688] 1 1 1 1 1 1 1 1 1 1 ...
##  $ dt_diagnosis                : Date[1:100688], format: "2023-05-29" "2023-06-05" ...
##  $ time_int                    : num [1:100688] 202322 202323 202324 202325 202326 ...
##  $ new_infections              : num [1:100688] 6 1 2 10 19 25 23 18 22 35 ...
##  $ cumulative_infected         : num [1:100688] 6 7 9 19 38 63 86 104 126 161 ...
##  $ new_unrecovered             : num [1:100688] 0 1 0 0 0 1 0 1 1 1 ...
##  $ cumulative_unrecovered      : num [1:100688] 0 1 1 1 1 2 2 3 4 5 ...
##  $ new_severe                  : num [1:100688] 0 0 1 0 0 0 0 0 0 0 ...
##  $ cumulative_severe           : num [1:100688] 0 0 1 1 1 1 1 1 1 1 ...
##  $ dt_report                   : logi [1:100688] NA NA NA NA NA NA ...
##  $ health_officer_region       : chr [1:100688] "Bay Area" "Bay Area" "Bay Area" "Bay Area" ...
##  $ pop                         : num [1:100688] 34155 34155 34155 34155 34155 ...
##  $ race_label                  : chr [1:100688] "White, Non-Hispanic" "White, Non-Hispanic" "White, Non-Hispanic" "White, Non-Hispanic" ...
##  $ age_group                   : chr [1:100688] "Children" "Children" "Children" "Children" ...
##  $ incidence_rate              : num [1:100688] 17.57 2.93 5.86 29.28 55.63 ...
##  $ cumulative_rate             : num [1:100688] 17.6 20.5 26.4 55.6 111.3 ...
##  $ severe_rate                 : num [1:100688] 0 0 2.93 0 0 ...
##  $ cumulative_severe_rate      : num [1:100688] 0 0 2.93 2.93 2.93 ...
##  $ severe_proportion           : num [1:100688] 0 0 0.5 0 0 0 0 0 0 0 ...
##  $ cumulative_severe_proportion: num [1:100688] 0 0 0.1111 0.0526 0.0263 ...

2. Visualizations

Visualizations created for (a) Print quality table (b) Print quality plot #1: Morbidity heat map (c) Print quality plot #2: epi curve

Code is included.

Haven’s Visualization: Heat Map of Infections Across CA Counties

Interpretation: This is a heat map showing numbers of new infections of a novel respiratory disease by CA county in 2023. Southern CA counties such as Los Angeles, San Bernardino, Riverside, Orange, San Diego, and Kern; and Bay-Area counties including Contra Costa, San Joaquin, Alameda, and Santa Clara, had higher case numbers over that time period.

options(tigris_use_cache = TRUE)

ca_counties <- counties(
  state = "CA",
  cb = TRUE,
  year = 2024
)

maps_morbidity <- county_morbidity <- morbidity_popclean_combined %>%
  group_by(county) %>%
  summarise(
    total_cases = sum(new_infections, na.rm = TRUE),
    .groups = "drop"
  ) %>%
  mutate(county = trimws(county))

ca_morbidity_map <- ca_counties %>%
  left_join(
    county_morbidity,
    by = c("NAME" = "county")
  )

ggplot(ca_morbidity_map) +
  geom_sf(aes(fill = total_cases), color = "white",
          linewidth = 0.2) +
  scale_fill_viridis(
    option = "magma",
    name = "Number of New infections",
    na.value = "grey90",  labels = scales::comma
  ) +
  labs(
    title = "Morbidity Distribution Across CA Counties",
    subtitle = "Total new infections by County, 2023",
    caption = "Source: Morbidity dataset"
  ) +
  theme_void() +
  theme(
    plot.title = element_text(
      size = 16, face = "bold", hjust = 0.5
    ),
    plot.subtitle = element_text(hjust = 0.5),
    legend.position = "right"
  ) 

Giselle’s Visualization: Table of Cumulative Outbreak Burden and Severity by Race/Ethnicity

Interpretation: This table displays the cumulative incidence of the novel respiratory disease by ethnicity in CA in 2023. American Indians/Native Alaskans, followed by White non-Hispanics and Black non-Hispanics, had the highest cumulative incidence of disease. White non-Hispanics had the highest proportion of severe disease cases (aong total cases) at 3.57%.

# Identify the final surveillance date in the dataset (2023-12-25)

latest_date <- max(morbidity_popclean_combined$dt_diagnosis, na.rm = TRUE)

# Summarize cumulative infections, incidence rate, 
# and severity by Race/Ethnicity

race_summary_table <- morbidity_popclean_combined %>%
  filter(dt_diagnosis == latest_date) %>%
  group_by(`Race / Ethnicity` = race_label) %>%
  summarise(
    `Total Population` = sum(pop, na.rm = TRUE),
    `Cumulative Infections` = sum(cumulative_infected, na.rm = TRUE),
    `Cumulative Incidence Rate (per 100k)` = 
      (`Cumulative Infections` / `Total Population`) * 100000,
    `Cumulative Severe Cases` = sum(cumulative_severe, na.rm = TRUE),
    `Severe Case Proportion (%)` = 
      (`Cumulative Severe Cases` / `Cumulative Infections`) * 100,
    .groups = "drop"
  ) %>%
  arrange(desc(`Cumulative Incidence Rate (per 100k)`))

# Format as a stand-alone, print-quality table

race_summary_table %>%
  mutate(
    `Total Population` = scales::comma(`Total Population`),
    `Cumulative Infections` = scales::comma(`Cumulative Infections`),
    `Cumulative Incidence Rate (per 100k)` = 
      scales::number(`Cumulative Incidence Rate (per 100k)`, 
                     accuracy = 0.1, big.mark = ","),
    `Cumulative Severe Cases` = scales::comma(`Cumulative Severe Cases`),
    `Severe Case Proportion (%)` = 
      scales::number(`Severe Case Proportion (%)`, accuracy = 0.01)
  ) %>%
  kable(
    caption = paste0("Table 1. Cumulative Novel Respiratory Disease Burden and 
                     Severity by Race/Ethnicity in California 
                     (Through ", latest_date, ")"),
    align = c("l", "r", "r", "r", "r", "r")
  ) %>%
  kable_styling(
    bootstrap_options = c("striped", "hover", "condensed", "responsive"),
    full_width = FALSE,
    position = "center"
  ) %>%
  footnote(
    general = "Source: California Department of Public Health (CDPH) 
    Simulated Outbreak & 2023 Population Datasets. 
    Rates are calculated per 100,000 residents.",
    general_title = "Note: "
  )
Table 1. Cumulative Novel Respiratory Disease Burden and Severity by Race/Ethnicity in California (Through 2023-12-25)
Race / Ethnicity Total Population Cumulative Infections Cumulative Incidence Rate (per 100k) Cumulative Severe Cases Severe Case Proportion (%)
American Indian / Alaska Native 158,672 22,195 13,988.0 671 3.02
White, Non-Hispanic 13,848,282 1,778,774 12,844.7 63,448 3.57
Black, Non-Hispanic 2,211,518 271,836 12,291.8 7,118 2.62
Hispanic / Latino 14,829,946 1,796,696 12,115.3 36,484 2.03
Native Hawaiian / Pacific Islander 153,729 16,921 11,007.0 410 2.42
Asian 6,295,420 546,770 8,685.2 16,568 3.03
Multiracial 1,611,503 116,391 7,222.5 2,227 1.91
Note:
Source: California Department of Public Health (CDPH)
Simulated Outbreak & 2023 Population Datasets.
Rates are calculated per 100,000 residents.

Tarissa’s Visualization: Epi Curve of Newly-diagnosed Infections by Age Over Time

Interpretation: This histogram is an epi curve showing the number of newly-diagnosed cases for each week between May 29th and December 25th 2023. Colors denote age group. The period between August and October, 2023, hosted the highest number of cases. In general, the highest number of newly-diagnosed cases were among adults aged 18-49 years.

library(lubridate)
library(ggplot2)

aggregate_morbidity <- morbidity_popclean_combined %>%
  group_by(dt_diagnosis, age_cat) %>%
  summarize(new_infections1 = sum(new_infections)) %>%
  ungroup()

epi_curve <- ggplot(data = aggregate_morbidity, 
                    aes(x = dt_diagnosis, y = new_infections1))+
  geom_col(aes(fill = age_cat))+
  theme_minimal()+
  labs(x = "Diagnosis Date", y = "Number of New Infections", 
       fill = "Age Category",
       title = "Newly Diagnosed Infections by Age Category, California, 2023")+
  scale_x_date(date_breaks = "6 weeks")+ 
  scale_y_continuous(labels = scales::label_comma())

epi_curve