library(tidyverse)
knitr::opts_chunk$set(echo = TRUE)

Introduction

Research Question: How well do median household income, unemployment rate, and bachelor’s degree attainment predict the poverty rate among U.S. counties?

This project uses the OpenIntro county_complete dataset. The dataset contains 3,142 U.S. counties and 188 variables. Each row represents one county, and the columns contain information about population, income, education, employment, poverty, and other county characteristics. For this analysis, I focus on four quantitative variables: poverty_2017, median_household_income_2017, unemployment_rate_2017, and bachelors_2017.

The outcome variable is poverty_2017, which is the percent of the county population below the poverty level in 2017. The predictors are median household income in 2017, unemployment rate in 2017, and the percent of the population that earned a bachelor’s degree in 2017. The dataset is from OpenIntro: https://www.openintro.org/data/index.php?data=county_complete

Data Analysis

I will first import and clean the data, then look at summary statistics and plots to understand the variables. I will use select(), filter(), and mutate() to prepare the data. I will also use summarise() for basic EDA. The plots will help show how each predictor is related to county poverty rate before fitting the regression model.

county <- read.csv("https://www.openintro.org/data/csv/county_complete.csv")

dim(county)
## [1] 3142  188
head(county[, c("poverty_2017", "median_household_income_2017",
                "unemployment_rate_2017", "bachelors_2017")])
##   poverty_2017 median_household_income_2017 unemployment_rate_2017
## 1         13.7                        55317                   3.86
## 2         11.8                        52562                   3.99
## 3         27.2                        33368                   5.90
## 4         15.2                        43404                   4.39
## 5         15.6                        47412                   4.02
## 6         28.5                        29655                   4.93
##   bachelors_2017
## 1           25.0
## 2           30.7
## 3           12.0
## 4           13.2
## 5           13.1
## 6           13.4
df <- county |>
  select(poverty_2017, median_household_income_2017,
         unemployment_rate_2017, bachelors_2017) |>
  filter(!is.na(poverty_2017),
         !is.na(median_household_income_2017),
         !is.na(unemployment_rate_2017),
         !is.na(bachelors_2017)) |>
  mutate(income_10k = median_household_income_2017 / 10000)

dim(df)
## [1] 3139    5
summary(df)
##   poverty_2017   median_household_income_2017 unemployment_rate_2017
##  Min.   : 2.40   Min.   : 19264               Min.   : 1.620        
##  1st Qu.:11.30   1st Qu.: 41126               1st Qu.: 3.520        
##  Median :15.20   Median : 48072               Median : 4.360        
##  Mean   :15.97   Mean   : 49762               Mean   : 4.611        
##  3rd Qu.:19.40   3rd Qu.: 55763               3rd Qu.: 5.355        
##  Max.   :52.00   Max.   :129588               Max.   :19.070        
##  bachelors_2017    income_10k    
##  Min.   : 4.70   Min.   : 1.926  
##  1st Qu.:14.75   1st Qu.: 4.113  
##  Median :19.00   Median : 4.807  
##  Mean   :21.22   Mean   : 4.976  
##  3rd Qu.:25.30   3rd Qu.: 5.576  
##  Max.   :78.10   Max.   :12.959
df |>
  summarise(
    counties = n(),
    mean_poverty = mean(poverty_2017),
    mean_income = mean(median_household_income_2017),
    mean_unemployment = mean(unemployment_rate_2017),
    mean_bachelors = mean(bachelors_2017)
  )
##   counties mean_poverty mean_income mean_unemployment mean_bachelors
## 1     3139     15.96989    49761.57          4.611443       21.21768
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 = median_household_income_2017, y = poverty_2017)) +
  geom_point(alpha = 0.4) +
  geom_smooth(method = "lm", se = FALSE) +
  labs(
    title = "Poverty Rate and Median Household Income",
    x = "Median Household Income ($)",
    y = "Poverty Rate (%)"
  )
## `geom_smooth()` using formula = 'y ~ x'

ggplot(df, aes(x = unemployment_rate_2017, y = poverty_2017)) +
  geom_point(alpha = 0.4) +
  geom_smooth(method = "lm", se = FALSE) +
  labs(
    title = "Poverty Rate and Unemployment Rate",
    x = "Unemployment Rate (%)",
    y = "Poverty Rate (%)"
  )
## `geom_smooth()` using formula = 'y ~ x'

ggplot(df, aes(x = bachelors_2017, y = poverty_2017)) +
  geom_point(alpha = 0.4) +
  geom_smooth(method = "lm", se = FALSE) +
  labs(
    title = "Poverty Rate and Bachelor's Degree Attainment",
    x = "Bachelor's Degree (%)",
    y = "Poverty Rate (%)"
  )
## `geom_smooth()` using formula = 'y ~ x'

Regression Analysis

Multiple linear regression is appropriate because the outcome, poverty rate, is quantitative and there are three predictor variables. I use income in units of $10,000 so the income coefficient is easier to explain. The final model is:

