dataset | LAST_DOWNLOAD |
---|---|
cpi | 2021-01-09 |
unr | 2021-03-16 |
<- cpi %>%
data_DEU bind_rows(unr) %>%
filter(iso3c %in% c("DEU"),
month(date) == 12,
%in% c("CPM", "UNM")) %>%
variable select(variable, date, value) %>%
spread(variable, value) %>%
%>%
na.omit mutate(UNM = UNM / 100,
CPM = log(CPM),
CPM = (CPM - lag(CPM, 1))) %>%
filter(date != as.Date("1923-12-31"),
!= as.Date("1922-12-31"))
date
%>%
data_DEU gather(variable, value, -date) %>%
left_join(variable, by = "variable") %>%
ggplot(.) +
geom_line(aes(x = date, y = value, color = Variable, linetype = Variable)) +
theme_minimal() + xlab("") + ylab("Unemployment, Inflation") +
scale_x_date(breaks = seq(1700, 2020, 20) %>% paste0("-01-01") %>% as.Date,
labels = date_format("%Y")) +
scale_y_continuous(breaks = 0.01*seq(-50, 100, 5),
labels = percent_format(accuracy = 1, prefix = "")) +
scale_color_manual(values = viridis(5)[1:4]) +
theme(legend.position = c(0.7, 0.80),
legend.title = element_blank())
%>%
data_DEU filter(date >= as.Date("1954-01-01")) %>%
gather(variable, value, -date) %>%
left_join(variable, by = "variable") %>%
ggplot(.) +
geom_line(aes(x = date, y = value, color = Variable, linetype = Variable)) +
theme_minimal() + xlab("") + ylab("Unemployment, Inflation") +
scale_x_date(breaks = seq(1700, 2020, 5) %>% paste0("-01-01") %>% as.Date,
labels = date_format("%y")) +
scale_y_continuous(breaks = 0.01*seq(-50, 100, 1),
labels = percent_format(accuracy = 1, prefix = "")) +
scale_color_manual(values = viridis(5)[1:4]) +
theme(legend.position = c(0.2, 0.9),
legend.title = element_blank())
if (knitr::is_html_output()) type <- "html" else type <- "latex"
<- data_DEU %>%
DEU_post_1971 filter(date >= as.Date("1971-01-01")) %>%
lm(CPM ~ UNM, data = .)
<- data_DEU %>%
DEU_pre_1971 filter(date <= as.Date("1971-01-01")) %>%
lm(CPM ~ UNM, data = .)
<- data_DEU %>%
DEU_pre_1914 filter(date <= as.Date("1914-01-01")) %>%
lm(CPM ~ UNM, data = .)
stargazer(DEU_post_1971, DEU_pre_1971, DEU_pre_1914,
header = F,
df = F,
title = "\\textsc{Phillips Curve}",
column.labels = c("Post 1971", "Pre 1971", "Pre 1920"),
dep.var.labels = "Inflation",
covariate.labels = "Unemployment",
intercept.bottom = F,
omit.stat = c("f", "ser", "rsq"),
omit = "Constant",
style = "qje",
notes = "Data",
notes.append = F,
notes.align = "l",
notes.label = "Note:",
type = type)
Inflation | |||
Post 1971 | Pre 1971 | Pre 1920 | |
(1) | (2) | (3) | |
Unemployment | -0.345*** | -0.433* | -0.587 |
(0.106) | (0.218) | (0.429) | |
N | 45 | 73 | 26 |
Adjusted R2 | 0.178 | 0.039 | 0.034 |
Note: | Data |
bind_rows(unr, cpi) %>%
filter(iso3c == "CHE",
%in% c("UNM", "CPM")) %>%
variable select(variable, date, value) %>%
spread(variable, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
inflation = 100*(CPM/lag(CPM, 1)-1)) %>%
filter(year >= 1980,
<= 2005) %>%
year ggplot(.) + theme_minimal() +
geom_point(aes(x = UNM/100, y = inflation/100)) +
xlab("Unemployment Rate") + ylab("Inflation") +
scale_x_continuous(breaks = 0.01*seq(-10, 30, 1),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-20, 20, 1),
labels = scales::percent_format(accuracy = 1)) +
scale_color_viridis_d(option="C", name = "Period", begin = 0.15, end = 0.85)+
stat_smooth(aes(x = UNM/100, y = inflation/100), linetype=2, method="lm") +
theme(legend.title = element_blank(),
legend.position = c(0.2, 0.9))
bind_rows(unr, cpi) %>%
filter(iso3c == "CHE",
%in% c("UNM", "CPM")) %>%
variable select(variable, date, value) %>%
spread(variable, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
inflation = 100*(CPM/lag(CPM, 1)-1)) %>%
filter(year >= 1970,
<= 2020) %>%
year ggplot(.) + theme_minimal() +
geom_point(aes(x = UNM/100, y = inflation/100)) +
xlab("Unemployment Rate") + ylab("Inflation") +
scale_x_continuous(breaks = 0.01*seq(-10, 30, 1),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-20, 40, 2),
labels = scales::percent_format(accuracy = 1)) +
scale_color_viridis_d(option="C", name = "Period", begin = 0.15, end = 0.85)+
stat_smooth(aes(x = UNM/100, y = inflation/100), linetype=2, method="lm") +
theme(legend.title = element_blank(),
legend.position = c(0.2, 0.9))
bind_rows(unr, cpi) %>%
filter(iso3c == "CHE",
%in% c("UNM", "CPM")) %>%
variable select(variable, date, value) %>%
spread(variable, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
CPM = 100*(CPM/lag(CPM, 1)-1)) %>%
filter(year >= 1970,
<= 2005) %>%
year gather(variable, value, -date, -year) %>%
mutate(Variable = ifelse(variable == "UNM", "Unemployment Rate",
"CPI Inflation")) %>%
ggplot(.) + geom_line(aes(x = date, y = value/100, linetype = Variable)) +
theme_minimal() + ylab("") + xlab("") +
scale_x_date(breaks = as.Date(paste0(seq(1960, 2020, 10), "-01-01")),
labels = date_format("%Y")) +
scale_y_continuous(breaks = 0.01*seq(-50, 50, 2),
labels = scales::percent_format(accuracy = 1)) +
theme(legend.position = c(0.8, 0.8),
legend.title = element_blank())
bind_rows(unr, cpi) %>%
filter(iso3c == "CHE",
%in% c("UNM", "CPM")) %>%
variable select(variable, date, value) %>%
spread(variable, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
CPM = 100*(CPM/lag(CPM, 1)-1)) %>%
filter(year >= 1980) %>%
gather(variable, value, -date, -year) %>%
mutate(Variable = ifelse(variable == "UNM", "Unemployment Rate",
"CPI Inflation")) %>%
ggplot(.) + geom_line(aes(x = date, y = value/100, linetype = Variable)) +
theme_minimal() + ylab("") + xlab("") +
scale_x_date(breaks = as.Date(paste0(seq(1960, 2020, 10), "-01-01")),
labels = date_format("%Y")) +
scale_y_continuous(breaks = 0.01*seq(-50, 50, 2),
labels = scales::percent_format(accuracy = 1)) +
theme(legend.position = c(0.8, 0.8),
legend.title = element_blank())
bind_rows(unr, cpi) %>%
filter(iso3c == "JPN",
%in% c("UNM", "CPM")) %>%
variable select(variable, date, value) %>%
spread(variable, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
inflation = 100*(CPM/lag(CPM, 1)-1)) %>%
filter(year >= 1980,
<= 2005) %>%
year ggplot(.) + theme_minimal() +
geom_point(aes(x = UNM/100, y = inflation/100)) +
xlab("Unemployment Rate") + ylab("Inflation") +
scale_x_continuous(breaks = 0.01*seq(-10, 30, 1),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-20, 20, 1),
labels = scales::percent_format(accuracy = 1)) +
scale_color_viridis_d(option="C", name = "Period", begin = 0.15, end = 0.85)+
stat_smooth(aes(x = UNM/100, y = inflation/100), linetype=2, method="lm") +
theme(legend.title = element_blank(),
legend.position = c(0.2, 0.9))
bind_rows(unr, cpi) %>%
filter(iso3c == "JPN",
%in% c("UNM", "CPM")) %>%
variable select(variable, date, value) %>%
spread(variable, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
inflation = 100*(CPM/lag(CPM, 1)-1)) %>%
filter(year >= 1970,
<= 2020) %>%
year ggplot(.) + theme_minimal() +
geom_point(aes(x = UNM/100, y = inflation/100)) +
xlab("Unemployment Rate") + ylab("Inflation") +
scale_x_continuous(breaks = 0.01*seq(-10, 30, 1),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-20, 40, 2),
labels = scales::percent_format(accuracy = 1)) +
scale_color_viridis_d(option="C", name = "Period", begin = 0.15, end = 0.85)+
stat_smooth(aes(x = UNM/100, y = inflation/100), linetype=2, method="lm") +
theme(legend.title = element_blank(),
legend.position = c(0.2, 0.9))
bind_rows(unr, cpi) %>%
filter(iso3c == "JPN",
%in% c("UNM", "CPM")) %>%
variable select(variable, date, value) %>%
spread(variable, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
CPM = 100*(CPM/lag(CPM, 1)-1)) %>%
filter(year >= 1970,
<= 2005) %>%
year gather(variable, value, -date, -year) %>%
mutate(Variable = ifelse(variable == "UNM", "Unemployment Rate",
"CPI Inflation")) %>%
ggplot(.) + geom_line(aes(x = date, y = value/100, linetype = Variable)) +
theme_minimal() + ylab("") + xlab("") +
scale_x_date(breaks = as.Date(paste0(seq(1960, 2020, 10), "-01-01")),
labels = date_format("%Y")) +
scale_y_continuous(breaks = 0.01*seq(-50, 50, 2),
labels = scales::percent_format(accuracy = 1)) +
theme(legend.position = c(0.8, 0.8),
legend.title = element_blank())
bind_rows(unr, cpi) %>%
filter(iso3c == "JPN",
%in% c("UNM", "CPM")) %>%
variable select(variable, date, value) %>%
spread(variable, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
CPM = 100*(CPM/lag(CPM, 1)-1)) %>%
filter(year >= 1980) %>%
gather(variable, value, -date, -year) %>%
mutate(Variable = ifelse(variable == "UNM", "Unemployment Rate",
"CPI Inflation")) %>%
ggplot(.) + geom_line(aes(x = date, y = value/100, linetype = Variable)) +
theme_minimal() + ylab("") + xlab("") +
scale_x_date(breaks = as.Date(paste0(seq(1960, 2020, 10), "-01-01")),
labels = date_format("%Y")) +
scale_y_continuous(breaks = 0.01*seq(-50, 50, 2),
labels = scales::percent_format(accuracy = 1)) +
theme(legend.position = c(0.8, 0.8),
legend.title = element_blank())
bind_rows(unr, cpi) %>%
filter(Ticker %in% c("UNGBRM", "CPGBRM")) %>%
select(Ticker, date, value) %>%
spread(Ticker, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
inflation = 100*(CPGBRM/lag(CPGBRM, 1)-1)) %>%
filter(year >= 1867,
<= 1914) %>%
year ggplot(.) + theme_minimal() +
geom_point(aes(x = UNGBRM/100, y = inflation/100)) +
xlab("Unemployment Rate") + ylab("Inflation") +
scale_x_continuous(breaks = 0.01*seq(-10, 30, 2),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-20, 20, 1),
labels = scales::percent_format(accuracy = 1)) +
scale_color_viridis_d(option="C", name = "Period", begin = 0.15, end = 0.85)+
stat_smooth(aes(x = UNGBRM/100, y = inflation/100), linetype=2, method="lm") +
theme(legend.title = element_blank(),
legend.position = c(0.2, 0.9))
bind_rows(unr, cpi) %>%
filter(Ticker %in% c("UNGBRM", "CPGBRM")) %>%
select(Ticker, date, value) %>%
spread(Ticker, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
inflation = 100*(CPGBRM/lag(CPGBRM, 1)-1)) %>%
filter(year >= 1914,
<= 1945) %>%
year ggplot(.) + theme_minimal() +
geom_point(aes(x = UNGBRM/100, y = inflation/100)) +
xlab("Unemployment Rate") + ylab("Inflation") +
scale_x_continuous(breaks = 0.01*seq(-10, 30, 2),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-30, 40, 5),
labels = scales::percent_format(accuracy = 1)) +
scale_color_viridis_d(option="C", name = "Period", begin = 0.15, end = 0.85)+
stat_smooth(aes(x = UNGBRM/100, y = inflation/100), linetype=2, method="lm") +
theme(legend.title = element_blank(),
legend.position = c(0.2, 0.9))
bind_rows(unr, cpi) %>%
filter(Ticker %in% c("UNGBRM", "CPGBRM")) %>%
select(Ticker, date, value) %>%
spread(Ticker, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
inflation = 100*(CPGBRM/lag(CPGBRM, 1)-1)) %>%
filter(year >= 1970,
<= 2000) %>%
year ggplot(.) + theme_minimal() +
geom_point(aes(x = UNGBRM/100, y = inflation/100)) +
xlab("Unemployment Rate") + ylab("Inflation") +
scale_x_continuous(breaks = 0.01*seq(-10, 30, 1),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-30, 40, 1),
labels = scales::percent_format(accuracy = 1)) +
scale_color_viridis_d(option="C", name = "Period", begin = 0.15, end = 0.85)+
stat_smooth(aes(x = UNGBRM/100, y = inflation/100), linetype=2, method="lm") +
theme(legend.title = element_blank(),
legend.position = c(0.2, 0.9))
bind_rows(unr, cpi) %>%
filter(Ticker %in% c("UNGBRM", "CPGBRM")) %>%
select(Ticker, date, value) %>%
spread(Ticker, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
inflation = 100*(CPGBRM/lag(CPGBRM, 1)-1)) %>%
filter(year >= 2000) %>%
ggplot(.) + theme_minimal() +
geom_point(aes(x = UNGBRM/100, y = inflation/100)) +
xlab("Unemployment Rate") + ylab("Inflation") +
scale_x_continuous(breaks = 0.01*seq(-10, 30, 1),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-30, 40, 1),
labels = scales::percent_format(accuracy = 1)) +
scale_color_viridis_d(option="C", name = "Period", begin = 0.15, end = 0.85)+
stat_smooth(aes(x = UNGBRM/100, y = inflation/100), linetype=2, method="lm") +
theme(legend.title = element_blank(),
legend.position = c(0.2, 0.9))
bind_rows(unr, cpi) %>%
filter(Ticker %in% c("UNGBRM", "CPGBRM")) %>%
select(Ticker, date, value) %>%
spread(Ticker, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
inflation = 100*(CPGBRM/lag(CPGBRM, 1)-1)) %>%
filter(year >= 1867) %>%
mutate(period = case_when(date <= as.Date("1914-01-01") ~ "1867-1914 (Gold Standard)",
<= as.Date("1967-08-15") ~ "1914-1967 (Intra Year)",
date ~ "1967-2020 (Flexible Exchange Rates)")) %>%
T ggplot(.) + theme_minimal() +
geom_point(aes(x = UNGBRM/100, y = inflation/100, color = period)) +
xlab("Unemployment Rate") + ylab("Inflation") +
scale_x_continuous(breaks = 0.01*seq(-10, 10, 1),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-20, 40, 5),
labels = scales::percent_format(accuracy = 1)) +
scale_color_viridis_d(option="C", name = "Period", begin = 0.15, end = 0.85)+
stat_smooth(aes(x = UNGBRM/100, y = inflation/100, color = period), linetype=2, method="lm") +
theme(legend.title = element_blank(),
legend.position = c(0.2, 0.9))
%>%
cpi filter(iso3c == "GBR") %>%
select(date, variable = Ticker, value) %>%
filter(month(date) == 12, day(date) == 31) %>%
mutate(value = log(value) - lag(log(value), 1)) %>%
bind_rows(unr %>%
filter(iso3c == "GBR") %>%
select(date, variable = Ticker, value) %>%
filter(month(date) == 12, day(date) == 31) %>%
mutate(value = value / 100)) %>%
mutate(variable_label = ifelse(variable == "UNGBRM", "Unemployment Rate",
"CPI Inflation")) %>%
ggplot(aes(x = date, y = value, linetype = variable_label), data = .) + geom_line() + theme_minimal() +
scale_x_date(breaks = as.Date(paste0(seq(1800, 2025, 10), "-01-01")),
labels = date_format("%Y"),
limits = as.Date(paste0(c(1800, 1900), "-01-01"))) +
scale_y_continuous(breaks = 0.01*seq(-50, 50, 5),
labels = scales::percent_format(accuracy = 1)) +
theme(legend.position = c(0.5, 0.15),
legend.title = element_blank()) +
ylab("") + xlab("")
%>%
cpi filter(iso3c == "GBR") %>%
select(date, variable = Ticker, value) %>%
filter(month(date) == 12, day(date) == 31) %>%
mutate(value = log(value) - lag(log(value), 1)) %>%
bind_rows(unr %>%
filter(iso3c == "GBR") %>%
select(date, variable = Ticker, value) %>%
filter(month(date) == 12, day(date) == 31) %>%
mutate(value = value / 100)) %>%
mutate(variable_label = ifelse(variable == "UNGBRM", "Unemployment Rate",
"CPI Inflation")) %>%
ggplot(aes(x = date, y = value, linetype = variable_label), data = .) + geom_line() + theme_minimal() +
scale_x_date(breaks = as.Date(paste0(seq(1900, 1970, 10), "-01-01")),
labels = date_format("%Y"),
limits = as.Date(paste0(c(1900, 1970), "-01-01"))) +
scale_y_continuous(breaks = 0.01*seq(-50, 50, 5),
labels = scales::percent_format(accuracy = 1)) +
theme(legend.position = c(0.5, 0.15),
legend.title = element_blank()) +
ylab("") + xlab("")
bind_rows(unr, cpi) %>%
filter(Ticker %in% c("UNGBRM", "CPGBRM")) %>%
select(Ticker, date, value) %>%
spread(Ticker, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
CPGBRM = 100*(CPGBRM/lag(CPGBRM, 1)-1)) %>%
gather(variable, value, -date, -year) %>%
mutate(Variable = ifelse(variable == "UNGBRM", "Unemployment Rate",
"CPI Inflation")) %>%
filter(year >= 1960) %>%
ggplot(aes(x = date, y = value/100, linetype = Variable), data = .) + geom_line() + theme_minimal() +
scale_x_date(breaks = as.Date(paste0(seq(1960, 2020, 10), "-01-01")),
labels = date_format("%Y"),
limits = as.Date(paste0(c(1960, 2020), "-01-01"))) +
scale_y_continuous(breaks = 0.01*seq(-50, 50, 5),
labels = scales::percent_format(accuracy = 1)) +
theme(legend.position = c(0.8, 0.8),
legend.title = element_blank()) +
ylab("") + xlab("")
<- bind_rows(unr, cpi) %>%
data_US_price filter(Ticker %in% c("UNUSAM", "CPUSAM")) %>%
mutate(year = year(date) + 1,
value = value / 100) %>%
filter(month(date) == 12) %>%
mutate(date = date + 1) %>%
select(Ticker, date, value) %>%
spread(Ticker, value) %>%
mutate(CPUSAM_log = log(CPUSAM),
inflation = CPUSAM_log - lag(CPUSAM_log),
inflation_lag = lag(inflation, 1)) %>%
select(date, UNUSAM, inflation, inflation_lag) %>%
na.omit
<- rollify(.f = function(inflation, UNUSAM){
rolling_lm lm(inflation ~ UNUSAM)
window = 20, unlist = FALSE)
},
%>%
data_US_price mutate(roll_lm = rolling_lm(inflation, UNUSAM)) %>%
filter(!is.na(roll_lm)) %>%
mutate(tidied = purrr::map(roll_lm, broom::tidy, conf.int = TRUE)) %>%
unnest(tidied) %>%
select(date, term, estimate, std.error, statistic, p.value, conf.low, conf.high) %>%
filter(term != "(Intercept)") %>%
ggplot(data = ., aes(x = date, y = estimate)) +
geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = 0.25)+
geom_line(color = "black") +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
scale_x_date(breaks = seq(1760, 2025, 20) %>% paste0("-01-01") %>% as.Date,
labels = date_format("%Y")) +
scale_y_continuous(breaks = seq(-10, 10, 1)) +
theme_minimal() + labs(x = "", y = "Slope of the Phillips Curve")
<- rollify(.f = function(inflation, UNUSAM, inflation_lag){
rolling_lm lm(inflation ~ UNUSAM + inflation_lag)
window = 10, unlist = FALSE)
},
%>%
data_US_price mutate(roll_lm = rolling_lm(inflation, UNUSAM, inflation_lag)) %>%
filter(!is.na(roll_lm)) %>%
mutate(tidied = purrr::map(roll_lm, broom::tidy, conf.int = TRUE)) %>%
unnest(tidied) %>%
select(date, term, estimate, std.error, statistic, p.value, conf.low, conf.high) %>%
filter(term != "(Intercept)") %>%
mutate(termf = case_when(term == "inflation_lag" ~ "Persistence of Inflation",
== "UNUSAM" ~ "Slope of the Phillips Curve")) %>%
term ggplot(data = ., aes(x = date, y = estimate)) +
geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = 0.25)+
geom_line(color = "black") +
facet_wrap(~termf, nrow = 2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
scale_x_date(breaks = seq(1760, 2025, 20) %>% paste0("-01-01") %>% as.Date,
labels = date_format("%Y")) +
scale_y_continuous(breaks = seq(-10, 10, 1)) +
theme_minimal() + labs(x = "", y = "")
bind_rows(unr, cpi) %>%
filter(Ticker %in% c("UNUSAM", "CPUSAM")) %>%
select(Ticker, date, value) %>%
spread(Ticker, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
inflation = 100*(CPUSAM/lag(CPUSAM, 1)-1)) %>%
filter(year <= 1945) %>%
mutate(period = case_when(date <= as.Date("1971-08-15") ~ "1947-1971 (Bretton Woods)",
TRUE ~ "1971-2020 (Flexible Exchange Rates)")) %>%
ggplot(.) + theme_minimal() +
geom_point(aes(x = UNUSAM/100, y = inflation/100)) +
xlab("Unemployment Rate") + ylab("Inflation") +
scale_x_continuous(breaks = 0.01*seq(-10, 10, 1),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-20, 20, 1),
labels = scales::percent_format(accuracy = 1)) +
scale_color_viridis_d(option="C", name = "Period", begin = 0.15, end = 0.85)+
stat_smooth(aes(x = UNUSAM/100, y = inflation/100, color = period), linetype=2, method="lm") +
theme(legend.title = element_blank(),
legend.position = c(0.2, 0.9))
bind_rows(unr, cpi) %>%
filter(Ticker %in% c("UNUSAM", "CPUSAM")) %>%
select(Ticker, date, value) %>%
spread(Ticker, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
inflation = 100*(CPUSAM/lag(CPUSAM, 1)-1)) %>%
mutate(period = case_when(date <= as.Date("1945-12-01") ~ "1890-1945 (Gold Standard)",
<= as.Date("1971-08-15") ~ "1945-1971 (Bretton Woods)",
date TRUE ~ "1971-2020 (Flexible Exchange Rates)")) %>%
ggplot(.) + theme_minimal() +
geom_point(aes(x = UNUSAM/100, y = inflation/100, color = period)) +
xlab("Unemployment Rate") + ylab("Inflation") +
scale_x_continuous(breaks = 0.01*seq(-10, 30, 2),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-20, 20, 2),
labels = scales::percent_format(accuracy = 1)) +
scale_color_viridis_d(option="C", name = "Period", begin = 0.15, end = 0.85)+
stat_smooth(aes(x = UNUSAM/100, y = inflation/100, color = period), linetype=2, method="lm") +
theme(legend.title = element_blank(),
legend.position = c(0.7, 0.9))
bind_rows(unr, cpi) %>%
filter(Ticker %in% c("UNUSAM", "CPUSAM")) %>%
select(Ticker, date, value) %>%
spread(Ticker, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
inflation = 100*(CPUSAM/lag(CPUSAM, 1)-1)) %>%
mutate(period = case_when(date <= as.Date("1945-12-01") ~ "1890-1945 (Gold Standard)",
<= as.Date("1971-08-15") ~ "1945-1971 (Bretton Woods)",
date TRUE ~ "1971-2020 (Flexible Exchange Rates)")) %>%
ggplot(.) + theme_minimal() +
geom_point(aes(x = UNUSAM/100, y = inflation/100, color = period)) +
xlab("Unemployment Rate") + ylab("Inflation") +
scale_x_continuous(breaks = 0.01*seq(-10, 30, 2),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-20, 20, 2),
labels = scales::percent_format(accuracy = 1)) +
scale_color_viridis_d(option="C", name = "Period", begin = 0.15, end = 0.85)+
stat_smooth(aes(x = UNUSAM/100, y = inflation/100, color = period), linetype=2, method="lm", fill = NA) +
theme(legend.title = element_blank(),
legend.position = c(0.7, 0.9))
bind_rows(unr, cpi) %>%
filter(Ticker %in% c("UNUSAM", "CPUSAM")) %>%
select(Ticker, date, value) %>%
spread(Ticker, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
inflation = 100*(CPUSAM/lag(CPUSAM, 1)-1)) %>%
filter(year >= 1947) %>%
mutate(period = case_when(date <= as.Date("1971-08-15") ~ "1947-1971 (Bretton Woods)",
TRUE ~ "1971-2020 (Flexible Exchange Rates)")) %>%
ggplot(.) + theme_minimal() +
geom_point(aes(x = UNUSAM/100, y = inflation/100, color = period)) +
xlab("Unemployment Rate") + ylab("Inflation") +
scale_x_continuous(breaks = 0.01*seq(-10, 10, 1),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-20, 20, 1),
labels = scales::percent_format(accuracy = 1)) +
scale_color_viridis_d(option="C", name = "Period", begin = 0.15, end = 0.85)+
stat_smooth(aes(x = UNUSAM/100, y = inflation/100, color = period), linetype=2, method="lm") +
theme(legend.title = element_blank(),
legend.position = c(0.2, 0.9))
bind_rows(unr, cpi) %>%
filter(Ticker %in% c("UNUSAM", "CPUSAM")) %>%
select(Ticker, date, value) %>%
spread(Ticker, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
UNUSAM = UNUSAM/100,
inflation = log(CPUSAM) - lag(log(CPUSAM), 1)) %>%
filter(year <= 1940) %>%
mutate(period = case_when(year <= 1933 ~ "1890-1933 ($20 Gold Standard)",
TRUE ~ "1933-1941 ($35 Gold Standard)")) %>%
ggplot(.) + theme_minimal() +
geom_point(aes(x = UNUSAM, y = inflation, color = period)) +
geom_text_repel(aes(x = UNUSAM, y = inflation, label = year, color = period)) +
xlab("Unemployment Gap") + ylab("Inflation") +
scale_x_continuous(breaks = 0.01*seq(-10, 40, 2),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-20, 20, 2),
labels = scales::percent_format(accuracy = 1)) +
scale_color_viridis_d(option="C", name = "Period", begin = 0.15, end = 0.85) +
stat_smooth(aes(x = UNUSAM, y = inflation), linetype = 2, method = "lm", color = viridis(3)[2]) +
theme(legend.title = element_blank(),
legend.position = c(0.75, 0.9))
bind_rows(unr, cpi) %>%
filter(Ticker %in% c("UNUSAM", "CPUSAM")) %>%
select(Ticker, date, value) %>%
spread(Ticker, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
UNUSAM = UNUSAM/100,
inflation = log(CPUSAM) - lag(log(CPUSAM), 1)) %>%
ggplot(.) + theme_minimal() +
geom_point(aes(x = UNUSAM, y = inflation)) +
geom_text(aes(x = UNUSAM + 0.009, y = inflation, label = date %>% year)) +
xlab("Unemployment Rate") + ylab("Inflation") +
scale_x_continuous(breaks = 0.01*seq(0, 30, 5),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-20, 20, 5),
labels = scales::percent_format(accuracy = 1)) +
stat_smooth(aes(x = UNUSAM, y = inflation), linetype = 2, method = "lm")
%>%
unr filter(Ticker == "UNUSAM") %>%
rename(unr = value) %>%
select(date, unr) %>%
left_join(cpi %>%
filter(Ticker == "CPUSAM") %>%
rename(cpi = value) %>%
select(date, cpi),
by = "date") %>%
filter(date <= as.Date("1968-01-01"),
>= as.Date("1955-01-01")) %>%
date # Make Annual
filter(month(date) == 12 & day(date) == 31) %>%
mutate(cpi_d1ln = log(cpi) - lag(log(cpi), 1),
unr = unr / 100) %>%
ggplot(.) + theme_minimal() +
geom_point(aes(x = unr, y = cpi_d1ln)) +
geom_text(aes(x = unr + 0.002, y = cpi_d1ln, label = date %>% year)) +
xlab("Unemployment Rate") + ylab("Price Inflation") +
scale_x_continuous(breaks = 0.01*seq(0, 40, 0.5),
labels = scales::percent_format(accuracy = 0.5)) +
scale_y_continuous(breaks = 0.01*seq(-20, 20, 0.5),
labels = scales::percent_format(accuracy = 0.5)) +
stat_smooth(aes(x = unr, y = cpi_d1ln), linetype = 2, method = "lm")
bind_rows(unr, cpi) %>%
filter(Ticker %in% c("UNUSAM", "CPUSAM")) %>%
select(-variable, -iso3c) %>%
spread(Ticker, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
filter(date <= as.Date("1946-01-01")) %>%
mutate(CPUSAM_log = log(CPUSAM),
price_inflation = CPUSAM_log - dplyr::lag(CPUSAM_log),
UNUSAM = UNUSAM/100) %>%
select(date, UNUSAM, price_inflation) %>%
gather(variable, value, -date) %>%
mutate(variable_desc = case_when(variable == "UNUSAM" ~ "Unemployment Rate",
== "price_inflation" ~ "Inflation (Price)")) %>%
variable ggplot(.) +
geom_line(aes(x = date, y = value, color = variable_desc)) +
ylab("Unemployment Rate, Inflation") + xlab("") +
scale_color_manual(values = c(viridis(4)[1], viridis(4)[2])) +
scale_linetype_manual(values = c("solid", "solid")) +
scale_x_date(breaks = as.Date(paste0(seq(1850, 2020, 5), "-01-01")),
labels = date_format("%Y")) +
scale_y_continuous(breaks = 0.01*seq(-50, 50, 2),
labels = scales::percent_format(accuracy = 1)) +
theme_minimal() +
theme(legend.position = c(0.2, 0.90),
legend.title = element_blank(),
legend.key.size = unit(0.9, 'lines')) +
geom_vline(xintercept = as.Date("1933-01-01"), linetype = "dotted", color = "black") +
geom_rect(data = data_frame(start = as.Date("1933-01-01"),
end = as.Date("1939-08-15")),
aes(xmin = start, xmax = end, ymin = -Inf, ymax = +Inf),
fill = viridis(4)[4], alpha = 0.1) +
geom_rect(data = data_frame(start = as.Date("1890-01-01"),
end = as.Date("1933-01-01")),
aes(xmin = start, xmax = end, ymin = -Inf, ymax = +Inf),
fill = viridis(4)[3], alpha = 0.1) +
geom_text(data = data_frame(start = c(1910, 1908, 1932, 1928) %>% paste0("-01-01") %>% as.Date,
percent = c(0.26, -0.135, -0.135, 0.26),
name = c("Gold Standard", "Phillips curve Period", "Missing Deflation", "$ deval (Roosevelt)"),
color_new = c("black", "black", "black", grey(0.3))),
aes(x = start, y = percent, label = name),
size = 3, vjust = 0, hjust = 0, nudge_x = 50, color = c(grey(0.3), grey(0.3), grey(0.3), "black"))
bind_rows(unr, cpi) %>%
filter(Ticker %in% c("UNUSAM", "CPUSAM")) %>%
select(Ticker, date, value) %>%
spread(Ticker, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(date = date + 1,
UNUSAM = UNUSAM/100,
inflation = log(CPUSAM) - lag(log(CPUSAM), 1)) %>%
filter(date <= as.Date("1960-01-01")) %>%
ggplot(.) + theme_minimal() +
geom_point(aes(x = UNUSAM, y = inflation)) +
geom_text_repel(aes(x = UNUSAM, y = inflation, label = format(date, format = "%y"))) +
xlab("Unemployment Rate") + ylab("Inflation") +
scale_x_continuous(breaks = 0.01*seq(0, 30, 2),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-20, 20, 5),
labels = scales::percent_format(accuracy = 1)) +
stat_smooth(aes(x = UNUSAM, y = inflation), linetype = 2, method = "lm", color = viridis(3)[2])
%>%
unr filter(Ticker == "UNUSAM") %>%
rename(unr = value) %>%
select(date, unr) %>%
left_join(cpi %>%
filter(Ticker == "CPUSAM") %>%
rename(cpi = value) %>%
select(date, cpi),
by = "date") %>%
filter(date <= as.Date("1933-01-01"),
>= as.Date("1890-01-01")) %>%
date # Make Annual
filter(month(date) == 12 & day(date) == 31) %>%
mutate(cpi_d1ln = log(cpi) - lag(log(cpi), 1),
unr = unr / 100) %>%
ggplot(.) + theme_minimal() +
geom_point(aes(x = unr, y = cpi_d1ln)) +
geom_text_repel(aes(x = unr, y = cpi_d1ln, label = date %>% year)) +
xlab("Unemployment Rate") + ylab("Price Inflation") +
scale_x_continuous(breaks = 0.01*seq(0, 40, 2),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-20, 20, 2),
labels = scales::percent_format(accuracy = 1)) +
stat_smooth(aes(x = unr, y = cpi_d1ln), linetype = 2, method = "lm", color = viridis(3)[2])
%>%
cpi bind_rows(unr) %>%
filter(Ticker %in% c("UNUSAM", "CPUSAM")) %>%
select(Ticker, date, value) %>%
spread(Ticker, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
UNUSAM = UNUSAM/100,
inflation = log(CPUSAM) - lag(log(CPUSAM), 1)) %>%
filter(year <= 1933) %>%
ggplot(.) + theme_minimal() +
geom_point(aes(x = UNUSAM, y = inflation)) +
geom_text(aes(x = UNUSAM + 0.009, y = inflation, label = year)) +
xlab("Unemployment Rate") + ylab("Inflation") +
scale_x_continuous(breaks = 0.01*seq(0, 30, 5),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-20, 20, 5),
labels = scales::percent_format(accuracy = 1)) +
stat_smooth(aes(x = UNUSAM, y = inflation), linetype = 2, method = "lm")
%>%
unr filter(Ticker == "UNUSAM") %>%
rename(unr = value) %>%
select(date, unr) %>%
left_join(cpi %>%
filter(Ticker == "CPUSAM") %>%
rename(cpi = value) %>%
select(date, cpi),
by = "date") %>%
filter(date <= as.Date("1933-01-01"),
>= as.Date("1890-01-01")) %>%
date # Make Annual
filter(month(date) == 12 & day(date) == 31) %>%
mutate(cpi_d1ln = log(cpi) - lag(log(cpi), 1),
unr = unr / 100) %>%
ggplot(.) + theme_minimal() +
geom_point(aes(x = unr, y = cpi_d1ln)) +
geom_text(aes(x = unr + 0.01, y = cpi_d1ln, label = date %>% year)) +
xlab("Unemployment Rate") + ylab("Price Inflation") +
scale_x_continuous(breaks = 0.01*seq(0, 40, 2),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-20, 20, 2),
labels = scales::percent_format(accuracy = 1)) +
stat_smooth(aes(x = unr, y = cpi_d1ln), linetype = 2, method = "lm")
%>%
cpi bind_rows(unr) %>%
filter(Ticker %in% c("UNUSAM", "CPUSAM")) %>%
select(Ticker, date, value) %>%
spread(Ticker, value) %>%
%>%
na.omit filter(month(date) == 12, day(date) == 31) %>%
mutate(year = year(date) + 1,
UNUSAM = UNUSAM/100,
inflation = log(CPUSAM) - lag(log(CPUSAM), 1)) %>%
filter(year <= 1940) %>%
mutate(period = case_when(year <= 1933 ~ "1890-1933 ($20 Gold Standard)",
TRUE ~ "1933-1941 ($35 Gold Standard)")) %>%
ggplot(.) + theme_minimal() +
geom_point(aes(x = UNUSAM, y = inflation, color = period)) +
geom_text(aes(x = UNUSAM + 0.009, y = inflation, label = year, color = period)) +
xlab("Unemployment Gap") + ylab("Inflation") +
scale_x_continuous(breaks = 0.01*seq(-10, 40, 2),
labels = scales::percent_format(accuracy = 1)) +
scale_y_continuous(breaks = 0.01*seq(-20, 20, 2),
labels = scales::percent_format(accuracy = 1)) +
scale_color_viridis_d(option="C", name = "Period", begin = 0.15, end = 0.85) +
stat_smooth(aes(x = UNUSAM, y = inflation), linetype = 2, method = "lm") +
theme(legend.title = element_blank(),
legend.position = c(0.75, 0.9))