Dos Presidency Effect Gas Prices

2025-12-05

Slide 1

This project investigates how U.S. gasoline prices have changed across different presidential terms over time. The price of gas is a key indicator of both economic stability and public sentiment, often influencing consumer spending and inflation. While gas prices depend on global factors, like oil supply, wars, and pandemics, presidential periods can reflect national responses to these pressures through economic or energy policies. Understanding how prices behaved during each presidency offers insights into long-term economic patterns and the timing of major events that affected Americans’ daily lives. This analysis will highlight whether gas price fluctuations align more with historical periods (such as early 2000s recession, 2020 pandemic recovery) rather than political transitions themselves.

Slide 2

Questions: 1.How did average U.S. gas prices trend during each president’s term? 2.Which presidential terms saw the highest and lowest average gas prices? 3.Were there sharp changes in gas prices immediately before or after a new president took office?

Slide 3

Setup

library(readr)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
library(ggplot2)
library(plotly)
## Warning: package 'plotly' was built under R version 4.5.1
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout

Slide 4

LOAD DATA

gas <- read_csv("C:/Users/jappe/Downloads/GASREGW.csv") %>%
  mutate(observation_date = ymd(observation_date)) %>%
  rename(GasPrice = GASREGW)
## Rows: 1841 Columns: 2
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl  (1): GASREGW
## date (1): observation_date
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
pres <- read_csv("C:/Users/jappe/Downloads/presidents.csv") %>%
  arrange(Date)
## Rows: 179 Columns: 2
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (1): President
## date (1): Date
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Slide 5

MATCH GAS DATE TO PRESIDENT

combined <- gas %>%
  left_join(
    pres,
    join_by(closest(observation_date >= Date))
  )

Slide 6

PUTTING PRESIDENTS IN ORDER

pres_order <- c(
  "Bush 41",
  "Clinton",
  "Bush 43",
  "Obama",
  "Trump 1",
  "Biden",
  "Trump 2"
)

combined$President <- factor(combined$President, levels = pres_order)

Slide 7

ANALYSIS Average gas price by president.

avg_gas <- combined %>%
  group_by(President) %>%
  summarise(AvgGas = mean(GasPrice, na.rm = TRUE))

avg_gas
## # A tibble: 7 Ă— 2
##   President AvgGas
##   <fct>      <dbl>
## 1 Bush 41     1.12
## 2 Clinton     1.16
## 3 Bush 43     2.13
## 4 Obama       2.97
## 5 Trump 1     2.48
## 6 Biden       3.44
## 7 Trump 2     3.12

Slide 8

Start, end, and change during each term

trend <- combined %>%
  group_by(President) %>%
  summarise(
    Start  = first(GasPrice),
    End    = last(GasPrice),
    Change = End - Start
  )

trend
## # A tibble: 7 Ă— 4
##   President Start   End  Change
##   <fct>     <dbl> <dbl>   <dbl>
## 1 Bush 41    1.19  1.07 -0.122 
## 2 Clinton    1.06  1.41  0.349 
## 3 Bush 43    1.41  1.61  0.207 
## 4 Obama      1.68  2.31  0.625 
## 5 Trump 1    2.38  2.24 -0.134 
## 6 Biden      2.25  3.01  0.757 
## 7 Trump 2    3.05  3.06  0.0140

Slide 9

GRAPHS Gas price trend by president

p1 <- ggplot(combined,
             aes(x = observation_date, y = GasPrice, color = President)) +
  geom_line() +
  labs(
    title = "Gas Price Trend by President",
    x = "Date",
    y = "Gas Price ($)"
  ) +
  theme_minimal()

ggplotly(p1)

Slide 10

Average gas price per president

p2 <- ggplot(avg_gas,
             aes(x = factor(President, levels = pres_order),
                 y = AvgGas,
                 fill = President)) +
  geom_col() +
  coord_flip() +
  labs(
    title = "Average Gas Price per President",
    x = "President",
    y = "Average Gas Price ($)"
  ) +
  theme_minimal()

ggplotly(p2)

Slide 11

Gas price change during each term

p3 <- ggplot(trend,
             aes(x = factor(President, levels = pres_order),
                 y = Change,
                 fill = Change > 0)) +
  geom_col() +
  coord_flip() +
  labs(
    title = "Change in Gas Price During Presidential Term",
    x = "President",
    y = "Change ($)"
  ) +
  scale_fill_manual(values = c("TRUE"="red", "FALSE"="blue"),
                    labels = c("TRUE"="Increase", "FALSE"="Decrease")) +
  theme_minimal()

ggplotly(p3)
volatility <- combined %>%
  group_by(President) %>%
  summarise(
    StdDev = sd(GasPrice, na.rm = TRUE),
    Range = max(GasPrice) - min(GasPrice)
  )

volatility
## # A tibble: 7 Ă— 3
##   President StdDev  Range
##   <fct>      <dbl>  <dbl>
## 1 Bush 41   0.0829 NA    
## 2 Clinton   0.149   0.774
## 3 Bush 43   0.734   3.06 
## 4 Obama     0.615   2.28 
## 5 Trump 1   0.267   1.19 
## 6 Biden     0.476   2.76 
## 7 Trump 2   0.0500  0.224

Slide 12

Volatility

# 1. Create volatility (daily change)
combined_vol <- combined %>%
  arrange(observation_date) %>%
  mutate(
    Volatility = abs(GasPrice - lag(GasPrice))
  )

# 2. One combined graph with SAME colors for both lines
p_all <- ggplot(combined_vol, aes(x = observation_date)) +

  # Gas price line (colored by president)
  geom_line(aes(y = GasPrice, color = President), size = 1) +

  # Volatility line (same President colors)
  geom_line(aes(y = Volatility, color = President), 
            size = 0.8, 
            linetype = "dashed") +

  labs(
    title = "Gas Prices and Volatility by Presidential Term",
    x = "Date",
    y = "Gas Price / Volatility (scaled)"
  ) +
  theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
ggplotly(p_all)

Slide 13

In my research I noticed volatility strongly effects gas prices as you can see in the last graph there are large gas price spikes where volatility spikes. Such as 2008 finical crisis, 2020 covid and 2022 war. So my final analysis is, gas prices change more because of volatility than because of who is president.Presidents correlate with certain gas price levels because they happen to serve during global event/ wars, recessions, pandemics, and supply disruptions—that cause volatility.Volatility spikes can happen in any presidency.However, presidents do have a part in it, when they make decisions that would cause these events.

Slide 14

Data Sources:

https://pmc.ncbi.nlm.nih.gov/articles/PMC10123483/

FRED: https://fred.stlouisfed.org/series/GASREGW

presidents.csv