Data sources:
https://fred.stlouisfed.org/
CPI: https://fred.stlouisfed.org/series/CORESTICKM159SFRBATL
Unemployment rate: https://fred.stlouisfed.org/series/UNRATE
Fed Funds: https://fred.stlouisfed.org/series/FEDFUNDS
library(tidyverse)
library(dplyr)
#Bring in the Data
ff <- as.data.frame(read_csv ("https://raw.githubusercontent.com/dianaplunkett/608/main/FEDFUNDS.csv"))
cp <- as.data.frame( read_csv ("https://raw.githubusercontent.com/dianaplunkett/608/main/FRED-CPI.csv"))
unr <- as.data.frame(read_csv ("https://raw.githubusercontent.com/dianaplunkett/608/main/FRED-UNRATE.csv"))
ff<- filter(ff, year(DATE)>1998)
cp<- filter(cp, year(DATE)>1998)
unr<- filter(unr, year(DATE)>1998)
cp <- cp%>%
rename(cpi=CORESTICKM159SFRBATL)
ggplot() +
geom_line(data=unr,
color="#4682B4",
linetype=2,
linewidth =1,
aes(x=DATE, y=UNRATE) )+
geom_line(data=ff,
color="#E69F00",linewidth=1.5,
aes(x=DATE, y=FEDFUNDS))+
geom_line(data=cp,
color="#145a32",linetype=5,linewidth=1,
aes(x=DATE, y=cpi))+
theme_classic()+
theme(axis.title = element_blank())
Doing this for all 3 data sets (FedFunds, CPI and Unemployment) allows us to highlight the “big” changes.
ff <- ff %>%
mutate(
ffMoM = (FEDFUNDS - lag(FEDFUNDS))/lag(FEDFUNDS)
) %>%
mutate(ffMoM = ifelse(is.na(ffMoM), 0, ffMoM))
cp <- cp%>%
mutate(
cpMoM = (cpi - lag(cpi))/lag(cpi)
) %>%
mutate(cpMoM = ifelse(is.na(cpMoM), 0, cpMoM))
unr <- unr %>%
mutate(
unrMoM = (UNRATE - lag(UNRATE))/lag(UNRATE)
) %>%
mutate(unrMoM = ifelse(is.na(unrMoM), 0, unrMoM))
Whoa, that’s a mess.
ggplot() +
geom_line(data=unr,
color="#4682B4",
linetype=2,
linewidth =.5,
aes(x=DATE, y=unrMoM) )+
geom_line(data=ff,
color="#E69F00",linewidth=.5,
aes(x=DATE, y=ffMoM))+
geom_line(data=cp,
color="#145a32",linetype=5,linewidth=.5,
aes(x=DATE, y=cpMoM))+
theme_classic()+
theme(axis.title = element_blank())
First, make indicators for Big MoM changes.
For Fed Funds, use +/- 0.5 as big moves.
CPI, use +/- 0.15.
Unemployment, use +/- 0.07.
ff <- ff %>% mutate(ffbig = abs(ff$ffMoM)>0.5)
cp <- cp %>% mutate(cpbig=abs(cp$cpMoM)>0.15)
unr <- unr %>% mutate(unrbig=abs(unr$unrMoM)>0.07)
# and sep data sets for just big
ffbig<- filter(ff, ffbig)
cpbig<- filter(cp, cpbig)
unrbig<- filter(unr, unrbig)
ggplot() +
geom_line(data=ff,
color='#FFEFD5',
linewidth =.5,
aes(x=DATE,
y=FEDFUNDS))+
geom_line(data=cp,
color='#8FBC8B',
linetype=5,
linewidth=.5,
aes(x=DATE,
y=cpi))+
geom_line(data=unr,
color='#B0C4DE',
linetype=2,
linewidth=.5,
aes(x=DATE,
y=UNRATE))+
geom_point(data=ffbig,
color="#E69F00",
size=2,
aes(x=DATE,
y=FEDFUNDS)) +
geom_point(data=cpbig,
color="#145a32",
size=2,
aes(x=DATE,
y=cpi))+
geom_point(data=unrbig,
color="#4682B4",
size=2,
aes(x=DATE,
y=UNRATE))+
theme_classic()+
theme(axis.title = element_blank())
First Area - 2007 - 2016
ff.1<- filter(ff,
year(DATE)>2007 & year(DATE)<=2016)
ffbig.1<- filter(ffbig,
year(DATE)>2007 & year(DATE)<=2016)
cp.1<- filter(cp,
year(DATE)>2007 & year(DATE)<=2016)
cpbig.1<- filter(cpbig,
year(DATE)>2007 & year(DATE)<=2016)
unr.1<- filter(unr,
year(DATE)>2007 & year(DATE)<=2016)
unrbig.1<- filter(unrbig,
year(DATE)>2007 & year(DATE)<=2016)
ggplot() +
geom_line(data=ff.1,
color='#FFEFD5',
linewidth =1,
aes(x=DATE,
y=FEDFUNDS))+
geom_line(data=cp.1,
color='#8FBC8B',
linetype=5,
linewidth=1,
aes(x=DATE,
y=cpi))+
geom_line(data=unr.1,
color='#B0C4DE',
linetype=2,
aes(x=DATE,
y=UNRATE))+
geom_point(data=ffbig.1,
color="#E69F00",
size=2,
aes(x=DATE,
y=FEDFUNDS)) +
geom_point(data=cpbig.1,
color="#145a32",
size=2,
aes(x=DATE,
y=cpi))+
geom_point(data=unrbig.1,
color="#4682B4",
size=2,
aes(x=DATE,
y=UNRATE))+
theme_classic()+
theme(axis.title = element_blank())
Second Area - 2020 - 2024
ff.2<- filter(ff,
year(DATE)>=2020)
ffbig.2<- filter(ffbig,
year(DATE)>=2020)
cp.2<- filter(cp,
year(DATE)>=2020)
cpbig.2<- filter(cpbig,
year(DATE)>=2020)
unr.2<- filter(unr,
year(DATE)>=2020)
unrbig.2<- filter(unrbig,
year(DATE)>=2020)
ggplot() +
geom_line(data=ff.2,
color='#FFEFD5',
linewidth =1,
aes(x=DATE,
y=FEDFUNDS))+
geom_line(data=cp.2,
color='#8FBC8B',
linetype=5,
linewidth=1,
aes(x=DATE,
y=cpi))+
geom_line(data=unr.2,
color='#B0C4DE',
linetype=2,
aes(x=DATE,
y=UNRATE))+
geom_point(data=ffbig.2,
color="#E69F00",
size=2,
aes(x=DATE,
y=FEDFUNDS)) +
geom_point(data=cpbig.2,
color="#145a32",
size=2,
aes(x=DATE,
y=cpi))+
geom_point(data=unrbig.2,
color="#4682B4",
size=2,
aes(x=DATE,
y=UNRATE))+
theme_classic()+
theme(axis.title = element_blank())