prc_hicp_midx %>%
filter(coicop %in% c("TOT_X_NRG_FOOD", "CP00"),
geo %in% c("AT", "BE", "CY", "DE", "EE", "EL", "ES", "FI", "FR", "IE",
"IT", "LT", "LU", "LV", "MT", "NL", "PT", "SI", "SK", "HR"),
unit == "I15") %>%
mutate(year = substr(time, 1, 4)) %>%
left_join(geo, by = "geo") %>%
#filter(!(Geo %in% intersect(eurozone_countries, CEEC_countries))) %>%
left_join(prc_hicp_cow %>%
filter(statinfo == "COWEA20", geo != "EA20") %>%
transmute(geo, year = time, country_weights = values, uniform_weights = 1),
by = c("geo", "year")) %>%
month_to_date %>%
group_by(Geo, coicop) %>%
arrange(date) %>%
mutate(`2-year inflation` = (values/lag(values, 24))^(1/2)-1,
`1-year inflation` = values/lag(values, 12)-1) %>%
ungroup %>%
gather(variable, values, `2-year inflation`, `1-year inflation`) %>%
filter(!is.na(values)) %>%
group_by(coicop, date, variable) %>%
summarise(values = sqrt(Hmisc::wtd.var(values, country_weights))) %>%
mutate(Coicop = ifelse(coicop == "CP00", "Headline inflation", "Core inflation")) %>%
filter(date >= as.Date("2000-01-01")) %>%
ggplot(.) + geom_line(aes(x = date, y = values, color = Coicop, linetype = Coicop)) +
theme_minimal() + xlab("") + ylab("Standard Deviation of Annual Inflation\nWeighted, EA-20 (%)") +
scale_x_date(breaks = seq(1960, 2050, 2) %>% paste0("-01-01") %>% as.Date,
labels = date_format("%Y")) +
scale_color_manual(values = c("#1E1C1C", "#A81630")) +
scale_y_continuous(breaks = 0.01*seq(-20, 20, .5),
labels = percent_format(a = .1)) +
theme(legend.position = "top",
legend.title = element_blank(),
axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
facet_wrap(~ variable)