Objective

The Federal Reserve’s mandate from Congress is to control inflation and to maintain low unemployment. These seem to be contradictory objectives. For this story you will need to source the following data for the last 25 years;

Your Data Visualizations should be designed to answer the question “Has the FED been able to fulfill the mandate given to it by Congress?”

Libraries/Packages

library(httr)
library(tidyverse)
library(glue)
library(fredr)
library(lubridate)

API/Data Gathering

The Objective in data collection was to get the last 25 years for each of the following: The Consumer Price Index (CPI), The FED Funds Rate (FRED), Unemployment Rate, and Inflation Rate. The CPI and Unemployment rate came from the Bureau of Labor Statistics(BLS); as the FED Funds rate and Inflation Rate came from the Federal Reserve Board website. This results in needing to use 2 different API sources in order to collect the data. It should be noted that the BLS websites, data policy is a maximum of 20 years per request, therefore the code is bulkier as it had to combine 2 request to reach the 25 year range of data per each type. The Federal Reserve Board website was done via the \(fredr\) package and after obtaining an API key, the process was very easy.

BLS Public Data API Resource

FRED API Package Documentation

Bureau of Labor Statistics

#Api Key
bls_api_key <- readLines("API Key.txt")
bls_url <- "https://api.bls.gov/publicAPI/v2/timeseries/data/"

#Unemployment rate
#LNS14000000
#(Seas) Unemployment Rate

#CPI
#EIUIR4
#Monthly import price index for BEA End Use 4, Consumer goods, excluding automotives, not seasonally adjusted

payload <- glue('{
    "seriesid":["LNS14000000"],
    "startyear":"2015",
    "endyear":"2024",
    "registrationkey":"{{bls_api_key}}"
}', .open="{{", .close="}}")


response <- POST(bls_url,
                body = payload,
                 content_type("application/json"),
                encode = "json")
x <- content(response, "text") %>% jsonlite::fromJSON()
x$Results$series$data[[1]] %>% as_tibble() -> Unemploy_2

payload <- glue('{
    "seriesid":["LNS14000000"],
    "startyear":"1999",
    "endyear":"2015",
    "registrationkey":"{{bls_api_key}}"
}', .open="{{", .close="}}")


response <- POST(bls_url,
                body = payload,
                 content_type("application/json"),
                encode = "json")
x <- content(response, "text") %>% jsonlite::fromJSON()
x$Results$series$data[[1]] %>% as_tibble() -> Unemploy_1

Unemploy_Final <- bind_rows(Unemploy_1, Unemploy_2) %>%
  distinct()


payload <- glue('{
    "seriesid":["EIUIR4"],
    "startyear":"2015",
    "endyear":"2024",
    "registrationkey":"{{bls_api_key}}"
}', .open="{{", .close="}}")


response <- POST(bls_url,
                body = payload,
                 content_type("application/json"),
                encode = "json")
x <- content(response, "text") %>% jsonlite::fromJSON()
x$Results$series$data[[1]] %>% as_tibble() -> CPI_2

payload <- glue('{
    "seriesid":["EIUIR4"],
    "startyear":"1999",
    "endyear":"2015",
    "registrationkey":"{{bls_api_key}}"
}', .open="{{", .close="}}")


response <- POST(bls_url,
                body = payload,
                 content_type("application/json"),
                encode = "json")
x <- content(response, "text") %>% jsonlite::fromJSON()
x$Results$series$data[[1]] %>% as_tibble() -> CPI_1

CPI_Final <- bind_rows(CPI_1, CPI_2) %>%
  distinct()

Federal Reserve Board

# API From FRED
FRED_API_KEY <- readLines("API Key2.txt")
fredr_set_key(FRED_API_KEY)

Fed_Final <- fredr(
  series_id = "FEDFUNDS",
  observation_start = as.Date("1999-01-01"),
  observation_end = as.Date("2024-01-01")
)

