Why Economic Inflation?

  • With so much of the news media today focusing on inflation as a central topic in economic and political discussions, my objective for this project was to compare public sentiment on inflation to the actual inflation data reported by the U.S. Bureau of Labor Statistics.

  • To do so, I tested the perceptions held by those around me against the market basket price levels captured by the Consumer Price Index.

Description of Data Cleaning and Sourcing (Latex Computation)

  • The Consumer Price Index (CPI) measures the average change over time in the prices paid by urban consumers for a fixed market basket of goods and services.

\[ \text{CPI} = \frac{\text{Current Cost of Market Basket}} {\text{Cost of Basket in 1982 - 1984}} \times 100 \]

Example:

\[ \text{CPI} = 262.639 \Rightarrow \text{prices are } 2.626 \text{ times higher than 1982 - 1984.} \]

  • For this project, I used the CPI-U index (all urban consumers) and filtered monthly values from 2021 onward to capture the post-pandemic “new normal.”

Null and Alternative Hypotheses: Sentiment Collection (Latex Computation)

  • Each person gave an opinion on how many times more expensive the market basket is now compared to the early 1980s (1–10 scale). These were mapped to rough CPI levels.

Let \(\mu\) be the true mean CPI from 2021–2025. From perceptions, I formed a projected CPI of \(\mu_0 = 390\).

\[ H_0: \mu = 390 \]

\[ H_1: \mu < 390 \]

One-Sample t-Test: Formula and Computation (Latex Computation Part One)

To compare the sample mean CPI to the projected value, I used a one-sample t-test with unknown population standard deviation.

\[ t = \frac{\bar{x} - \mu_0}{s / \sqrt{n}} \]

Given:

  • \(\bar{x} = 296.4561\)
  • \(\mu_0 = 390\)
  • \(s = 17.0784\)
  • \(n = 50\)

One-Sample t-Test: Formula and Computation (Latex Computation Part Two)

Substituting:

\[ t = \frac{296.4561 - 390}{17.0784 / \sqrt{50}} = \frac{-93.5439}{2.415} \approx -38.73 \]

The p-value for a left-tailed test was found as:

\[ p = P(T_{49} \le -38.73) \approx 0 \quad \Rightarrow \quad p < 0.0001. \]

Interactive CPI Index from 2021 to 2025 (using plotly)

  • Here are the CPI values from the last four years

Survey Opinions on Inflation (Bar Chart using ggplot)

  • Resullts of a survey sent out on perceived inflation rates

Distribution of Opinions using L (ggplot)

  • Here they are presented in a different manner

R Code Used for Hypothesis Test and Plots

  • The following code is what I utilized to create the graphs shown earlier:
# cpi index throughout the years:

plot_ly(
  data = cpi_data,
  x    = ~date,
  y    = ~value,
  type = "scatter",
  mode = "lines+markers",
  hovertemplate = "Date: %{x}<br>CPI: %{y}<extra></extra>"
) %>%
  layout(
    title = "CPI Over Time (2021–2025)",
    xaxis = list(title = "Date"),
    yaxis = list(title = "CPI Index (value)")
  )

R Code Used for Hypothesis Test and Plots

# perceptions plot 1 
ggplot(perception, aes(x = person, y = opinion)) +
  geom_col(fill = "#8C1D40", alpha = 0.8) +
  labs(
    title = "Perceived Increase in Market Basket Prices",
    x = "Person",
    y = "Opinion (1–10 scale)"
  ) +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

R Code Used for Hypothesis Test and Plots

# perceptions plot 2 
ggplot(perception, aes(x = index, y = opinion)) +
  geom_line() +
  geom_point() +
  scale_x_continuous(
    breaks = perception$index,
    labels = perception$person
  ) +
  labs(
    title = "Perceived Inflation by Person (Line View)",
    x = "Person",
    y = "Opinion (1–10 scale)"
  ) +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))