Your task is to utilize these datasets to create county-level measures to accomplish two goals.
The first is to compare county asthma ED rates with a county CES measure to assess if there appears to be a correlation. (Sadia)
The second is to compare asthma ED rates with county-level summaries for specific environmental measures to determine if those specific measures may be worth further investigation. (Yijun)
Join all datasets together
Calculate any remaining data elements needed for analysis
Show code used to create joined dataset, but please do not print full data frame output (showing data structure with str() is okay)
We selected the following columns from each data and joined them together:
ces_measure: pm2.5, drinking_water, haz_waste
ces_scores_demog: ces_4_0_score
chhs_asthma: age_adjusted ED visit rate, most recent year = 2020, total population
# data cleaning for ces_measure: uniform county name & recategorize to county level
ces_measure_prep <- ces_measure %>%
rename(county = california_county) %>%
group_by(county) %>%
summarise(avg_pm2_5 = mean(pm2_5, na.rm = TRUE),
avg_drinking_water = mean(drinking_water, na.rm = TRUE),
avg_haz_waste = mean(haz_waste, na.rm = TRUE))
# data cleaning for ces_scores_demog: uniform county name & recategorize to county level
ces_scores_demog_prep <- ces_scores_demog %>%
mutate(county = str_remove(county, " County")) %>%
group_by(county) %>%
summarise(avg_ces_score = weighted.mean(ces_4_0_score,
w = total_population,
na.rm = TRUE))
# data cleaning for asthma data: used total_population & year = 2020 &
chhs_asthma_prep <- chhs_asthma %>%
mutate(county = str_to_title(str_trim(county))) %>%
filter(county != "California",
strata == "Total population",
year == 2020) %>%
select(county, age_adjusted_ed_visit_rate)
# Join 3 data sets
data_joined <- chhs_asthma_prep %>%
left_join(y = ces_scores_demog_prep, by = "county") %>%
left_join(y = ces_measure_prep, by = "county")
One print quality table as requested in scenario
One print quality plot or chart as requested in scenario
Research question 2: compare asthma ED rates with county-level summaries for specific environmental measures (PM 2.5; Drinking Water; and Hazardous Waste) to determine if those specific measures may be worth further investigation.
envir_measure = c("PM 2.5", "Drinking Water", "Hazardous Waste")
correlation = c(
cor(data_joined$age_adjusted_ed_visit_rate,
data_joined$avg_pm2_5,
use = "complete.obs"),
cor(data_joined$age_adjusted_ed_visit_rate,
data_joined$avg_drinking_water,
use = "complete.obs"),
cor(data_joined$age_adjusted_ed_visit_rate,
data_joined$avg_haz_waste,
use = "complete.obs"))
p_value = c(
cor.test(data_joined$age_adjusted_ed_visit_rate,
data_joined$avg_pm2_5)$p.value,
cor.test(data_joined$age_adjusted_ed_visit_rate,
data_joined$avg_drinking_water)$p.value,
cor.test(data_joined$age_adjusted_ed_visit_rate,
data_joined$avg_haz_waste)$p.value)
table1 <- tibble(envir_measure, correlation, p_value)
kable(table1,
col.names = c("Envirenmental Measures", "Pearson Correlation", "p-value"),
digits = c(0,2,3),
align = "lcc",
caption = "Correlation between Asthma ED Visit Rates and 3 Environmental Measures in California Counties") %>%
kable_styling(full_width = FALSE)
| Envirenmental Measures | Pearson Correlation | p-value |
|---|---|---|
| PM 2.5 | -0.07 | 0.601 |
| Drinking Water | 0.07 | 0.597 |
| Hazardous Waste | -0.18 | 0.175 |
Interpretation: The age-adjusted asthma ED visit rate showed weak correlations with PM2.5 (r = -0.07), Drinking Water (r = 0.07), and Hazardous Waste (r = -0.18), and none of these correlations were statistically significant (all p > 0.05). Based on this county-level analysis, there is no strong evidence of a association between asthma ED visit rates and these 3 environmental measures.
Research question 1: compare county asthma ED rates with county CES measure to assess if there appears to be a correlation.
# Pearson correlation between county CES score and asthma ED rate
ces_cor <- cor.test(data_joined$avg_ces_score,
data_joined$age_adjusted_ed_visit_rate)
ces_cor$estimate # correlation (r)
## cor
## 0.2645705
ces_cor$p.value # p-value
## [1] 0.04672272
# scatterplot (Sierra County removed due to no 2020 asthma ED rate)
data_joined %>%
filter(!is.na(age_adjusted_ed_visit_rate)) %>%
ggplot(aes(x = avg_ces_score, y = age_adjusted_ed_visit_rate)) +
geom_point(color = "pink", size = 2.5) +
geom_smooth(method = "lm", formula = y ~ x, color = "gray") +
labs(
title = "Asthma ED Visit Rates vs. CalEnviroScreen Score\nby California County, 2020",
subtitle = "Pearson r = 0.26, p = 0.047 (n = 57 counties)",
x = "CalEnviroScreen 4.0 Score\n(Population-Weighted County Average)",
y = "Age-Adjusted Asthma ED Visits\nper 10,000 Residents",
caption = "Line shows linear fit with 95% confidence band. Sierra County excluded (no 2020 data).\nSources: OEHHA CalEnviroScreen 4.0; CHHS Asthma ED Visit Rates by County.") +
theme_minimal() +
theme(plot.title = element_text(face = "bold"),
plot.caption = element_text(hjust = 0))
interpretation:
This scatterplot compares each California county’s population-weighted CalEnviroScreen 4.0 score with its age-adjusted asthma ED visit rate in 2020. It demonstrates a weak positive correlation (r = 0.26, p = 0.047) as counties with greater cumulative environmental burden tended to have slightly higher asthma ED rates. However, the points are widely scattered around the trend line, and some of the highest asthma ED rates (above 40 per 10,000) occurred in counties with below-average CES scores. This suggests that the overall CES score alone is not a strong predictor of county asthma ED rates and that specific environmental exposures and other county factors should be examined.