fed_rates <- read_csv("../challenge_datasets/FedFundsRate.csv")
## Rows: 904 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (10): Year, Month, Day, Federal Funds Target Rate, Federal Funds Upper T...
##
## ℹ 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.
head(fed_rates)
## # A tibble: 6 × 10
## Year Month Day `Federal Funds Target Rate` `Federal Funds Upper Target`
## <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1954 7 1 NA NA
## 2 1954 8 1 NA NA
## 3 1954 9 1 NA NA
## 4 1954 10 1 NA NA
## 5 1954 11 1 NA NA
## 6 1954 12 1 NA NA
## # ℹ 5 more variables: `Federal Funds Lower Target` <dbl>,
## # `Effective Federal Funds Rate` <dbl>, `Real GDP (Percent Change)` <dbl>,
## # `Unemployment Rate` <dbl>, `Inflation Rate` <dbl>
There wasn’t much to tidy other than removing some NA values for ease of work later on.
fed_rates <- fed_rates %>%
mutate(Month = paste0(Year, "-", Month),
Date = as_date(Month, format = "%Y-%m")) %>%
select(-Month)
fed_rates_plot <- fed_rates %>%
filter(!is.na(`Effective Federal Funds Rate`))
fed_rates <- fed_rates %>%
mutate(across(c(`Real GDP (Percent Change)`,
`Unemployment Rate`,
`Inflation Rate`),
as.numeric))
fed_rates
## # A tibble: 904 × 10
## Year Day `Federal Funds Target Rate` `Federal Funds Upper Target`
## <dbl> <dbl> <dbl> <dbl>
## 1 1954 1 NA NA
## 2 1954 1 NA NA
## 3 1954 1 NA NA
## 4 1954 1 NA NA
## 5 1954 1 NA NA
## 6 1954 1 NA NA
## 7 1955 1 NA NA
## 8 1955 1 NA NA
## 9 1955 1 NA NA
## 10 1955 1 NA NA
## # ℹ 894 more rows
## # ℹ 6 more variables: `Federal Funds Lower Target` <dbl>,
## # `Effective Federal Funds Rate` <dbl>, `Real GDP (Percent Change)` <dbl>,
## # `Unemployment Rate` <dbl>, `Inflation Rate` <dbl>, Date <date>
We can take a loop at federal funds target over time! This is important as it would be easy to observe the change of rates over time and could be a part of further analysis on maybe why the rates fluctuate.
ggplot(data = fed_rates) +
geom_smooth(mapping = aes(x = Year,
y = `Effective Federal Funds Rate`),
method="loess", formula=y~x, se=FALSE) +
labs(
title = "Effective Federal Funds Rate Over Time",
subtitle = "Interest rates",
x = "Year",
y = "Effective Fed Funds Rate (%)"
) +
theme_minimal() +
theme(plot.title = element_text(size=14))
## Warning: Removed 152 rows containing non-finite values (`stat_smooth()`).
ggplot(fed_rates, aes(Year, `Unemployment Rate`)) +
geom_smooth(aes(color="Unemployment"),
method="loess", se=FALSE, span=0.25) +
geom_smooth(aes(y = `Inflation Rate`, color="Inflation"),
method="loess", se=FALSE, span=0.25) +
scale_y_continuous(sec.axis = sec_axis(~.*1, name="Inflation")) +
labs(title="Inflation and Unemployment over Time",
color="") +
theme_classic()
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 152 rows containing non-finite values (`stat_smooth()`).
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 194 rows containing non-finite values (`stat_smooth()`).
Reading about the Philips Curve on the news, I was actually pretty curious on how this relationship holds and it seems to hold in some cases. We can see that in most cases it holds this relationship!