Is the mean poverty rate different among U.S. counties with no smoking ban, a partial smoking ban, and a comprehensive smoking ban?
For this project, I am using the OpenIntro
county_complete dataset. The dataset contains 3,142 U.S.
counties and 188 variables. Each row represents one county. The dataset
includes information about population, income, education, employment,
poverty, health, housing, and other county-level characteristics.
For my research question, I will focus on two variables.
poverty_2017 is a quantitative variable that represents the
percent of the county population living below the poverty level in 2017.
smoking_ban_2010 is a categorical variable that identifies
whether a county had no smoking ban, a partial smoking ban, or a
comprehensive smoking ban in 2010. The dataset comes from OpenIntro and
can be accessed at https://www.openintro.org/data/index.php?data=county_complete.
For the data analysis, I will first import and inspect the dataset. Then I will select the two variables needed for my question, remove missing values, and convert the smoking-ban variable into a factor. I will use summary statistics to compare the poverty rates across the three groups. I will also create a histogram to look at the overall poverty-rate distribution and a boxplot to compare the three smoking-ban groups.
county <- read.csv("https://www.openintro.org/data/csv/county_complete.csv")
dim(county)
## [1] 3142 188
head(county[, c("poverty_2017", "smoking_ban_2010")])
## poverty_2017 smoking_ban_2010
## 1 13.7 none
## 2 11.8 none
## 3 27.2 partial
## 4 15.2 none
## 5 15.6 none
## 6 28.5 none
df <- county |>
select(poverty_2017, smoking_ban_2010) |>
filter(!is.na(poverty_2017), !is.na(smoking_ban_2010)) |>
mutate(smoking_ban_2010 = factor(smoking_ban_2010))
dim(df)
## [1] 3114 2
summary(df)
## poverty_2017 smoking_ban_2010
## Min. : 2.40 comprehensive: 554
## 1st Qu.:11.40 none :1925
## Median :15.20 partial : 635
## Mean :15.99
## 3rd Qu.:19.40
## Max. :52.00
table(df$smoking_ban_2010)
##
## comprehensive none partial
## 554 1925 635
group_summary <- df |>
group_by(smoking_ban_2010) |>
summarise(
counties = n(),
mean_poverty = mean(poverty_2017),
median_poverty = median(poverty_2017),
sd_poverty = sd(poverty_2017)
)
group_summary
## # A tibble: 3 × 5
## smoking_ban_2010 counties mean_poverty median_poverty sd_poverty
## <fct> <int> <dbl> <dbl> <dbl>
## 1 comprehensive 554 14.6 13.6 6.14
## 2 none 1925 16.6 16.1 6.46
## 3 partial 635 15.3 14.1 6.71
ggplot(df, aes(x = poverty_2017)) +
geom_histogram(binwidth = 2, color = "black", fill = "lightblue") +
labs(
title = "Distribution of County Poverty Rates",
x = "Poverty Rate (%)",
y = "Number of Counties"
)
ggplot(df, aes(x = smoking_ban_2010, y = poverty_2017)) +
geom_boxplot(fill = "lightblue") +
labs(
title = "Poverty Rate by County Smoking Ban Type",
x = "Smoking Ban Type",
y = "Poverty Rate (%)"
)
The outcome variable, poverty_2017, is quantitative,
while smoking_ban_2010 is categorical with three
independent groups. Because I am comparing the mean poverty rate across
three groups, a one-way ANOVA is an appropriate statistical test. The
summary table helps compare the average poverty rates and variability in
each group. The histogram shows the overall distribution of poverty
rates, and the boxplot makes it easier to visually compare the three
smoking-ban groups.
The null hypothesis states that the mean poverty rate is the same for all three smoking-ban groups. The alternative hypothesis states that at least one group has a different mean poverty rate.
H₀: μₙₒₙₑ = μₚₐᵣₜᵢₐₗ = μcₒₘₚᵣₑₕₑₙₛᵢᵥₑ
Hₐ: At least one of the mean poverty rates is different.
I will use a significance level of α = 0.05.
anova_model <- aov(poverty_2017 ~ smoking_ban_2010, data = df)
anova_results <- summary(anova_model)
anova_results
## Df Sum Sq Mean Sq F value Pr(>F)
## smoking_ban_2010 2 2018 1008.9 24.21 3.67e-11 ***
## Residuals 3111 129624 41.7
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
p_value <- anova_results[[1]][["Pr(>F)"]][1]
p_value
## [1] 3.673333e-11
The ANOVA p-value is 3.673^{-11}. Since the p-value is less than 0.05, I reject the null hypothesis.
This means there is enough evidence to conclude that at least one smoking-ban group has a different mean poverty rate.
The summary statistics and boxplot allow the poverty rates of the three smoking-ban groups to be compared before running the hypothesis test. The ANOVA then tests whether the differences among the sample means are statistically significant. Based on the p-value and an alpha level of 0.05, the test determines whether the null hypothesis should be rejected.
The results should be interpreted as an association, not as proof that smoking-ban policies cause poverty rates to change. Counties can differ in many other ways, such as population size, income, education, employment, and location. These other factors may also be related to poverty and smoking-ban policies.
This project examined whether mean poverty rates differ among U.S. counties with no smoking ban, a partial smoking ban, and a comprehensive smoking ban. I cleaned the dataset, created summary statistics, used visualizations to compare the groups, and performed a one-way ANOVA. The hypothesis test gives a statistical answer to the research question using a significance level of 0.05.
For future research, I could include other county-level variables such as median household income, unemployment rate, education level, or metropolitan status. I could also compare data from different years to see whether the relationship between poverty and smoking-ban type changes over time.
OpenIntro. United States Counties
(county_complete).
https://www.openintro.org/data/index.php?data=county_complete
OpenIntro CSV dataset.
https://www.openintro.org/data/csv/county_complete.csv