FAAt108 %>%
filter(Line %in% c(2, 3)) %>%
rename(variable = LineDescription) %>%
left_join(gdp_adjustment, by = "date") %>%
mutate(value = 1000 * `Real GDP / Real GDP Trend (Log Linear)` * value / GDP,
variable = case_when(variable == "Fixed assets" ~ "Fixed assets (Private + Government)",
variable == "Private" ~ "Fixed assets (Private)")) %>%
ggplot + geom_line(aes(x = date, y = value, color = variable, linetype = variable)) +
ylab("% of GDP") + xlab("") +
theme_minimal()+
geom_rect(data = nber_recessions %>%
filter(Peak > as.Date("1927-01-01")),
aes(xmin = Peak, xmax = Trough, ymin = -Inf, ymax = +Inf),
fill = 'grey', alpha = 0.5) +
scale_x_date(breaks = nber_recessions$Peak,
minor_breaks = "5 years",
labels = date_format("%y")) +
scale_y_continuous(breaks = 0.01*seq(0, 500, 20),
labels = scales::percent_format(accuracy = 1)) +
scale_color_manual(values = viridis(5)[1:4]) +
theme(legend.position = c(0.2, 0.9),
legend.title = element_blank(),
legend.text = element_text(size = 8),
legend.key.size = unit(0.9, 'lines'))