Sliding Calculations of Risks of Federal Reserve Rate Cuts
Update: 2025-08-24
Description
[This article was first published on DataGeeek, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Bank of America cautioned that the Federal Reserve risks making a policy error if it starts cutting rates next month.
They indicated that economic activity has increased after a slowdown in the first half of the year, and if that is accurate, the labor market is likely to recover as well.
The rolling mean chart shows rate cuts came after the significant uptrend of unemployment, and we can not see such a that increasing recently.
<figure>
<svg fill="none" height="12" viewBox="0 0 12 12" width="12" xmlns="http://www.w3.org/2000/svg">
<path d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" fill="#fff">
</svg>
</button></figure>
Source code:
library(tidyverse)
library(timetk)
#U.S. Unemployment Rate
df_unemployment <-
read.delim("https://raw.githubusercontent.com/mesdi/blog/refs/heads/main/unemployment") %>%
as_tibble() %>%
janitor::clean_names() %>%
#removing parentheses and the text within
mutate(release_date = str_remove(release_date, " \\(.*\\)"),
actual = str_remove(actual, "%")) %>%
mutate(release_date = parse_date(release_date, "%b %d, %Y")) %>%
mutate(release_date = floor_date(release_date, "month") %m-% months(1),
actual = as.numeric(actual)) %>%
select(date = release_date, 'U.S. Unemployment Rate' = actual) %>%
drop_na()
#Fed Interest Rate
df_fed_rates <-
read.delim("https://raw.githubusercontent.com/mesdi/blog/refs/heads/main/fed_rates.txt") %>%
as_tibble() %>%
janitor::clean_names() %>%
#removing parentheses and the text within
mutate(release_date = str_remove(release_date, " \\(.*\\)"),
actual = str_remove(actual, "%")) %>%
mutate(release_date = parse_date(release_date, "%b %d, %Y")) %>%
mutate(release_date = floor_date(release_date, "month"),
actual = as.numeric(actual)) %>%
select(date = release_date, 'Fed Interest Rate' = actual) %>%
#makes regular time series by filling the time gaps
pad_by_time(date, .by = "month") %>%
fill('Fed Interest Rate', .direction = "down") %>%
drop_na()
#Survey data
df_survey <-
df_unemployment %>%
left_join(df_fed_rates) %>%
drop_na() %>%
pivot_longer(2:3,
names_to = "symbol",
values_to = "value")
#Sliding (Rolling) Calculations
# Make the rolling function
roll_avg_6 <-
slidify(.f = mean,
.period = 6,
.align = "center",
.partial = TRUE)
# Apply the rolling function
df_survey %>%
select(symbol,
date,
value) %>%
group_by(symbol) %>%
# Apply Sliding Function
mutate(rolling_avg_6 = roll_avg_6(value)) %>%
tidyr::pivot_longer(cols = c(value, rolling_avg_6)) %>%
plot_time_series(date,
value/100,
.color_var = name,
.line_size = 1.2,
.facet_ncol = 1,
.smooth = FALSE,
.interactive = FALSE) +
labs(title = "6-month Smoothing Line",
y = "",
x = "") +
scale_y_continuous(labels = scales::percent_format()) +
theme_tq(base_family = "Roboto Slab", base_size = 16) +
theme(plot.title = ggtext::element_markdown(face = "bold"),
plot.background = element_rect(fill = "azure"),
strip.text = element_text(face = "bold", color = "snow"),
strip.background = element_rect(fill = "orange"),
axis.text = element_text(face = "bold"),
legend.position = "none")
To leave a comment for the author, please follow the link and comment on their blog: DataGeeek.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Comments
In Channel