In this project, I will use publicly available data to explore how state-level unemployment rates relate to consumer spending trends.

  1. Data Collection
library(fredr)
library(tidyverse)
library(lubridate)
fredr_set_key("e94769feaf925275ff1738ada4ca88b5")

ma_unemp <- fredr(series_id = 'MAUR', observation_start = as.Date('2025-03-01'))

unemployment <- fredr(series_id = 'UNRATE', observation_start = as.Date('2015-01-01') )

head(ma_unemp)
## # A tibble: 2 × 5
##   date       series_id value realtime_start realtime_end
##   <date>     <chr>     <dbl> <date>         <date>      
## 1 2025-03-01 MAUR        4.4 2025-05-29     2025-05-29  
## 2 2025-04-01 MAUR        4.6 2025-05-29     2025-05-29
library(readxl)
consumption_data <- read_excel("C:/Users/mickp/Downloads/PCE.xlsx", sheet = 2)

pce <- fredr(series_id = 'PCE', observation_start =  as.Date('2015-01-01'))

PCE: Personal Consumption Expenditures, Billions of Dollars, Monthly, Seasonally Adjusted Annual Rate

  1. Data Cleaning
colSums(is.na(unemployment))
##           date      series_id          value realtime_start   realtime_end 
##              0              0              0              0              0
colSums(is.na(pce))
##           date      series_id          value realtime_start   realtime_end 
##              0              0              0              0              0
clean_unemployment <- unemployment %>%
  select(date, unemployment_rate = value)

pce_clean <- pce %>%
  select(date, pce = value)

econ_data <- left_join(clean_unemployment, pce_clean, by = 'date')

Visualization

ggplot(econ_data, aes(x = date, y = unemployment_rate)) +
  geom_line(color = 'firebrick') +
  labs(title = 'US Unemployment Rate 2015–Present', 
       y = 'Unemployment Rate (%)', 
       x = 'Date')

ggplot(econ_data, aes(x = date, y = pce)) +
  geom_line(color = 'limegreen') +
  labs(title = 'US Personal Consumption Expenditrues (Billions)', x = 'Date', y = 'PCE (Billions)')
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_line()`).

Analyzing the relationship

cor(econ_data$unemployment_rate, econ_data$pce, use = 'complete.obs')
## [1] -0.3319506

The correlation of -.33 between the unemployment rate and PCE suggests a significant negative linear relationship between these variables. This means that as unemployment increases, consumer spending tends to decrease. This negative correlation is due to faltering economic confidence and income in light of higher unemployment, although the strength is modest and does not entirely convey the reason for shifts in PCE.

model <- lm(pce ~ unemployment_rate, data = econ_data)
summary(model)
## 
## Call:
## lm(formula = pce ~ unemployment_rate, data = econ_data)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
##  -2923  -2345  -1227   2009   4950 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        17847.8      655.9  27.212  < 2e-16 ***
## unemployment_rate   -510.6      131.9  -3.871 0.000176 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2497 on 121 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.1102, Adjusted R-squared:  0.1028 
## F-statistic: 14.98 on 1 and 121 DF,  p-value: 0.0001762

According to this summary, as unemployment increases by 1 percent, PCE decreases by $510.60 billion, holding other factors consistent. The extremely low p-value suggests that there is strong evidence supporting the idea that unemployment influences PCE. However, the R-squared value of .1102 suggests that only about 11% of the variation in PCE is explained by the unemployment rate. While this figure is low, it should not come as much of a surprise given the amount of factors present in economic analysis, such as inflation, wages, and interest rates.