Has the FED been able to fulfill the mandate given to it by Congress?
Story - 2 : Can the FED Control Inflation and Maintain Full Employment
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; The Consumer Price Index (CPI) (Bureau of Labor Statistics)
The FED Funds Rate (FRED) (Federal Reserve Board)
Unemployment Rate (Bureau of Labor Statistics)
Loading packages
## Warning: package 'ggplot2' was built under R version 4.2.3
## Warning: package 'httr' was built under R version 4.2.3
## Warning: package 'fredr' was built under R version 4.2.3
#Seting API key
fredr_set_key("131e426d3e90b22277da7f01827483d7")
#Fetching CPI data
cpi_data <- fredr(series_id = "CPIAUCNS")
#Print the fetched data
print(cpi_data)
## # A tibble: 1,333 × 5
## date series_id value realtime_start realtime_end
## <date> <chr> <dbl> <date> <date>
## 1 1913-01-01 CPIAUCNS 9.8 2024-02-18 2024-02-18
## 2 1913-02-01 CPIAUCNS 9.8 2024-02-18 2024-02-18
## 3 1913-03-01 CPIAUCNS 9.8 2024-02-18 2024-02-18
## 4 1913-04-01 CPIAUCNS 9.8 2024-02-18 2024-02-18
## 5 1913-05-01 CPIAUCNS 9.7 2024-02-18 2024-02-18
## 6 1913-06-01 CPIAUCNS 9.8 2024-02-18 2024-02-18
## 7 1913-07-01 CPIAUCNS 9.9 2024-02-18 2024-02-18
## 8 1913-08-01 CPIAUCNS 9.9 2024-02-18 2024-02-18
## 9 1913-09-01 CPIAUCNS 10 2024-02-18 2024-02-18
## 10 1913-10-01 CPIAUCNS 10 2024-02-18 2024-02-18
## # ℹ 1,323 more rows
#Using API key
fredr_set_key("131e426d3e90b22277da7f01827483d7")
#Fetching CPI data
cpi_data <- fredr(series_id = "CPIAUCNS")
#Fetching FED Funds Rate data
fed_funds_data <- fredr(series_id = "FEDFUNDS")
#Fetching Unemployment Rate data
unemployment_data <- fredr(series_id = "UNRATE")
#Printing the fetched data
print(cpi_data)
## # A tibble: 1,333 × 5
## date series_id value realtime_start realtime_end
## <date> <chr> <dbl> <date> <date>
## 1 1913-01-01 CPIAUCNS 9.8 2024-02-18 2024-02-18
## 2 1913-02-01 CPIAUCNS 9.8 2024-02-18 2024-02-18
## 3 1913-03-01 CPIAUCNS 9.8 2024-02-18 2024-02-18
## 4 1913-04-01 CPIAUCNS 9.8 2024-02-18 2024-02-18
## 5 1913-05-01 CPIAUCNS 9.7 2024-02-18 2024-02-18
## 6 1913-06-01 CPIAUCNS 9.8 2024-02-18 2024-02-18
## 7 1913-07-01 CPIAUCNS 9.9 2024-02-18 2024-02-18
## 8 1913-08-01 CPIAUCNS 9.9 2024-02-18 2024-02-18
## 9 1913-09-01 CPIAUCNS 10 2024-02-18 2024-02-18
## 10 1913-10-01 CPIAUCNS 10 2024-02-18 2024-02-18
## # ℹ 1,323 more rows
## # A tibble: 835 × 5
## date series_id value realtime_start realtime_end
## <date> <chr> <dbl> <date> <date>
## 1 1954-07-01 FEDFUNDS 0.8 2024-02-18 2024-02-18
## 2 1954-08-01 FEDFUNDS 1.22 2024-02-18 2024-02-18
## 3 1954-09-01 FEDFUNDS 1.07 2024-02-18 2024-02-18
## 4 1954-10-01 FEDFUNDS 0.85 2024-02-18 2024-02-18
## 5 1954-11-01 FEDFUNDS 0.83 2024-02-18 2024-02-18
## 6 1954-12-01 FEDFUNDS 1.28 2024-02-18 2024-02-18
## 7 1955-01-01 FEDFUNDS 1.39 2024-02-18 2024-02-18
## 8 1955-02-01 FEDFUNDS 1.29 2024-02-18 2024-02-18
## 9 1955-03-01 FEDFUNDS 1.35 2024-02-18 2024-02-18
## 10 1955-04-01 FEDFUNDS 1.43 2024-02-18 2024-02-18
## # ℹ 825 more rows
## # A tibble: 913 × 5
## date series_id value realtime_start realtime_end
## <date> <chr> <dbl> <date> <date>
## 1 1948-01-01 UNRATE 3.4 2024-02-18 2024-02-18
## 2 1948-02-01 UNRATE 3.8 2024-02-18 2024-02-18
## 3 1948-03-01 UNRATE 4 2024-02-18 2024-02-18
## 4 1948-04-01 UNRATE 3.9 2024-02-18 2024-02-18
## 5 1948-05-01 UNRATE 3.5 2024-02-18 2024-02-18
## 6 1948-06-01 UNRATE 3.6 2024-02-18 2024-02-18
## 7 1948-07-01 UNRATE 3.6 2024-02-18 2024-02-18
## 8 1948-08-01 UNRATE 3.9 2024-02-18 2024-02-18
## 9 1948-09-01 UNRATE 3.8 2024-02-18 2024-02-18
## 10 1948-10-01 UNRATE 3.7 2024-02-18 2024-02-18
## # ℹ 903 more rows
## Warning: package 'dplyr' was built under R version 4.2.3
##
## 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
#Filtering data for the last 25 years
cpi_data <- cpi_data %>% filter(date >= Sys.Date() - 365 * 25)
fed_funds_data <- fed_funds_data %>% filter(date >= Sys.Date() - 365 * 25)
unemployment_data <- unemployment_data %>% filter(date >= Sys.Date() - 365 * 25)
#Printing the filtered data
print(cpi_data)
## # A tibble: 299 × 5
## date series_id value realtime_start realtime_end
## <date> <chr> <dbl> <date> <date>
## 1 1999-03-01 CPIAUCNS 165 2024-02-18 2024-02-18
## 2 1999-04-01 CPIAUCNS 166. 2024-02-18 2024-02-18
## 3 1999-05-01 CPIAUCNS 166. 2024-02-18 2024-02-18
## 4 1999-06-01 CPIAUCNS 166. 2024-02-18 2024-02-18
## 5 1999-07-01 CPIAUCNS 167. 2024-02-18 2024-02-18
## 6 1999-08-01 CPIAUCNS 167. 2024-02-18 2024-02-18
## 7 1999-09-01 CPIAUCNS 168. 2024-02-18 2024-02-18
## 8 1999-10-01 CPIAUCNS 168. 2024-02-18 2024-02-18
## 9 1999-11-01 CPIAUCNS 168. 2024-02-18 2024-02-18
## 10 1999-12-01 CPIAUCNS 168. 2024-02-18 2024-02-18
## # ℹ 289 more rows
## # A tibble: 299 × 5
## date series_id value realtime_start realtime_end
## <date> <chr> <dbl> <date> <date>
## 1 1999-03-01 FEDFUNDS 4.81 2024-02-18 2024-02-18
## 2 1999-04-01 FEDFUNDS 4.74 2024-02-18 2024-02-18
## 3 1999-05-01 FEDFUNDS 4.74 2024-02-18 2024-02-18
## 4 1999-06-01 FEDFUNDS 4.76 2024-02-18 2024-02-18
## 5 1999-07-01 FEDFUNDS 4.99 2024-02-18 2024-02-18
## 6 1999-08-01 FEDFUNDS 5.07 2024-02-18 2024-02-18
## 7 1999-09-01 FEDFUNDS 5.22 2024-02-18 2024-02-18
## 8 1999-10-01 FEDFUNDS 5.2 2024-02-18 2024-02-18
## 9 1999-11-01 FEDFUNDS 5.42 2024-02-18 2024-02-18
## 10 1999-12-01 FEDFUNDS 5.3 2024-02-18 2024-02-18
## # ℹ 289 more rows
## # A tibble: 299 × 5
## date series_id value realtime_start realtime_end
## <date> <chr> <dbl> <date> <date>
## 1 1999-03-01 UNRATE 4.2 2024-02-18 2024-02-18
## 2 1999-04-01 UNRATE 4.3 2024-02-18 2024-02-18
## 3 1999-05-01 UNRATE 4.2 2024-02-18 2024-02-18
## 4 1999-06-01 UNRATE 4.3 2024-02-18 2024-02-18
## 5 1999-07-01 UNRATE 4.3 2024-02-18 2024-02-18
## 6 1999-08-01 UNRATE 4.2 2024-02-18 2024-02-18
## 7 1999-09-01 UNRATE 4.2 2024-02-18 2024-02-18
## 8 1999-10-01 UNRATE 4.1 2024-02-18 2024-02-18
## 9 1999-11-01 UNRATE 4.1 2024-02-18 2024-02-18
## 10 1999-12-01 UNRATE 4 2024-02-18 2024-02-18
## # ℹ 289 more rows
#Filtering data for the last 25 years
start_date <- Sys.Date() - 25 * 365 #assuming each year is 365 days
cpi_data <- filter(cpi_data, date >= start_date)
fed_funds_data <- filter(fed_funds_data, date >= start_date)
unemployment_data <- filter(unemployment_data, date >= start_date)
#Plotting Consumer Price Index (CPI) over time
ggplot(cpi_data, aes(x = date, y = value)) +
geom_line() +
labs(title = "Consumer Price Index (CPI) Over the Last 25 Years",
x = "Date",
y = "CPI")
#Plotting FED Funds Rate over time
ggplot(fed_funds_data, aes(x = date, y = value)) +
geom_line() +
labs(title = "FED Funds Rate Over the Last 25 Years",
x = "Date",
y = "FED Funds Rate")
#Plotting Unemployment Rate over time
ggplot(unemployment_data, aes(x = date, y = value)) +
geom_line() +
labs(title = "Unemployment Rate Over the Last 25 Years",
x = "Date",
y = "Unemployment Rate")
Consumer Price Index (CPI) has been steadily increasing in a straight line over the last 25 years, which implies a persistent inflation. In this case it suggests a long-term increase in the general price level of goods and services as an increase of the cost of goods and services. Among other policy implications.
Funds rate (FED) Overall, the zig-zag pattern in the Federal Funds Rate reflects the FED’s efforts to navigate and respond to various economic challenges and changes in inflationary pressures over the years.For example, the significant peak in the early 2000s might have been associated with a period of economic expansion or 2020 Covid.
Unemployment rate (UN rate) the observed trend in the unemployment rate reflects the impact of the COVID-19 pandemic on the labor market and subsequent efforts to address the challenges posed by the crisis.
Calculating the inflation rate based on the Consumer Price Index (CPI) data
#Filtering data for the last 25 years
start_date <- Sys.Date() - 25 * 365 # assuming each year is 365 days
cpi_data <- filter(cpi_data, date >= start_date)
#Calculating percentage change in CPI for the last 25 years
cpi_data <- arrange(cpi_data, date)
cpi_data <- mutate(cpi_data, inflation_rate = ((value / lag(value)) - 1) * 100)
#Filtering out the first row as it doesn't have a previous period
cpi_data <- cpi_data %>% filter(!is.na(inflation_rate))
#Printing or visualize the inflation rate for the last 25 years
print(cpi_data)
## # A tibble: 298 × 6
## date series_id value realtime_start realtime_end inflation_rate
## <date> <chr> <dbl> <date> <date> <dbl>
## 1 1999-04-01 CPIAUCNS 166. 2024-02-18 2024-02-18 0.727
## 2 1999-05-01 CPIAUCNS 166. 2024-02-18 2024-02-18 0
## 3 1999-06-01 CPIAUCNS 166. 2024-02-18 2024-02-18 0
## 4 1999-07-01 CPIAUCNS 167. 2024-02-18 2024-02-18 0.301
## 5 1999-08-01 CPIAUCNS 167. 2024-02-18 2024-02-18 0.240
## 6 1999-09-01 CPIAUCNS 168. 2024-02-18 2024-02-18 0.479
## 7 1999-10-01 CPIAUCNS 168. 2024-02-18 2024-02-18 0.179
## 8 1999-11-01 CPIAUCNS 168. 2024-02-18 2024-02-18 0.0595
## 9 1999-12-01 CPIAUCNS 168. 2024-02-18 2024-02-18 0
## 10 2000-01-01 CPIAUCNS 169. 2024-02-18 2024-02-18 0.297
## # ℹ 288 more rows
#Filtering data for the last 25 years
start_date <- Sys.Date() - 25 * 365 # assuming each year is 365 days
cpi_data <- filter(cpi_data, date >= start_date)
fed_funds_data <- filter(fed_funds_data, date >= start_date)
unemployment_data <- filter(unemployment_data, date >= start_date)
#Calculating percentage change in CPI for the last 25 years
cpi_data <- arrange(cpi_data, date)
cpi_data <- mutate(cpi_data, inflation_rate = ((value / lag(value)) - 1) * 100)
#Filtering out the first row as it doesn't have a previous period
cpi_data <- cpi_data %>% filter(!is.na(inflation_rate))
#Aligning the lengths before binding columns
min_length <- min(length(cpi_data$date), length(unemployment_data$date))
combined_data <- bind_cols(
cpi_data %>% select(date, inflation_rate),
unemployment_data %>% slice(1:min_length) %>% select(date, value),
fed_funds_data %>% slice(1:min_length) %>% select(date, value)
)
## New names:
## • `date` -> `date...1`
## • `date` -> `date...3`
## • `value` -> `value...4`
## • `date` -> `date...5`
## • `value` -> `value...6`
## # A tibble: 297 × 6
## date...1 inflation_rate date...3 value...4 date...5 value...6
## <date> <dbl> <date> <dbl> <date> <dbl>
## 1 1999-05-01 0 1999-03-01 4.2 1999-03-01 4.81
## 2 1999-06-01 0 1999-04-01 4.3 1999-04-01 4.74
## 3 1999-07-01 0.301 1999-05-01 4.2 1999-05-01 4.74
## 4 1999-08-01 0.240 1999-06-01 4.3 1999-06-01 4.76
## 5 1999-09-01 0.479 1999-07-01 4.3 1999-07-01 4.99
## 6 1999-10-01 0.179 1999-08-01 4.2 1999-08-01 5.07
## 7 1999-11-01 0.0595 1999-09-01 4.2 1999-09-01 5.22
## 8 1999-12-01 0 1999-10-01 4.1 1999-10-01 5.2
## 9 2000-01-01 0.297 1999-11-01 4.1 1999-11-01 5.42
## 10 2000-02-01 0.592 1999-12-01 4 1999-12-01 5.3
## # ℹ 287 more rows
Checking columns names to make sure names and columns are in dataset
check_columns <- function(data) {
if (!exists("data")) {
stop("The 'data' variable does not exist.")
}
col_names <- colnames(data)
if (length(col_names) == 0) {
cat("The dataset has no columns.\n")
} else {
cat("Columns in the dataset:\n")
for (col in col_names) {
cat("-", col, "\n")
}
}
}
#Example usage:
check_columns(cpi_data)
## Columns in the dataset:
## - date
## - series_id
## - value
## - realtime_start
## - realtime_end
## - inflation_rate
## Columns in the dataset:
## - date
## - series_id
## - value
## - realtime_start
## - realtime_end
## Columns in the dataset:
## - date
## - series_id
## - value
## - realtime_start
## - realtime_end
## Columns in the dataset:
## - date
## - series_id
## - value
## - realtime_start
## - realtime_end
## - inflation_rate
## Columns in the dataset:
## - date
## - series_id
## - value
## - realtime_start
## - realtime_end
## Columns in the dataset:
## - date
## - series_id
## - value
## - realtime_start
## - realtime_end
## Warning: package 'lubridate' was built under R version 4.2.3
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
#Function to calculate percentage change from previous year
calculate_pct_change <- function(data) {
data %>%
arrange(date) %>%
mutate(year = year(date)) %>%
group_by(year) %>%
summarise(value = mean(value, na.rm = TRUE)) %>%
ungroup() %>%
mutate(pct_change = (value / lag(value) - 1) * 100) %>%
filter(!is.na(pct_change))
}
#Calculating percentage change for each dataset
cpi_pct_change <- calculate_pct_change(cpi_data)
fed_funds_pct_change <- calculate_pct_change(fed_funds_data)
unemployment_pct_change <- calculate_pct_change(unemployment_data)
#Combining the percentage change data
combined_pct_change <- bind_rows(
cpi_pct_change %>% mutate(type = "Consumer Price Index"),
fed_funds_pct_change %>% mutate(type = "FED Funds Rate"),
unemployment_pct_change %>% mutate(type = "Unemployment Rate")
)
#Creating a single plot comparing CPI, FED Funds Rate, and Unemployment Rate
combined_plot <- ggplot(combined_pct_change, aes(x = year, y = pct_change, color = type)) +
geom_line() +
labs(title = "Yearly Percentage Change in Economic Indicators",
x = "Year",
y = "Percentage Change (%)",
color = "Indicator Type") +
theme_minimal()
#Displaying the combined plot
print(combined_plot)
In conclusion, the intricate task of balancing economic stability with public health concerns poses a delicate challenge, particularly evident when steering the economy through global crises. The analysis of the graphs underscores the difficulties encountered by the FED Funds Rate in meeting the Congressional mandate from 2008 to 2022. This period was characterized by global economic recessions, unanticipated financial crises, and public health emergencies, notably the COVID-19 pandemic. The complexities involved in managing the economy amid unprecedented challenges underscore the formidable tasks faced by policymakers in navigating through multifaceted and unpredictable global scenarios.
Federal Reserve of Economic Data (FRED) package: https://github.com/sboysel/fredr https://fred.stlouisfed.org/docs/api/api_key.html