Inflation_Final <- fredr(
  series_id = "FPCPITOTLZGUSA",
  observation_start = as.Date("1999-01-01"),
  observation_end = as.Date("2024-01-01"))

Data Manipulation/Visualization

CPI_Final <- CPI_Final %>%
  mutate(date = ymd(paste(year, periodName, "01"))) %>%
  select(-year, -periodName)
Unemploy_Final <- Unemploy_Final %>%
  mutate(date = ymd(paste(year, periodName, "01"))) %>%
  select(-year, -periodName)


Unemploy_Final <- Unemploy_Final %>%
  mutate(value = as.numeric(value))

CPI_Final <- CPI_Final %>%
  mutate(value = as.numeric(value))

plot1 <- ggplot() +
  geom_line(data = Unemploy_Final, aes(x = date, y = value, color = "Unemployment Rate")) +
  geom_line(data = Inflation_Final, aes(x = date, y = value, color = "Inflation Rate")) +
  geom_line(data = Fed_Final, aes(x = date, y = value, color = "Federal Funds Rate"))+
  labs(x = "Date", y = "Value", title = "Economic Indicators Over the Last 25 Years") + scale_color_manual(values = c("Unemployment Rate" = "blue", "Inflation Rate" = "orange", "Federal Funds Rate" = "green")) +
  theme(legend.position = "right")


plot2 <- ggplot() +
  geom_line(data = CPI_Final, aes(x = date, y = value, color = "CPI")) +
  labs(x = "Date", y = "Value", title = "CPI Over the Last 25 years") +
  scale_color_manual(values = "red", labels = "CPI") +
  theme_minimal() +
  theme(legend.position = "none")



CPI <- select(CPI_Final, date, CPI = value)
UnEmploy <- select(Unemploy_Final, date, Unemployment_Rate = value)
FED <- select(Fed_Final, date, Fed_Rate = value)
Inflation <- select(Inflation_Final, date, Inflation = value)

df_final <- full_join(CPI, UnEmploy, by = "date") %>%
  full_join(FED, by = "date")

# Pearson's test for CPI and Unemployment_Rate
cor_CU <- cor.test(df_final$CPI, df_final$Unemployment_Rate)

# Pearson's test for CPI and Fed_Rate
cor_CF <- cor.test(df_final$CPI, df_final$Fed_Rate)

# Pearson's test for Unemployment_Rate and Fed_Rate
cor_UF <- cor.test(df_final$Unemployment_Rate, df_final$Fed_Rate)

Has the FED been able to fulfill the mandate given to it by Congress?


What is the Mandate given by Congress?

To start out, the Federal Reserve’s mandate from Congress showcases the it’s responsibility to help control inflation at a target 2% and maintain low unemployment around 3-5%. The Federal Reserve’s greatest tool in both of these task is it’s monetary policy of setting interest rates. The idea is that controlling the federal interest rate and continuing to monitor open market operations; the Federal Reserve will be able to achieve these objectives and help promote long-term economic growth and stability. Through out the period of data(1999-2024), we have collected, there have been 3 major economical events that have shifted the US economy. In 1999/early 2000’s there was the Dot-Com Bubble which has resulted in the market crash due to inflated values of internet based companies. There was the 2008 Housing Crisis, which caused banks to fail and for the US to go into an economic recession. Finally recently, in 2020, there was the Covid-19 Pandemic that caused the global economy to plummet due to lockdown measures in attempt to contain the spread, which resulted in high unemployment rates and an economic crisis.

Different Economical Indicators

CPI (Consumer Price Index)

When CPI increases this is the metric used to calculate inflation since its the change in prices of goods and services, month to month or year to year. Generally speaking, the Federal Reserve typically lowers the Federal Funds Rate when this happens which results in a negative correlation. This action aligns with general monetary policy principles, as lower interest rates help stimulate economic activity and will try to maintain price stability. Additionally, if inflation starts to decline, this may prompt the Federal Reserve to raise interest rates to stunt economical growth and prevent excessive inflation. Therefore the Federal Reserve’s efforts is reflected by the negative correlation between CPI and the Federal Funds Rate manage inflation.