Poverty Rate = β₀ + β₁(Income in $10,000s) + β₂(Unemployment Rate) + β₃(Bachelor’s Degree %) + error

model <- lm(
  poverty_2017 ~ income_10k + unemployment_rate_2017 + bachelors_2017,
  data = df
)

summary(model)
## 
## Call:
## lm(formula = poverty_2017 ~ income_10k + unemployment_rate_2017 + 
##     bachelors_2017, data = df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -13.5952  -2.3289  -0.2567   1.9914  26.2659 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            26.46942    0.42071   62.92   <2e-16 ***
## income_10k             -3.83911    0.07433  -51.65   <2e-16 ***
## unemployment_rate_2017  1.18720    0.04573   25.96   <2e-16 ***
## bachelors_2017          0.14751    0.01030   14.33   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.842 on 3135 degrees of freedom
## Multiple R-squared:  0.6528, Adjusted R-squared:  0.6524 
## F-statistic:  1965 on 3 and 3135 DF,  p-value: < 2.2e-16
confint(model)
##                             2.5 %     97.5 %
## (Intercept)            25.6445229 27.2943142
## income_10k             -3.9848531 -3.6933685
## unemployment_rate_2017  1.0975378  1.2768649
## bachelors_2017          0.1273199  0.1676965
coef_table <- coefficients(summary(model))
coef_table
##                          Estimate Std. Error   t value      Pr(>|t|)
## (Intercept)            26.4694185 0.42071037  62.91601  0.000000e+00
## income_10k             -3.8391108 0.07433099 -51.64886  0.000000e+00
## unemployment_rate_2017  1.1872014 0.04572989  25.96117 9.194584e-135
## bachelors_2017          0.1475082 0.01029636  14.32624  3.872991e-45
r_squared <- summary(model)$r.squared
adj_r_squared <- summary(model)$adj.r.squared
r_squared
## [1] 0.6527736
adj_r_squared
## [1] 0.6524413

The coefficient for income shows the expected change in poverty rate for a $10,000 increase in median household income while unemployment and bachelor’s degree attainment are held constant. The unemployment coefficient shows the expected change in poverty rate for a one percentage-point increase in unemployment while the other predictors are held constant. The bachelor’s degree coefficient shows the expected change in poverty rate for a one percentage-point increase in bachelor’s degree attainment while the other predictors are held constant.

The model’s R-squared is 0.653, and the adjusted R-squared is 0.652. This tells me how much of the variation in county poverty rates is explained by the three predictors together.

Model Assumptions and Diagnostics

For multiple linear regression, I need to check linearity, independence, homoscedasticity, normality of residuals, and multicollinearity. Each row represents a different county, so I treat the observations as separate county cases. The diagnostic plots below are used to check the other assumptions.

par(mfrow = c(2, 2))
plot(model)

par(mfrow = c(1, 1))

The Residuals vs Fitted plot is used to check linearity. A roughly random pattern around zero supports the assumption. The Scale-Location plot is used to check whether the residual spread is fairly even. The Normal Q-Q plot is used to check whether residuals are approximately normal. The Residuals vs Leverage plot helps identify counties that may have unusually strong influence on the model.

vif_income <- 1 / (1 - summary(lm(
  income_10k ~ unemployment_rate_2017 + bachelors_2017,
  data = df
))$r.squared)

vif_unemployment <- 1 / (1 - summary(lm(
  unemployment_rate_2017 ~ income_10k + bachelors_2017,
  data = df
))$r.squared)

vif_bachelors <- 1 / (1 - summary(lm(
  bachelors_2017 ~ income_10k + unemployment_rate_2017,
  data = df
))$r.squared)

vif_values <- c(
  income_10k = vif_income,
  unemployment_rate_2017 = vif_unemployment,
  bachelors_2017 = vif_bachelors
)

vif_values
##             income_10k unemployment_rate_2017         bachelors_2017 
##               2.031694               1.208696               1.941186

The largest VIF is 2.03. Since the VIF values are below 5, there is not a serious multicollinearity problem among these predictors.

Conclusion and Future Directions

This multiple linear regression model examines how median household income, unemployment rate, and bachelor’s degree attainment work together to predict county poverty rates. The model summary shows which predictors have statistically meaningful relationships with poverty after controlling for the other variables. The R-squared and adjusted R-squared show how much of the differences in poverty rates across counties are explained by the model.

This analysis shows association, not causation. Counties can differ in many other ways that are not included in this model, such as cost of living, industry, population size, housing, health, and regional differences. A future analysis could add more predictors, compare different model forms, or include interaction terms to see whether the relationship between one predictor and poverty changes depending on another predictor.

References

OpenIntro. United States Counties: county_complete. https://www.openintro.org/data/index.php?data=county_complete

OpenIntroStat. usdata: Data on the States and Counties of the United States. https://github.com/OpenIntroStat/usdata