Presidential Economic Performance

Harold Nelson

10/14/2019

Setup

Load all of our usual packages. Add fredr.

library(tidyverse)
## ── Attaching packages ─────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.2.1       ✔ purrr   0.2.5  
## ✔ tibble  2.0.1       ✔ dplyr   0.8.0.1
## ✔ tidyr   0.8.1       ✔ stringr 1.4.0  
## ✔ readr   1.1.1       ✔ forcats 0.3.0
## ── Conflicts ────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(readr)
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
## 
##     date
library(fredr)
library(ggforce)

Connect to FRED

# Note: the key is a quoted string
fredr_set_key("2923ccf83015d6b33cfda99a3c83093e")

Get Presidential Term Dates

Presidents <- read_csv("Presidents.csv",col_types = cols(Date = col_date(format = "%m/%d/%y")))
Presidents = filter(Presidents,Date <= ymd("2019-10-01") & Date > ymd("1980-01-01"))
View(Presidents)

Unemployment Rate

unratef = fredr_series_observations(
  series_id = "UNRATE",
  observation_start = as.Date("1980-04-01"),
  frequency = "q")

unratef$president = Presidents$President[1:158]
unrate = unratef$value

ung = ggplot(unratef,aes(x=date,y=value)) +
  geom_point(size=3) + 
  geom_mark_rect(aes(fill = president,label=president))

ung

# ggplotly(ung)

Real GDP

realgdpf = fredr_series_observations(
  series_id = "A191RL1Q225SBEA",
  observation_start = as.Date("1980-01-01"),
  frequency = "q")

realgdpf$president = Presidents$President[1:158]
realgdp = realgdpf$value

rg = ggplot(realgdpf,aes(x=date,y=value)) +
  geom_point(size=.5)
ggplotly(rg)

Jobs Added

newjobsf = fredr_series_observations(
  series_id = "PAYEMS",
  observation_start = as.Date("1980-01-01"),
  frequency = "q",
  units = "chg")

newjobsf$president = Presidents$President
newjobs = newjobsf$value

rg = ggplot(newjobsf,aes(x=date,y=value)) +
  geom_point(size=.5)
ggplotly(rg)

Rate of Inflation

infcpif = fredr_series_observations(
  series_id = "CPIAUCSL",
  observation_start = as.Date("1980-04-01"),
  frequency = "q",
  units = "chg")

infcpif$president = Presidents$President[1:158]
infcpi = infcpif$value

rg = ggplot(infcpif,aes(x=date,y=value)) +
  geom_point(aes(color=president),size=3) + 
  geom_mark_rect(aes(fill=president,
                     label=president),show.legend=F)
rg

# ggplotly(rg)

Labor Force Participation Rate (Change)

lfpr25_54f = fredr_series_observations(
  series_id = "LNS11300060",
  observation_start = as.Date("1980-04-01"),
  frequency = "q",
  units = "chg")

lfpr25_54 = lfpr25_54f$value

rg = ggplot(lfpr25_54f,aes(x=date,y=value)) +
  geom_point(size=.5)
ggplotly(rg)

Make the dataframe.

indicators = data.frame(Presidents[1:158,],realgdp,
                        infcpi,lfpr25_54,unrate)
glimpse(indicators)
## Observations: 158
## Variables: 6
## $ Date      <date> 1980-04-01, 1980-07-01, 1980-10-01, 1981-01-01, 1981-…
## $ President <chr> "Reagan", "Reagan", "Reagan", "Reagan", "Reagan", "Rea…
## $ realgdp   <dbl> 1.3, -8.0, -0.5, 7.7, 8.1, -2.9, 4.9, -4.3, -6.1, 1.8,…
## $ infcpi    <dbl> 2.66666667, 1.53333333, 2.33333333, 2.36666667, 1.8333…
## $ lfpr25_54 <dbl> -0.06666667, 0.03333333, 0.10000000, 0.36666667, 0.333…
## $ unrate    <dbl> 7.3, 7.7, 7.4, 7.4, 7.4, 7.4, 8.2, 8.8, 9.4, 9.9, 10.7…

nrow(Presidents)