U.S. Prices (1920-1942)
(ref:gold-standard-1920-1942) U.S. Prices (1920-1942)
Code
shiller %>%
select(date, CPI) %>%
filter(date >= as.Date("1920-01-01"),
date <= as.Date("1942-01-01")) %>%
na.omit %>%
ggplot(.) + geom_line(aes(x = date, y = CPI)) +
ylab("Price Level") +
scale_x_date(breaks = c(nber_recessions$Peak, nber_recessions$Trough),
labels = date_format("%y"),
limits = c(as.Date("1920-01-01"), as.Date("1942-01-01"))) +
geom_rect(data = nber_recessions,
aes(xmin = Peak, xmax = Trough, ymin = -Inf, ymax = +Inf),
fill = 'grey', alpha = 0.5) +
scale_y_continuous(breaks = seq(50, 400, 50)) +
theme_minimal() + xlab("") +
geom_vline(xintercept = as.Date("1933-04-20"), linetype = "dashed", color = "red")
S and P 500
Linear
Code
plot_linear <- shiller %>%
select(date, s_p_price) %>%
arrange(date) %>%
mutate(s_p_price = 10*s_p_price/s_p_price[1]) %>%
ggplot() + geom_line(aes(x = date, y = s_p_price)) +
theme_minimal() + xlab("") + ylab("") +
theme(legend.title = element_blank(),
legend.position = c(0.5, 0.9)) +
scale_y_continuous(breaks = seq(0, 10000, 1000)) +
scale_x_date(breaks = as.Date(paste0(seq(1800, 2100, 20), "-01-01")),
labels = date_format("%Y"))
plot_linear
Log
Code
plot_log <- plot_linear +
scale_y_log10(breaks = c(10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000))
plot_log
Bind
Code
ggpubr::ggarrange(plot_linear + ggtitle("Linear scale"), plot_log + ggtitle("Log scale"), common.legend = T)
Cyclically-Adjusted PE (1920-1942)
Code
shiller %>%
select(date, CAPE) %>%
filter(date >= as.Date("1920-01-01"), date <= as.Date("1942-01-01")) %>%
na.omit %>%
ggplot(.) + geom_line(aes(x = date, y = CAPE)) +
ylab("Cyclically Adjusted P/E Ratio") +
scale_x_date(breaks = as.Date(paste0(seq(1920, 1942, 2), "-01-01")),
labels = date_format("%y")) +
geom_rect(data = nber_recessions %>%
filter(Peak > as.Date("1920-01-01"), Peak < as.Date("1942-01-01")),
aes(xmin = Peak, xmax = Trough, ymin = -Inf, ymax = +Inf),
fill = 'grey', alpha = 0.5) +
scale_y_continuous(breaks = seq(5, 30, 5)) +
theme_minimal() + xlab("") +
geom_vline(xintercept = as.Date("1929-10-24"), linetype = "dashed", color = viridis(3)[2])
Earnings Yield
Code
shiller %>%
select(date, CAPE) %>%
na.omit %>%
filter(date >= as.Date("1980-01-01")) %>%
na.omit %>%
ggplot(.) + geom_line(aes(x = date, y = 1/CAPE)) +
ylab("Cyclically Adjusted Eearnings / Price Ratio") +
scale_x_date(breaks = as.Date(paste0(seq(1980, 2020, 5), "-01-01")),
labels = date_format("%y"),) +
geom_rect(data = nber_recessions %>%
filter(Peak > as.Date("1980-01-01")),
aes(xmin = Peak, xmax = Trough, ymin = -Inf, ymax = +Inf),
fill = 'grey', alpha = 0.5) +
scale_y_continuous(breaks = 0.01*seq(0, 30, 1),
labels = scales::percent_format(accuracy = 1)) +
theme_minimal() + xlab("")
Dividend / Earnings Yield
Code
shiller %>%
mutate(dividend_yield = dividend / s_p_price,
earnings_yield = earnings / s_p_price) %>%
select(date, dividend_yield, earnings_yield) %>%
gather(variable, value, -date) %>%
na.omit %>%
filter(date >= as.Date("1980-01-01")) %>%
mutate(variable_desc = case_when(variable == "dividend_yield" ~ "Dividend Yield (%)",
variable == "earnings_yield" ~ "Earnings Yield (%)")) %>%
na.omit %>%
ggplot(.) + geom_line(aes(x = date, y = value, color = variable_desc)) +
ylab("Dividend / Earnings Yield (%)") + xlab("") + theme_minimal() +
scale_color_manual(values = viridis(3)[1:2]) +
scale_x_date(breaks = as.Date(paste0(seq(1980, 2020, 5), "-01-01")),
labels = date_format("%y"),) +
geom_rect(data = nber_recessions %>%
filter(Peak > as.Date("1980-01-01")),
aes(xmin = Peak, xmax = Trough, ymin = -Inf, ymax = +Inf),
fill = 'grey', alpha = 0.5) +
theme(legend.position = c(0.45, 0.9),
legend.title = element_blank()) +
scale_y_continuous(breaks = 0.01*seq(0, 30, 1),
labels = scales::percent_format(accuracy = 1))
War Bear Market
Code
shiller %>%
select(date, CAPE) %>%
filter(date >= as.Date("1939-01-01"),
date <= as.Date("1955-01-01")) %>%
na.omit %>%
ggplot(.) + geom_line(aes(x = date, y = CAPE)) +
ylab("Cyclically Adjusted P/E Ratio") +
scale_x_date(breaks = as.Date(paste0(seq(1920, 1960, 2), "-01-01")),
labels = date_format("%y")) +
geom_rect(data = nber_recessions %>%
filter(Peak > as.Date("1939-01-01"), Peak < as.Date("1955-01-01")),
aes(xmin = Peak, xmax = Trough, ymin = -Inf, ymax = +Inf),
fill = 'grey', alpha = 0.5) +
scale_y_continuous(breaks = seq(5, 30, 1)) +
theme_minimal() + xlab("")
Post-War ups and downs
Code
shiller %>%
select(date, CAPE) %>%
filter(date >= as.Date("1945-01-01"),
date <= as.Date("2020-01-01")) %>%
na.omit %>%
ggplot(.) + geom_line(aes(x = date, y = CAPE)) +
ylab("Cyclically Adjusted P/E Ratio") +
scale_x_date(breaks = as.Date(paste0(seq(1920, 2020, 5), "-01-01")),
labels = date_format("%y")) +
scale_y_continuous(breaks = seq(0, 100, 5)) +
geom_rect(data = nber_recessions %>%
filter(Peak > as.Date("1945-01-01"), Peak < as.Date("2020-01-01")),
aes(xmin = Peak, xmax = Trough, ymin = -Inf, ymax = +Inf),
fill = 'grey', alpha = 0.5) +
theme_minimal() + xlab("")