Unemployment Rate

Traditionally there exists a negative correlation between the Unemployment Rate and the Federal Funds Rate. When Unemployment rates are low, this usually indicate a booming economy with increased consumer spending. This usually leads to inflation of typical goods and services and as a result, the Federal Reserve may raise interest rates to prevent overheating. Furthermore, rising unemployment rates would typically prompt the Federal Reserve to lower interest rates to help stimulate economic growth, which would then lead to job creation. The idea is that when interest rates are lower, there is typically more money for the business to spend which would usually go towards the workforce of the business and create new opportunity or job growth. According to different economists, a healthy unemployment rate in an economy is around 3-5% as it is believed to help drive demand and allow competition to be rampant.

Inflation Rate

There is usually a strong negative correlation between the Inflation Rate and the Federal Funds Rate. Higher inflation rates will prompt the Federal Reserve to lower interest rates. As it is seen that lowering interest rates will help stimulate borrowing and spending, which results in economic growth. Conversely, declining inflation may lead the Federal Reserve to raise interest rates to prevent excessive inflation. Since inflation is the metric that the Federal Reserve is trying to control, it mainly stems from how long rates are increased for as well as when they are changed to creating a landing for the target inflation rate of 2%.

CPI and Unemployment Rate

The correlation coefficient is 0.0367, and the p-value is 0.5254, which indicates that there is no statistically significant correlation between CPI and Unemployment Rate.

print(cor_CU)
## 
##  Pearson's product-moment correlation
## 
## data:  df_final$CPI and df_final$Unemployment_Rate
## t = 0.63581, df = 299, p-value = 0.5254
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.07662536  0.14917785
## sample estimates:
##        cor 
## 0.03674525
CPI and Federal Fund Rate

The correlation coefficient is -0.4149 and the p-value is 5.982e-14, which indicates a statistically significant negative correlation between CPI and Federal Funds Rate.

print(cor_CF)
## 
##  Pearson's product-moment correlation
## 
## data:  df_final$CPI and df_final$Fed_Rate
## t = -7.8838, df = 299, p-value = 5.982e-14
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.5042530 -0.3166485
## sample estimates:
##        cor 
## -0.4148501
Unemployment Rate and Federal Fund Rate

The correlation coefficient is -0.5905 and the p-value is < 2.2e-16, which indicates a statistically significant negative correlation between Unemployment Rate and Federal Funds Rate.

print(cor_UF)
## 
##  Pearson's product-moment correlation
## 
## data:  df_final$Unemployment_Rate and df_final$Fed_Rate
## t = -12.651, df = 299, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.659486 -0.511551
## sample estimates:
##       cor 
## -0.590456

Conclusion

To answer the question “Has the FED been able to fulfill the mandate given to it by Congress?”, I believe it is a simple, Yes. As we look at the graphs below, we can see that the 2 times when Interest Rates went to 0 was during the 2008 Housing crisis and Covid-19 Pandemic. The reason why it went to 0, was that the economy crashed and this is supported by the inflation rate at the time where it had a decreased during this period. Another supporting evidence of the economy crash is the sharp increase in unemployment rate during this time. As stated previously, the Federal Reserve will decrease the interest rate to help increase economical spending and hopefully decrease unemployment rates.

As their goal was to monitor the US economy and go for economic stability, I believe that their monetary policies have indicated them fulfilling their mandate. Even further, during recovering period after these economical crisis, we see slow increase to the interest rates when inflation rate has been higher. What isn’t shown but is considered when looking at these historic data, is that there is a lag period within monetary policies done by the Federal Reserve. This is due to prices, quantities and loans, being agreed upon well in advance as an example, the typical housing purchasing revolves around a fixed mortgage so the interest payments for that loan is locked in for typically a 15 or 30 year period. This results in loans and prices being locked into the old rates and not the current.

plot1

plot2