Challenge 4 - Fed Rates

fed_rates
ggplot
Tidyr
More data wrangling & Description of Fed Data
Author

Connor Landreth

Published

March 17, 2023

Check wd and load in packages

Code
getwd()
[1] "C:/Github Projects/601_Spring_2023/posts"
Code
setwd("C:/Github Projects/601_Spring_2023/posts/_data")

library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.0      ✔ purrr   1.0.0 
✔ tibble  3.1.8      ✔ dplyr   1.0.10
✔ tidyr   1.2.1      ✔ stringr 1.5.0 
✔ readr   2.1.3      ✔ forcats 0.5.2 
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
Code
library(dplyr)

knitr::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE)

Read in Fed Rates Data

Code
Rates <- read.csv("FedFundsRate.csv")
Error in file(file, "rt"): cannot open the connection
Code
glimpse(Rates)
Error in glimpse(Rates): object 'Rates' not found

Briefly describe the data

The data is inclusive of 10 variables and 904 observations. It look at fed rate data by month, year, and day from 1954-2017. Categories include interest and inflation rates, GDP, and funds target rates (lower x upper bounds)

Tidy Data (as needed)

Next, we’ll combine the variables to make one date variable, then pull it into the Rates data frame

Code
## Make one date variable

df1$Date <- as.Date(with(df1,paste(Year,Month,Day,sep = "-")), "%Y-%m-%d")
Error in with(df1, paste(Year, Month, Day, sep = "-")): object 'df1' not found
Code
View (df1)
Error in as.data.frame(x): object 'df1' not found
Code
Date = df1
Error in eval(expr, envir, enclos): object 'df1' not found
Code
## Combine data frame so "Date" is in original frame
df2 <- cbind(Rates, df1)
Error in cbind(Rates, df1): object 'Rates' not found
Code
View(df2)
Error in as.data.frame(x): object 'df2' not found
Code
## Remove individual (Year, Month, Day variables)
df3 <- df2[-c(1:3,11:13)]
Error in eval(expr, envir, enclos): object 'df2' not found
Code
View(df3)
Error in as.data.frame(x): object 'df3' not found

Next, I will arrange the new

This data is rather tidy, however, I will still elect to make some alterations to look at specific variables. I will look at the comparison between inflation and unemployment.

Code
df4 <- df3 %>% 
  select(6:8) %>% 
  drop_na(Inflation.Rate, Unemployment.Rate)
Error in select(., 6:8): object 'df3' not found
Code
View(df4)
Error in as.data.frame(x): object 'df4' not found

This view of df shows us a side-by-side, isolated comparison of unemployment and inflation rates by year, month, day.

Any additional comments? -

Identify variables that need to be mutated

Are there any variables that require mutation to be usable in your analysis stream? For example, are all time variables correctly coded as dates? Are all string variables reduced and cleaned to sensible categories? Do you need to turn any variables into factors and reorder for ease of graphics and visualization?

Document your work here.

Sort date order from least recent to most recent and graph the trend.Additionally, I will find the mean unemployment rate to aid analysis, and finally mutate column heads for visual appeal.

Code
df4[order(as.Date(df4$Date, format="%m/%d/%Y")),]
Error in eval(expr, envir, enclos): object 'df4' not found
Code
df4 %>% 
  summarise(Mean = mean(Unemployment.Rate))
Error in summarise(., Mean = mean(Unemployment.Rate)): object 'df4' not found
Code
df4 %>% 
  drop_na(Date) %>% 
  filter(Inflation.Rate > 2) %>% 
  ggplot(aes(Date, Unemployment.Rate, color=Inflation.Rate))+
  geom_point(size=3, alpha = 0.8)+
  geom_smooth()+
  theme_linedraw()+
  labs(title="Interest & Unemployment Rates by Date")
Error in drop_na(., Date): object 'df4' not found

The above chart shows high and low unemployment rates from 1954 and 2017. There is slight concentration on the lower end of the spectrum, but almost all of the instances of high inflation rates are seen above the mean of ~6. The lighter blue dots are representative of greater inflation rates, which again, all fall higher on the chart. This chart challenges the intuitive idea that unemployment and inflation are inversely related, meaning that traditionally it’s said the the higher the inflation rate, the lower unemployment is.

Any additional comments?