Inflation - inflation

Data - Fred

variable

variable Variable Nobs
T10YIE 10-Year Breakeven Inflation Rate 6187
T5YIE 5-Year Breakeven Inflation Rate 6187
T5YIFR 5-Year, 5-Year Forward Inflation Expectation Rate 6187
GASREGW US Regular All Formulations Gas Price 1883
CUUR0000SA0L2 Consumer Price Index for All Urban Consumers: All Items Less Shelter in U.S. City Average 1098
CPIAUCSL Consumer Price Index for All Urban Consumers: All Items in U.S. City Average 956
CPIUFDSL Consumer Price Index for All Urban Consumers: Food in U.S. City Average 956
UNRATE Unemployment Rate 944
CUUR0000SAH1 Consumer Price Index for All Urban Consumers: Shelter in U.S. City Average 885
CPIENGSL Consumer Price Index for All Urban Consumers: Energy in U.S. City Average 836
CPILFESL Consumer Price Index for All Urban Consumers: All Items Less Food and Energy in U.S. City Average 836
PCEPI Personal Consumption Expenditures: Chain-type Price Index 811
PCEPILFE Personal Consumption Expenditures Excluding Food and Energy (Chain-Type Price Index) 811
MICH University of Michigan: Inflation Expectation 583
CUSR0000SEHA Consumer Price Index for All Urban Consumers: Rent of Primary Residence in U.S. City Average 548
CUSR0000SEHC Consumer Price Index for All Urban Consumers: Owners' Equivalent Rent of Residences in U.S. City Average 524
CP0000USM086NEST Harmonized Index of Consumer Prices: Total for United States 325
CP00MI15EA20M086NEST Harmonized Index of Consumer Prices: Total for Euro Area (20 Countries) 321
TOTNRGFOODEA20MI15XM Harmonized Index of Consumer Prices: Overall Index Excluding Energy, Food, Alcohol, and Tobacco for Euro Area (20 Countries) 321
A255RD3Q086SBEA Imports of goods (implicit price deflator) 318
GDPDEF Gross Domestic Product: Implicit Price Deflator 318
T7YIEM 7-year Breakeven Inflation Rate 284
DPCCRV1Q225SBEA Personal Consumption Expenditures (PCE) Excluding Food and Energy (Chain-Type Price Index) 269
T20YIEM 20-year Breakeven Inflation Rate 266
T30YIEM 30-year Breakeven Inflation Rate 199
FPCPITOTLZGUSA Inflation, consumer prices for the United States 65

CPI, HICP

All

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "CP00MI15EA20M086NEST")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = value/lag(value, 12) - 1) |>
  mutate(country = ifelse(variable == "CP00MI15EA20M086NEST", "Euro area (HICP)", "US (CPI)")) |>
  na.omit() |>
  #filter(value >= 0.14) %>%
  ggplot() + geom_line(aes(x = date, y = value, color = country)) + theme_minimal() +
  scale_x_date(breaks = "5 years",
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  scale_color_manual(values = c("#003399", "#B22234")) +
  xlab("") + ylab("Inflation (%)") +
  theme(legend.position = c(0.2, 0.9),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  geom_hline(yintercept = 0.02, linetype = "dashed")

Since 2020

All

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "CP00MI15EA20M086NEST")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = value/lag(value, 12) - 1) |>
  filter(date >= as.Date("2009-01-01")) |>
  mutate(country = ifelse(variable == "CP00MI15EA20M086NEST", "Euro area (HICP)", "US (CPI)")) |>
  na.omit() |>
  ggplot() + geom_line(aes(x = date, y = value, color = country)) + theme_minimal() +
  scale_x_date(breaks = "1 year",
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  scale_color_manual(values = c("#003399", "#B22234")) +
  xlab("") + ylab("Inflation (%)") +
  theme(legend.position = c(0.2, 0.9),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  geom_hline(yintercept = 0.02, linetype = "dashed")

CPI, PCE, HICP

Since 2021

Inflation (1st difference, 1 year)

English

Code
invisible(Sys.setlocale("LC_TIME", "en_CA.UTF-8"))
inflation |>
  filter(variable %in% c("CPIAUCSL", "PCEPI", "CP0000USM086NEST", "CP00MI15EA20M086NEST")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = value/lag(value, 12) - 1) |>
  filter(date >= as.Date("2020-02-01")) |>
  mutate(country = ifelse(variable == "CP00MI15EA20M086NEST", "Euro area", "US"),
         type = case_when(variable %in% c("CP00MI15EA20M086NEST", "CP0000USM086NEST") ~ "HICP, Proxy-HICP",
                          variable == "CPIAUCSL" ~ "CPI",
                          variable == "PCEPI" ~ "PCE"),
         type = factor(type,
                       levels  = c("HICP, Proxy-HICP", "CPI", "PCE"),
                       labels = c("Harmonized Index of Consumer Prices (HICP)",
                                        "Consumer Price Index, BLS (CPI)",
                                        "Personal Consumption Expenditures, BEA (PCE)"))) |>
  na.omit() |>
  ggplot() + geom_line(aes(x = date, y = value, color = country, linetype = type)) + theme_minimal() +
  scale_x_date(breaks = seq.Date(from = as.Date("2020-01-01"), to = Sys.Date(), by = "2 months"),
               labels = date_format("%b %Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  scale_color_manual(values = c("#003399", "#B22234")) +
  xlab("") + ylab("Inflation (%)") +
  theme(legend.position = c(0.25, 0.78),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  geom_text_repel(data = . %>% filter(date %in% c(max(date), as.Date("2022-06-01"), as.Date("2022-10-01"))),
                  aes(x = date, y = value, label = percent(value, acc = 0.1)), 
                  fontface ="plain", color = "black", size = 3) +
  geom_vline(xintercept = as.Date("2022-06-01"), linetype = "dotted") + 
  geom_vline(xintercept = as.Date("2022-10-01"), linetype = "dotted")

Since 2020

Inflation (1st difference, 1 year)

English

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "PCEPI", "CP0000USM086NEST", "CP00MI15EA20M086NEST")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = value/lag(value, 12) - 1) |>
  filter(date >= as.Date("2020-01-01")) |>
  mutate(country = ifelse(variable == "CP00MI15EA20M086NEST", "Euro area", "US"),
         type = case_when(variable %in% c("CP00MI15EA20M086NEST", "CP0000USM086NEST") ~ "Harmonized Index of Consumer Prices (HICP, Proxy-HICP)",
                          variable == "CPIAUCSL" ~ "Consumer Price Index, BLS (CPI)",
                          variable == "PCEPI" ~ "Personal Consumption Expenditures, BEA (PCE)"),
         type = factor(type, levels = c("Harmonized Index of Consumer Prices (HICP, Proxy-HICP)",
                                        "Consumer Price Index, BLS (CPI)",
                                        "Personal Consumption Expenditures, BEA (PCE)"))) |>
  na.omit() |>
  ggplot() + geom_line(aes(x = date, y = value, color = country, linetype = type)) + theme_minimal() +
  scale_x_date(breaks = seq.Date(from = as.Date("2020-01-01"), to = Sys.Date(), by = "2 months"),
               labels = date_format("%b %Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  scale_color_manual(values = c("#003399", "#B22234")) +
  xlab("") + ylab("Inflation (%)") +
  theme(legend.position = c(0.3, 0.78),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  geom_text_repel(data = . %>% filter(date %in% c(max(date), as.Date("2022-06-01"), as.Date("2022-10-01"))),
                  aes(x = date, y = value, label = percent(value, acc = 0.1)), 
                  fontface ="plain", color = "black", size = 3) + 
  geom_vline(xintercept = as.Date("2022-06-01"), linetype = "dotted") + 
  geom_vline(xintercept = as.Date("2022-10-01"), linetype = "dotted")

French

Code
invisible(Sys.setlocale("LC_TIME", "fr_CA.UTF-8"))
inflation |>
  filter(variable %in% c("CPIAUCSL", "PCEPI", "CP0000USM086NEST", "CP00MI15EA20M086NEST")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = value/lag(value, 12) - 1) |>
  filter(date >= as.Date("2020-01-01")) |>
  mutate(country = ifelse(variable == "CP00MI15EA20M086NEST", "Zone euro", "États-Unis"),
         country = factor(country, levels = c("Zone euro", "États-Unis")),
         type = case_when(variable %in% c("CP00MI15EA20M086NEST", "CP0000USM086NEST") ~ "Indice des Prix à la Consommation Harmonisé (IPCH, Proxy-IPCH)",
                          variable == "CPIAUCSL" ~ "Indice des Prix à la Consommation (CPI)",
                          variable == "PCEPI" ~ "Déflateur de la Consommation (PCE)"),
         type = factor(type, levels = c("Indice des Prix à la Consommation Harmonisé (IPCH, Proxy-IPCH)",
                                        "Indice des Prix à la Consommation (CPI)",
                                        "Déflateur de la Consommation (PCE)"))) |>
  na.omit() |>
  ggplot() + geom_line(aes(x = date, y = value, linetype = type, color = country)) + theme_minimal() +
  scale_x_date(breaks = seq.Date(from = as.Date("2020-01-01"), to = Sys.Date(), by = "3 months"),
               labels = date_format("%b %Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  scale_color_manual(values = c("#003399", "#B22234")) +
  xlab("") + ylab("Inflation sur un an (%)") +
  theme(legend.position = c(0.3, 0.78),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  geom_text(data = . %>% filter(date %in% c(as.Date("2022-06-01"), as.Date("2022-10-01"))),
                  aes(x = date, y = value, label = percent(value, acc = 0.1)), 
                  fontface ="plain", color = "black", size = 3) + 
  geom_text_repel(data = . %>% filter(date %in% c(max(date))),
                  aes(x = date, y = value, label = percent(value, acc = 0.1)), 
                  fontface ="plain", color = "black", size = 3) + 
  geom_vline(xintercept = as.Date("2022-06-01"), linetype = "dotted") + 
  geom_vline(xintercept = as.Date("2022-10-01"), linetype = "dotted") +
  guides(linetype = guide_legend(order = 1),
         color = guide_legend(order = 2))

Inflation, 1st difference

1 month

Code
invisible(Sys.setlocale("LC_TIME", "en_CA.UTF-8"))
inflation |>
  filter(variable %in% c("CPIAUCSL", "PCEPI", "CP0000USM086NEST", "CP00MI15EA20M086NEST")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = value/lag(value, 1) - 1) |>
  filter(date >= as.Date("2020-01-01")) |>
  mutate(country = ifelse(variable == "CP00MI15EA20M086NEST", "Euro area", "U.S."),
         type = case_when(variable %in% c("CP00MI15EA20M086NEST", "CP0000USM086NEST") ~ "Harmonized Index of Consumer Prices (HICP, Proxy-HICP)",
                          variable == "CPIAUCSL" ~ "Consumer Price Index, BLS (CPI)",
                          variable == "PCEPI" ~ "Personal Consumption Expenditures, BEA (PCE)"),
         type = factor(type, levels = c("Harmonized Index of Consumer Prices (HICP, Proxy-HICP)",
                                        "Consumer Price Index, BLS (CPI)",
                                        "Personal Consumption Expenditures, BEA (PCE)"))) |>
  na.omit() |>
  ggplot() + geom_line(aes(x = date, y = value, color = country, linetype = type)) + theme_minimal() +
  scale_x_date(breaks = seq.Date(from = as.Date("2020-01-01"), to = Sys.Date(), by = "2 months"),
               labels = date_format("%b %Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  scale_color_manual(values = c("#003399", "#B22234")) +
  xlab("") + ylab("Inflation, 1 month (%)") +
  theme(legend.position = c(0.3, 0.78),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  geom_text(data = . %>% filter(date %in% c(max(date), as.Date("2022-06-01"), as.Date("2022-10-01"))),
                  aes(x = date, y = value, label = percent(value, acc = 0.1)), 
                  fontface ="plain", color = "black", size = 3) + 
  geom_vline(xintercept = as.Date("2022-06-01"), linetype = "dotted") + 
  geom_vline(xintercept = as.Date("2022-10-01"), linetype = "dotted")

2 months

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "PCEPI", "CP0000USM086NEST", "CP00MI15EA20M086NEST")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = value/lag(value, 2) - 1) |>
  filter(date >= as.Date("2020-01-01")) |>
  mutate(country = ifelse(variable == "CP00MI15EA20M086NEST", "Euro area", "U.S."),
         type = case_when(variable %in% c("CP00MI15EA20M086NEST", "CP0000USM086NEST") ~ "Harmonized Index of Consumer Prices (HICP, Proxy-HICP)",
                          variable == "CPIAUCSL" ~ "Consumer Price Index, BLS (CPI)",
                          variable == "PCEPI" ~ "Personal Consumption Expenditures, BEA (PCE)"),
         type = factor(type, levels = c("Harmonized Index of Consumer Prices (HICP, Proxy-HICP)",
                                        "Consumer Price Index, BLS (CPI)",
                                        "Personal Consumption Expenditures, BEA (PCE)"))) |>
  na.omit() |>
  ggplot() + geom_line(aes(x = date, y = value, color = country, linetype = type)) + theme_minimal() +
  scale_x_date(breaks = seq.Date(from = as.Date("2020-01-01"), to = Sys.Date(), by = "2 months"),
               labels = date_format("%b %Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  scale_color_manual(values = c("#003399", "#B22234")) +
  xlab("") + ylab("Inflation, 2 months (%)") +
  theme(legend.position = c(0.3, 0.78),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  geom_text(data = . %>% filter(date %in% c(max(date), as.Date("2022-06-01"), as.Date("2022-10-01"))),
                  aes(x = date, y = value, label = percent(value, acc = 0.1)), 
                  fontface ="plain", color = "black", size = 3) + 
  geom_vline(xintercept = as.Date("2022-06-01"), linetype = "dotted") + 
  geom_vline(xintercept = as.Date("2022-10-01"), linetype = "dotted")

3 months

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "PCEPI", "CP0000USM086NEST", "CP00MI15EA20M086NEST")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = value/lag(value, 3) - 1) |>
  filter(date >= as.Date("2020-01-01")) |>
  mutate(country = ifelse(variable == "CP00MI15EA20M086NEST", "Euro area", "U.S."),
         type = case_when(variable %in% c("CP00MI15EA20M086NEST", "CP0000USM086NEST") ~ "Harmonized Index of Consumer Prices (HICP, Proxy-HICP)",
                          variable == "CPIAUCSL" ~ "Consumer Price Index, BLS (CPI)",
                          variable == "PCEPI" ~ "Personal Consumption Expenditures, BEA (PCE)"),
         type = factor(type, levels = c("Harmonized Index of Consumer Prices (HICP, Proxy-HICP)",
                                        "Consumer Price Index, BLS (CPI)",
                                        "Personal Consumption Expenditures, BEA (PCE)"))) |>
  na.omit() |>
  ggplot() + geom_line(aes(x = date, y = value, color = country, linetype = type)) + theme_minimal() +
  scale_x_date(breaks = seq.Date(from = as.Date("2020-01-01"), to = Sys.Date(), by = "2 months"),
               labels = date_format("%b %Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  scale_color_manual(values = c("#003399", "#B22234")) +
  xlab("") + ylab("Inflation, 3 months (%)") +
  theme(legend.position = c(0.3, 0.78),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  geom_text(data = . %>% filter(date %in% c(max(date), as.Date("2022-06-01"), as.Date("2022-10-01"))),
                  aes(x = date, y = value, label = percent(value, acc = 0.1)), 
                  fontface ="plain", color = "black", size = 3) + 
  geom_vline(xintercept = as.Date("2022-06-01"), linetype = "dotted") + 
  geom_vline(xintercept = as.Date("2022-10-01"), linetype = "dotted")

6 months

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "PCEPI", "CP0000USM086NEST", "CP00MI15EA20M086NEST")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = value/lag(value, 6) - 1) |>
  filter(date >= as.Date("2020-01-01")) |>
  mutate(country = ifelse(variable == "CP00MI15EA20M086NEST", "Euro area", "U.S."),
         type = case_when(variable %in% c("CP00MI15EA20M086NEST", "CP0000USM086NEST") ~ "Harmonized Index of Consumer Prices (HICP, Proxy-HICP)",
                          variable == "CPIAUCSL" ~ "Consumer Price Index, BLS (CPI)",
                          variable == "PCEPI" ~ "Personal Consumption Expenditures, BEA (PCE)"),
         type = factor(type, levels = c("Harmonized Index of Consumer Prices (HICP, Proxy-HICP)",
                                        "Consumer Price Index, BLS (CPI)",
                                        "Personal Consumption Expenditures, BEA (PCE)"))) |>
  na.omit() |>
  ggplot() + geom_line(aes(x = date, y = value, color = country, linetype = type)) + theme_minimal() +
  scale_x_date(breaks = seq.Date(from = as.Date("2020-01-01"), to = Sys.Date(), by = "2 months"),
               labels = date_format("%b %Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  scale_color_manual(values = c("#003399", "#B22234")) +
  xlab("") + ylab("Inflation, 6 months (%)") +
  theme(legend.position = c(0.3, 0.78),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  geom_text(data = . %>% filter(date %in% c(max(date), as.Date("2022-06-01"), as.Date("2022-10-01"))),
                  aes(x = date, y = value, label = percent(value, acc = 0.1)), 
                  fontface ="plain", color = "black", size = 3) + 
  geom_vline(xintercept = as.Date("2022-06-01"), linetype = "dotted") + 
  geom_vline(xintercept = as.Date("2022-10-01"), linetype = "dotted")

Price Index

English

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "PCEPI", "CP0000USM086NEST", "CP00MI15EA20M086NEST")) |>
  add_row(date = as.Date("2023-10-01"), variable = "CP00MI15EA20M086NEST", value = 124.55) |>
  select(date, variable, value) |>
  filter(date >= as.Date("2020-01-01")) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = 100*value/value[1]) |>
  mutate(country = ifelse(variable == "CP00MI15EA20M086NEST", "Euro area", "US"),
         type = case_when(variable %in% c("CP00MI15EA20M086NEST", "CP0000USM086NEST") ~ "Harmonized Index of Consumer Prices (HICP, Proxy-HICP)",
                          variable == "CPIAUCSL" ~ "Consumer Price Index, BLS (CPI)",
                          variable == "PCEPI" ~ "Personal Consumption Expenditures, BEA (PCE)"),
         type = factor(type, levels = c("Harmonized Index of Consumer Prices (HICP, Proxy-HICP)",
                                        "Consumer Price Index, BLS (CPI)",
                                        "Personal Consumption Expenditures, BEA (PCE)"))) |>
  na.omit() |>
  ggplot() + geom_line(aes(x = date, y = value, color = country, linetype = type)) + theme_minimal() +
  scale_x_date(breaks = seq.Date(from = as.Date("2020-01-01"), to = Sys.Date(), by = "2 months"),
               labels = date_format("%b %Y")) + 
  scale_y_continuous(breaks = seq(100, 200, 5)) + 
  scale_color_manual(values = c("#003399", "#B22234")) +
  xlab("") + ylab("Price Index (January 2020 = 100)") +
  theme(legend.position = c(0.3, 0.78),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1))

French

Code
invisible(Sys.setlocale("LC_TIME", "fr_CA.UTF-8"))
inflation |>
  filter(variable %in% c("CPIAUCSL", "PCEPI", "CP0000USM086NEST", "CP00MI15EA20M086NEST")) |>
  add_row(date = as.Date("2023-10-01"), variable = "CP00MI15EA20M086NEST", value = 124.55) |>
  select(date, variable, value) |>
  filter(date >= as.Date("2020-01-01")) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = 100*value/value[1]) |>
  mutate(country = ifelse(variable == "CP00MI15EA20M086NEST", "Zone euro", "États-Unis"),
         country = factor(country, levels = c("Zone euro", "États-Unis")),
         type = case_when(variable %in% c("CP00MI15EA20M086NEST", "CP0000USM086NEST") ~ "Indice des Prix à la Consommation Harmonisé (IPCH, Proxy-IPCH)",
                          variable == "CPIAUCSL" ~ "Indice des Prix à la Consommation (CPI)",
                          variable == "PCEPI" ~ "Déflateur de la Consommation (PCE)"),
         type = factor(type, levels = c("Indice des Prix à la Consommation Harmonisé (IPCH, Proxy-IPCH)",
                                        "Indice des Prix à la Consommation (CPI)",
                                        "Déflateur de la Consommation (PCE)"))) |>
  na.omit() |>
  ggplot() + geom_line(aes(x = date, y = value, color = country, linetype = type)) + theme_minimal() +
  scale_x_date(breaks = seq.Date(from = as.Date("2020-01-01"), to = Sys.Date(), by = "3 months"),
               labels = date_format("%b %Y")) + 
  scale_y_continuous(breaks = seq(100, 200, 5)) + 
  scale_color_manual(values = c("#003399", "#B22234")) +
  xlab("") + ylab("Indice des prix (Janvier 2020 = 100)") +
  theme(legend.position = c(0.3, 0.78),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  guides(linetype = guide_legend(order = 1),
         color = guide_legend(order = 2))

Code
invisible(Sys.setlocale("LC_TIME", "en_CA.UTF-8"))

Core CPI, PCE, HICP

Since 2020

Inflation (1st difference)

1 year

Code
inflation |>
  filter(variable %in% c("PCEPILFE", "CPILFESL", "TOTNRGFOODEA20MI15XM")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = value/lag(value, 12) - 1) |>
  filter(date >= as.Date("2020-01-01")) |>
  mutate(country = ifelse(variable == "TOTNRGFOODEA20MI15XM", "Euro area", "U.S."),
         type = case_when(variable %in% c("TOTNRGFOODEA20MI15XM") ~ "Harmonized Index of Consumer Prices (HICP)",
                          variable == "CPILFESL" ~ "Consumer Price Index, BLS (CPI)",
                          variable == "PCEPILFE" ~ "Personal Consumption Expenditures, BEA (PCE)"),
         type = factor(type, levels = c("Harmonized Index of Consumer Prices (HICP)",
                                        "Consumer Price Index, BLS (CPI)",
                                        "Personal Consumption Expenditures, BEA (PCE)"))) |>
  na.omit() |>
  ggplot() + geom_line(aes(x = date, y = value, color = country, linetype = type)) + theme_minimal() +
  scale_x_date(breaks = seq.Date(from = as.Date("2020-01-01"), to = Sys.Date(), by = "2 months"),
               labels = scales::date_format("%b %Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  scale_color_manual(values = c("#003399", "#B22234")) +
  xlab("") + ylab("Core Inflation (%)") +
  theme(legend.position = c(0.25, 0.78),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  geom_text(data = . %>% filter(date %in% c(max(date), as.Date("2022-06-01"), as.Date("2022-10-01"))),
                  aes(x = date, y = value, label = scales::percent(value, acc = 0.1)), 
                  fontface ="plain", color = "black", size = 3) + 
  geom_vline(xintercept = as.Date("2022-06-01"), linetype = "dotted") + 
  geom_vline(xintercept = as.Date("2022-10-01"), linetype = "dotted")

6 months

Code
inflation |>
  filter(variable %in% c("PCEPILFE", "CPILFESL", "TOTNRGFOODEA20MI15XM")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = (value/lag(value, 6))^2 - 1) |>
  filter(date >= as.Date("2020-01-01")) |>
  mutate(country = ifelse(variable == "TOTNRGFOODEA20MI15XM", "Euro area", "U.S."),
         type = case_when(variable %in% c("TOTNRGFOODEA20MI15XM") ~ "Harmonized Index of Consumer Prices (HICP)",
                          variable == "CPILFESL" ~ "Consumer Price Index, BLS (CPI)",
                          variable == "PCEPILFE" ~ "Personal Consumption Expenditures, BEA (PCE)"),
         type = factor(type, levels = c("Harmonized Index of Consumer Prices (HICP)",
                                        "Consumer Price Index, BLS (CPI)",
                                        "Personal Consumption Expenditures, BEA (PCE)"))) |>
  na.omit() |>
  ggplot() + geom_line(aes(x = date, y = value, color = country, linetype = type)) + theme_minimal() +
  scale_x_date(breaks = seq.Date(from = as.Date("2020-01-01"), to = Sys.Date(), by = "2 months"),
               labels = scales::date_format("%b %Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  scale_color_manual(values = c("#003399", "#B22234")) +
  xlab("") + ylab("Core Inflation, 6 months annualized (%)") +
  theme(legend.position = c(0.25, 0.78),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  geom_text(data = . %>% filter(date %in% c(max(date), as.Date("2022-06-01"), as.Date("2022-10-01"))),
                  aes(x = date, y = value, label = scales::percent(value, acc = 0.1)), 
                  fontface ="plain", color = "black", size = 3)

3 months

Code
inflation |>
  filter(variable %in% c("PCEPILFE", "CPILFESL", "TOTNRGFOODEA20MI15XM")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = (value/lag(value, 3))^4 - 1) |>
  filter(date >= as.Date("2020-01-01")) |>
  mutate(country = ifelse(variable == "TOTNRGFOODEA20MI15XM", "Euro area", "U.S."),
         type = case_when(variable %in% c("TOTNRGFOODEA20MI15XM") ~ "Harmonized Index of Consumer Prices (HICP)",
                          variable == "CPILFESL" ~ "Consumer Price Index, BLS (CPI)",
                          variable == "PCEPILFE" ~ "Personal Consumption Expenditures, BEA (PCE)"),
         type = factor(type, levels = c("Harmonized Index of Consumer Prices (HICP)",
                                        "Consumer Price Index, BLS (CPI)",
                                        "Personal Consumption Expenditures, BEA (PCE)"))) |>
  na.omit() |>
  ggplot() + geom_line(aes(x = date, y = value, color = country, linetype = type)) + theme_minimal() +
  scale_x_date(breaks = seq.Date(from = as.Date("2020-01-01"), to = Sys.Date(), by = "2 months"),
               labels = scales::date_format("%b %Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  scale_color_manual(values = c("#003399", "#B22234")) +
  xlab("") + ylab("Core Inflation, 3 months annualized (%)") +
  theme(legend.position = c(0.25, 0.78),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  geom_text(data = . %>% filter(date %in% c(max(date), as.Date("2022-06-01"), as.Date("2022-10-01"))),
                  aes(x = date, y = value, label = scales::percent(value, acc = 0.1)), 
                  fontface ="plain", color = "black", size = 3)

Price Index

Code
inflation |>
  filter(variable %in% c("PCEPILFE", "CPILFESL", "TOTNRGFOODEA20MI15XM")) |>
  select(date, variable, value) |>
  filter(date >= as.Date("2020-01-01")) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = 100*value/value[1]) |>
  mutate(country = ifelse(variable == "TOTNRGFOODEA20MI15XM", "Euro area", "U.S."),
         type = case_when(variable %in% c("TOTNRGFOODEA20MI15XM") ~ "Harmonized Index of Consumer Prices (HICP)",
                          variable == "CPILFESL" ~ "Consumer Price Index, BLS (CPI)",
                          variable == "PCEPILFE" ~ "Personal Consumption Expenditures, BEA (PCE)"),
         type = factor(type, levels = c("Harmonized Index of Consumer Prices (HICP)",
                                        "Consumer Price Index, BLS (CPI)",
                                        "Personal Consumption Expenditures, BEA (PCE)"))) |>
  na.omit() |>
  ggplot() + geom_line(aes(x = date, y = value, color = country, linetype = type)) + theme_minimal() +
  scale_x_date(breaks = seq.Date(from = as.Date("2020-01-01"), to = Sys.Date(), by = "2 months"),
               labels = scales::date_format("%b %Y")) + 
  scale_y_continuous(breaks = seq(100, 200, 5)) + 
  scale_color_manual(values = c("#003399", "#B22234")) +
  xlab("") + ylab("Price Index (January 2020 = 100)") +
  theme(legend.position = c(0.3, 0.78),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1))

Since 2021

Inflation (1st difference)

3 months

Code
inflation |>
  filter(variable %in% c("CPILFESL", "TOTNRGFOODEA20MI15XM")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = (value/lag(value, 3))^4 - 1) |>
  filter(date >= as.Date("2022-01-01")) |>
  mutate(country = ifelse(variable == "TOTNRGFOODEA20MI15XM", "Euro area", "U.S."),
         type = case_when(variable %in% c("TOTNRGFOODEA20MI15XM") ~ "Harmonized Index of Consumer Prices (HICP)",
                          variable == "CPILFESL" ~ "Consumer Price Index, BLS (CPI)",
                          variable == "PCEPILFE" ~ "Personal Consumption Expenditures, BEA (PCE)"),
         type = factor(type, levels = c("Harmonized Index of Consumer Prices (HICP)",
                                        "Consumer Price Index, BLS (CPI)",
                                        "Personal Consumption Expenditures, BEA (PCE)"))) |>
  na.omit() |>
  ggplot() + geom_line(aes(x = date, y = value, color = country)) + theme_minimal() +
  scale_x_date(breaks = seq.Date(from = as.Date("2020-01-01"), to = Sys.Date(), by = "2 months"),
               labels = scales::date_format("%b %Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  scale_color_manual(values = c("#003399", "#B22234")) +
  xlab("") + ylab("Core Inflation, 3 months annualized (%)") +
  theme(legend.position = c(0.25, 0.78),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  geom_text(aes(x = date, y = value, label = scales::percent(value, acc = 0.1)), 
                  fontface ="plain", color = "black", size = 3)

CPi, PCE, PCE without energy and food

2010-

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "PCEPI", "PCEPILFE", "CPILFESL"),
         date >= as.Date("2010-01-01")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = ifelse(variable == "UNRATE", value/100, value/lag(value, 12) - 1)) |>
  left_join(variable, by = "variable") |>
  filter(date >= as.Date("2011-01-01")) |>
  na.omit() |>
  mutate(Variable = gsub("Consumer Price Index for All Urban Consumers", "CPI", Variable)) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 1) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Inflation (%)") +
  theme(legend.position = c(0.4, 0.85),
        legend.title = element_blank())

2019-

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "PCEPI", "PCEPILFE", "CPILFESL"),
         date >= as.Date("2010-01-01")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = ifelse(variable == "UNRATE", value/100, value/lag(value, 12) - 1)) |>
  left_join(variable, by = "variable") |>
  filter(date >= as.Date("2019-01-01")) |>
  na.omit() |>
  mutate(Variable = gsub("Consumer Price Index for All Urban Consumers", "CPI", Variable)) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 1) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Inflation (%)") +
  theme(legend.position = c(0.4, 0.85),
        legend.title = element_blank())

Since 2020

All

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "PCEPI", "PCEPILFE", "CPILFESL")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = value/lag(value, 12) - 1) |>
  filter(date >= as.Date("2020-01-01")) |>
  left_join(variable, by = "variable") |>
  na.omit() |>
  mutate(Variable = gsub("Consumer Price Index for All Urban Consumers", "CPI", Variable)) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = "3 months",
               labels = date_format("%b %Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Inflation (%)") +
  theme(legend.position = c(0.4, 0.8),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1))

New

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "PCEPI", "PCEPILFE", "CPILFESL")) |>
  mutate(category = case_when(variable %in% c("PCEPI", "CPIAUCSL") ~ "All items (Headline)",
                              T ~ "All items less Food and Energy (Core)"),
         PCE_or_CPI = case_when(variable %in% c("CPIAUCSL", "CPILFESL") ~ "Consumer Price Index (CPI)",
                              T ~ "Personal Consumption Expenditures (PCE)")) |>
  select(date, variable, value, category, PCE_or_CPI) |>
  group_by(category, PCE_or_CPI) |>
  arrange(date) |>
  mutate(value = value/lag(value, 12) - 1) |>
  filter(date >= as.Date("2020-01-01")) |>
  na.omit() |>
  ggplot() + geom_line(aes(x = date, y = value, color = PCE_or_CPI, linetype = category)) + theme_minimal() +
  scale_x_date(breaks = "3 months",
               labels = date_format("%b %Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("US Inflation (%)") +
  theme(legend.position = c(0.25, 0.8),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1))

With tickers

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "PCEPI", "PCEPILFE", "CPILFESL")) |>
  mutate(category = case_when(variable %in% c("PCEPI", "CPIAUCSL") ~ "All items (Headline)",
                              T ~ "All items less Food and Energy (Core)"),
         PCE_or_CPI = case_when(variable %in% c("CPIAUCSL", "CPILFESL") ~ "Consumer Price Index (CPI)",
                              T ~ "Personal Consumption Expenditures (PCE)")) |>
  select(date, variable, value, category, PCE_or_CPI) |>
  group_by(category, PCE_or_CPI) |>
  arrange(date) |>
  mutate(value = value/lag(value, 12) - 1) |>
  filter(date >= as.Date("2020-01-01")) |>
  na.omit() |>
  ggplot() + geom_line(aes(x = date, y = value, color = PCE_or_CPI, linetype = category)) + theme_minimal() +
  scale_x_date(breaks = seq.Date(from = as.Date("2018-06-01"), to = Sys.Date(), by = "3 months"),
               labels = date_format("%b %Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("US Inflation (%)") +
  theme(legend.position = c(0.25, 0.8),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  geom_text_repel(data = . %>% filter(date %in% c(max(date), as.Date("2022-06-01"))),
                  aes(x = date, y = value, label = percent(value, acc = 0.1)), 
                  fontface ="plain", color = "black", size = 3) + 
  geom_vline(xintercept = as.Date("2022-06-01"), linetype = "dotted")

2 years

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "PCEPI", "PCEPILFE", "CPILFESL")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = value/lag(value, 12) - 1) |>
  filter(date >= Sys.Date() - years(2)) |>
  left_join(variable, by = "variable") |>
  na.omit() |>
  mutate(Variable = gsub("Consumer Price Index for All Urban Consumers", "CPI", Variable)) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = "1 month",
               labels = date_format("%b %Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Inflation (%)") +
  theme(legend.position = c(0.4, 0.15),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  geom_text_repel(data = . %>% filter(date %in% c(max(date), as.Date("2022-06-01"),
                                                  as.Date("2022-01-01"), as.Date("2023-02-01"))),
                  aes(x = date, y = value, label = percent(value, acc = 0.1)), 
                  fontface ="plain", color = "black", size = 3) + 
  geom_vline(xintercept = as.Date("2022-06-01"), linetype = "dotted") + 
  geom_vline(xintercept = as.Date("2022-01-01"), linetype = "dotted") + 
  geom_vline(xintercept = as.Date("2023-02-01"), linetype = "dotted")

Contributions to inflation

Decomposition of headline inflation into Food, Energy, Rents and the residual Total less Energy, Food and Rents, with the dashed line showing core inflation (all items less food and energy). Same construction and aesthetic as the OECD data/oecd/PRICES_CPI.qmd chart, but sourced so both panels stay current.

  • US — CPI (CPIAUCSL, YoY). Component contribution = w * (I_t / I_{t-12} - 1) where w is the BLS CPI-U relative importance for that year (December vintage; 2024 vintage carried forward). Rents = rent of primary residence (CUSR0000SEHA) + owners’ equivalent rent (CUSR0000SEHC). The residual is taken as headline minus the three, so the stack sums to headline; the dashed line is the published core CPI (CPILFESL).
  • Euro area — HICP annual rate (prc_hicp_minr, TOTAL). Component contribution = w * rate, with w the HICP item weight from Eurostat prc_hicp_inw (per mille of the all-items index, updated each year; the last year is carried forward). Rents = actual rentals for housing (CP041); the euro-area HICP has no owners’-equivalent-rent component. The ready-made prc_hicp_ctrb contributions series is not used because it lags the headline release by several months.
Code
# BLS CPI-U relative importance (percent of all items, December vintage),
# https://www.bls.gov/cpi/tables/relative-importance/ - food, energy,
# rent of primary residence, owners' equivalent rent of residences.
cpi_weights <- tribble(
  ~wyear, ~w_food, ~w_energy, ~w_rpr,  ~w_oer,
   2020,  14.119,  6.155,     7.862,   24.263,
   2021,  13.370,  7.348,     7.398,   24.251,
   2022,  13.531,  6.921,     7.528,   25.424,
   2023,  13.555,  6.655,     7.671,   26.769,
   2024,  13.691,  6.216,     7.499,   26.282)

us_ctgy <- inflation |>
  filter(variable %in% c("CPIAUCSL", "CPILFESL", "CPIUFDSL", "CPIENGSL",
                         "CUSR0000SEHA", "CUSR0000SEHC")) |>
  select(date, variable, value) |>
  pivot_wider(names_from = variable, values_from = value) |>
  arrange(date) |>
  mutate(wyear = pmin(year(date), max(cpi_weights$wyear))) |>
  left_join(cpi_weights, by = "wyear") |>
  transmute(
    date,
    Inflation                 = 100 * (CPIAUCSL / lag(CPIAUCSL, 12) - 1),
    `Core inflation`          = 100 * (CPILFESL / lag(CPILFESL, 12) - 1),
    FOOD  = w_food   * (CPIUFDSL     / lag(CPIUFDSL, 12)     - 1),
    NRG   = w_energy * (CPIENGSL     / lag(CPIENGSL, 12)     - 1),
    RENTS = w_rpr    * (CUSR0000SEHA / lag(CUSR0000SEHA, 12) - 1) +
            w_oer    * (CUSR0000SEHC / lag(CUSR0000SEHC, 12) - 1)) |>
  mutate(TOT_X_NRG_FOOD_RENTS = Inflation - FOOD - NRG - RENTS) |>
  filter(date >= as.Date("2020-01-01"), !is.na(TOT_X_NRG_FOOD_RENTS))
Code
# Euro area, from Eurostat directly (prc_hicp_ctrb, the ready-made HICP
# contributions, lags the headline release by several months, so it is not used
# here). prc_hicp_minr carries the annual rates of change (unit RCH_A) to the
# latest release, and prc_hicp_iw the HICP item weights (per mille of the
# all-items index, updated annually). Contribution_i(t) = w_i(year) / 1000 *
# rate_i(t); the residual absorbs the small gap vs Eurostat's own chained
# formula. The euro-area HICP has no owners'-equivalent-rent component, so
# Rents = actual rentals for housing (CP041).
eu_rate <- open_dataset(here::here("data", "eurostat", "prc_hicp_minr.parquet")) |>
  filter(geo == "EA", unit == "RCH_A",
         coicop18 %in% c("TOTAL", "FOOD", "NRG", "CP041")) |>
  collect() |>
  transmute(date = as.Date(paste0(sub("M", "-", time), "-01")),
            coicop = coicop18, rate = values) |>
  pivot_wider(names_from = coicop, values_from = rate)

eu_weight <- read_parquet(here::here("data", "eurostat", "prc_hicp_iw.parquet")) |>
  filter(geo == "EA", statinfo == "IW", coicop18 %in% c("FOOD", "NRG", "CP041")) |>
  transmute(wyear = as.integer(time), coicop = coicop18, w = values / 1000) |>
  pivot_wider(names_from = coicop, values_from = w, names_prefix = "w_")

eu_ctgy <- eu_rate |>
  arrange(date) |>
  mutate(wyear = pmin(year(date), max(eu_weight$wyear))) |>
  left_join(eu_weight, by = "wyear") |>
  transmute(date,
            Inflation = TOTAL,
            FOOD  = w_FOOD  * FOOD,
            NRG   = w_NRG   * NRG,
            RENTS = w_CP041 * CP041) |>
  mutate(`Core inflation`     = Inflation - FOOD - NRG,
         TOT_X_NRG_FOOD_RENTS = Inflation - FOOD - NRG - RENTS) |>
  filter(date >= as.Date("2020-01-01"), !is.na(TOT_X_NRG_FOOD_RENTS))

English

US

Code
invisible(Sys.setlocale("LC_TIME", "en_CA.UTF-8"))
bars_US <- us_ctgy |>
  select(date, FOOD, NRG, RENTS, TOT_X_NRG_FOOD_RENTS) |>
  gather(coicop, values, -date) |>
  mutate(Coicop = factor(coicop, levels = c("FOOD", "NRG", "RENTS", "TOT_X_NRG_FOOD_RENTS"),
                         labels = c("Food", "Energy", "Rents",
                                    "Total less Energy, Food and Rents")),
         Geo = "US")

line_US <- us_ctgy |>
  select(date, Inflation, `Core inflation`) |>
  gather(Coicop, values, -date) |>
  mutate(Coicop = factor(Coicop, levels = c("Inflation", "Core inflation")),
         Geo = "US")

bars_US |>
  ggplot(aes(x = date, y = values/100)) +
  geom_col(aes(fill = Coicop), alpha = 1) +
  geom_line(data = line_US, aes(linetype = Coicop), size = 1.2) +
  theme_minimal() + xlab("") + ylab("Contributions to inflation") +
  scale_fill_manual(values = c("forestgreen","orange", "grey", "blue")) +
  scale_x_date(breaks ="3 months",
               labels = date_format("%b %Y")) +
  scale_y_continuous(breaks = 0.01*seq(-10, 30, 1),
                     labels = percent_format(accuracy = 1)) +
  theme(legend.position = "top",
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  guides(fill=guide_legend(nrow=2))

Euro area

Code
invisible(Sys.setlocale("LC_TIME", "en_CA.UTF-8"))
bars_EU <- eu_ctgy |>
  select(date, FOOD, NRG, RENTS, TOT_X_NRG_FOOD_RENTS) |>
  gather(coicop, values, -date) |>
  mutate(Coicop = factor(coicop, levels = c("FOOD", "NRG", "RENTS", "TOT_X_NRG_FOOD_RENTS"),
                         labels = c("Food", "Energy", "Rents",
                                    "Total less Energy, Food and Rents")),
         Geo = "Euro area")

line_EU <- eu_ctgy |>
  select(date, Inflation, `Core inflation`) |>
  gather(Coicop, values, -date) |>
  mutate(Coicop = factor(Coicop, levels = c("Inflation", "Core inflation")),
         Geo = "Euro area")

bars_EU |>
  ggplot(aes(x = date, y = values/100)) +
  geom_col(aes(fill = Coicop), alpha = 1) +
  geom_line(data = line_EU, aes(linetype = Coicop), size = 1.2) +
  theme_minimal() + xlab("") + ylab("Contributions to inflation") +
  scale_fill_manual(values = c("forestgreen","orange", "grey", "blue")) +
  scale_x_date(breaks ="3 months",
               labels = date_format("%b %Y")) +
  scale_y_continuous(breaks = 0.01*seq(-10, 30, 1),
                     labels = percent_format(accuracy = 1)) +
  theme(legend.position = "top",
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  guides(fill=guide_legend(nrow=2))

US, Euro area

Code
invisible(Sys.setlocale("LC_TIME", "en_CA.UTF-8"))
bars_EU |>
  bind_rows(bars_US) |>
  mutate(Geo = factor(Geo, levels = c("Euro area", "US"))) |>
  ggplot(aes(x = date, y = values/100)) +
  geom_col(aes(fill = Coicop), alpha = 1) +
  geom_line(data = line_EU |>
              bind_rows(line_US) |>
              mutate(Geo = factor(Geo, levels = c("Euro area", "US"))),
            aes(linetype = Coicop), size = 1.2) +
  theme_minimal() + xlab("") + ylab("Contributions to inflation") +
  scale_fill_manual(values = c("forestgreen","orange", "grey", "blue")) +
  scale_x_date(breaks ="6 months",
               labels = date_format("%b %Y"),
               expand = expansion(mult = 0.02)) +
  scale_y_continuous(breaks = 0.01*seq(-10, 30, 1),
                     labels = percent_format(accuracy = 1)) +
  theme(legend.position = "top",
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  guides(fill=guide_legend(nrow=2)) +
  facet_wrap(~ Geo)

French

US

Code
invisible(Sys.setlocale("LC_TIME", "fr_CA.UTF-8"))
bars_US <- us_ctgy |>
  select(date, FOOD, NRG, RENTS, TOT_X_NRG_FOOD_RENTS) |>
  gather(coicop, values, -date) |>
  mutate(Coicop = factor(coicop, levels = c("FOOD", "NRG", "RENTS", "TOT_X_NRG_FOOD_RENTS"),
                         labels = c("Alimentation", "Énergie", "Loyers",
                                    "Total sans énergie, alimentation, loyers")),
         Geo = "États-Unis")

line_US <- us_ctgy |>
  select(date, Inflation, `Inflation sous-jacente` = `Core inflation`) |>
  gather(Coicop, values, -date) |>
  mutate(Coicop = factor(Coicop, levels = c("Inflation", "Inflation sous-jacente")),
         Geo = "États-Unis")

bars_US |>
  ggplot(aes(x = date, y = values/100)) +
  geom_col(aes(fill = Coicop), alpha = 1) +
  geom_line(data = line_US, aes(linetype = Coicop), size = 1.2) +
  theme_minimal() + xlab("") + ylab("Contributions à l'inflation") +
  scale_fill_manual(values = c("forestgreen","orange", "grey", "blue")) +
  scale_x_date(breaks ="3 months",
               labels = date_format("%b %Y")) +
  scale_y_continuous(breaks = 0.01*seq(-10, 30, 1),
                     labels = percent_format(accuracy = 1)) +
  theme(legend.position = "top",
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  guides(fill=guide_legend(nrow=2))

Zone euro

Code
invisible(Sys.setlocale("LC_TIME", "fr_CA.UTF-8"))
bars_EU <- eu_ctgy |>
  select(date, FOOD, NRG, RENTS, TOT_X_NRG_FOOD_RENTS) |>
  gather(coicop, values, -date) |>
  mutate(Coicop = factor(coicop, levels = c("FOOD", "NRG", "RENTS", "TOT_X_NRG_FOOD_RENTS"),
                         labels = c("Alimentation", "Énergie", "Loyers",
                                    "Total sans énergie, alimentation, loyers")),
         Geo = "Zone euro")

line_EU <- eu_ctgy |>
  select(date, Inflation, `Inflation sous-jacente` = `Core inflation`) |>
  gather(Coicop, values, -date) |>
  mutate(Coicop = factor(Coicop, levels = c("Inflation", "Inflation sous-jacente")),
         Geo = "Zone euro")

bars_EU |>
  ggplot(aes(x = date, y = values/100)) +
  geom_col(aes(fill = Coicop), alpha = 1) +
  geom_line(data = line_EU, aes(linetype = Coicop), size = 1.2) +
  theme_minimal() + xlab("") + ylab("Contributions à l'inflation") +
  scale_fill_manual(values = c("forestgreen","orange", "grey", "blue")) +
  scale_x_date(breaks ="3 months",
               labels = date_format("%b %Y")) +
  scale_y_continuous(breaks = 0.01*seq(-10, 30, 1),
                     labels = percent_format(accuracy = 1)) +
  theme(legend.position = "top",
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  guides(fill=guide_legend(nrow=2))

US, Zone euro

Code
invisible(Sys.setlocale("LC_TIME", "fr_CA.UTF-8"))
bars_EU |>
  bind_rows(bars_US) |>
  mutate(Geo = factor(Geo, levels = c("Zone euro", "États-Unis"))) |>
  ggplot(aes(x = date, y = values/100)) +
  geom_col(aes(fill = Coicop), alpha = 1) +
  geom_line(data = line_EU |>
              bind_rows(line_US) |>
              mutate(Geo = factor(Geo, levels = c("Zone euro", "États-Unis"))),
            aes(linetype = Coicop), size = 1.2) +
  theme_minimal() + xlab("") + ylab("Contributions à l'inflation") +
  scale_fill_manual(values = c("forestgreen","orange", "grey", "blue")) +
  scale_x_date(breaks ="6 months",
               labels = date_format("%b %Y"),
               expand = expansion(mult = 0.02)) +
  scale_y_continuous(breaks = 0.01*seq(-10, 30, 1),
                     labels = percent_format(accuracy = 1)) +
  theme(legend.position = "top",
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  guides(fill=guide_legend(nrow=2)) +
  facet_wrap(~ Geo)

Rents,Without Rents, general, unemployment

2010-

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "CUUR0000SA0L2", "CUUR0000SAH1", "UNRATE"),
         date >= as.Date("2010-01-01")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = ifelse(variable == "UNRATE", value/100, value/lag(value, 12) - 1)) |>
  left_join(variable, by = "variable") |>
  filter(date >= as.Date("2011-01-01")) |>
  na.omit() |>
  mutate(Variable = gsub("Consumer Price Index for All Urban Consumers", "CPI", Variable)) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 1) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Inflation (%), Unemployment Rate (%)") +
  theme(legend.position = c(0.4, 0.85),
        legend.title = element_blank())

2 years

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "CUUR0000SA0L2", "CUUR0000SAH1", "UNRATE")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = ifelse(variable == "UNRATE", value/100, value/lag(value, 12) - 1)) |>
  filter(date >= Sys.Date() - years(2)) |>
  left_join(variable, by = "variable") |>
  na.omit() |>
  mutate(Variable = gsub("Consumer Price Index for All Urban Consumers", "CPI", Variable)) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = "2 months",
               labels = date_format("%b %Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Inflation (%), Unemployment Rate (%)") +
  theme(legend.position = c(0.3, 0.15),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1))

Rents,Without Rents VS general

2010-

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "CUUR0000SA0L2", "CUUR0000SAH1"),
         date >= as.Date("2010-01-01")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = value/lag(value, 12) - 1) |>
  left_join(variable, by = "variable") |>
  na.omit() |>
  mutate(Variable = gsub("Consumer Price Index for All Urban Consumers", "CPI", Variable)) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 1) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Inflation (%)") +
  theme(legend.position = c(0.5, 0.9),
        legend.title = element_blank())

2 years

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "CUUR0000SA0L2", "CUUR0000SAH1")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = value/lag(value, 12) - 1) |>
  filter(date >= Sys.Date() - years(3)) |>
  left_join(variable, by = "variable") |>
  na.omit() |>
  mutate(Variable = gsub("Consumer Price Index for All Urban Consumers", "CPI", Variable)) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = "2 months",
               labels = date_format("%b %Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Inflation (%)") +
  theme(legend.position = c(0.5, 0.2),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1))

Without Rents VS general

All

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "CUUR0000SA0L2"),
         date >= as.Date("1947-01-01")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = value/lag(value, 12) - 1) |>
  left_join(variable, by = "variable") |>
  na.omit() |>
  mutate(Variable = gsub("Consumer Price Index for All Urban Consumers", "CPI", Variable)) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Inflation (%)") +
  theme(legend.position = c(0.7, 0.9),
        legend.title = element_blank())

2000-

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "CUUR0000SA0L2"),
         date >= as.Date("2000-01-01")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = value/lag(value, 12) - 1) |>
  left_join(variable, by = "variable") |>
  na.omit() |>
  mutate(Variable = gsub("Consumer Price Index for All Urban Consumers", "CPI", Variable)) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 2) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Inflation (%)") +
  theme(legend.position = c(0.5, 0.9),
        legend.title = element_blank())

2010-

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "CUUR0000SA0L2"),
         date >= as.Date("2010-01-01")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = value/lag(value, 12) - 1) |>
  left_join(variable, by = "variable") |>
  na.omit() |>
  mutate(Variable = gsub("Consumer Price Index for All Urban Consumers", "CPI", Variable)) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 1) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Inflation (%)") +
  theme(legend.position = c(0.5, 0.9),
        legend.title = element_blank())

2017-

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "CUUR0000SA0L2"),
         date >= as.Date("2017-01-01")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = value/lag(value, 12) - 1) |>
  left_join(variable, by = "variable") |>
  na.omit() |>
  mutate(Variable = gsub("Consumer Price Index for All Urban Consumers", "CPI", Variable)) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 1) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Inflation (%)") +
  theme(legend.position = c(0.5, 0.9),
        legend.title = element_blank())

2 years

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "CUUR0000SA0L2")) |>
  select(date, variable, value) |>
  group_by(variable) |>
  arrange(date) |>
  mutate(value = value/lag(value, 12) - 1) |>
  filter(date >= Sys.Date() - years(3)) |>
  left_join(variable, by = "variable") |>
  na.omit() |>
  mutate(Variable = gsub("Consumer Price Index for All Urban Consumers", "CPI", Variable)) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = "2 months",
               labels = date_format("%b %Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Inflation (%)") +
  theme(legend.position = c(0.5, 0.2),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1))

Inflation U.S.

Consumer Inflation Expectations - MICH

All

Code
inflation |>
  filter(variable %in% c("MICH")) |>
  left_join(variable, by = "variable") |>
  ggplot() + geom_line(aes(x = date, y = value / 100)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Michigan Consumper Expectations (%)") +
  scale_color_manual(values = c("#2D68C4", "#F2A900", "#000000")) +
  theme(legend.position = c(0.5, 0.9),
        legend.title = element_blank())

1985-

Code
inflation |>
  filter(variable %in% c("MICH")) |>
  left_join(variable, by = "variable") |>
  filter(date >= as.Date("1985-01-01")) |>
  ggplot() + geom_line(aes(x = date, y = value / 100)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Michigan Consumper Expectations (%)") +
  scale_color_manual(values = c("#2D68C4", "#F2A900", "#000000")) +
  theme(legend.position = c(0.5, 0.9),
        legend.title = element_blank())

1995-

Code
inflation |>
  filter(variable %in% c("MICH")) |>
  left_join(variable, by = "variable") |>
  filter(date >= "1995-01-01") |>
  ggplot() + geom_line(aes(x = date, y = value / 100)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Michigan Consumper Expectations (%)") +
  scale_color_manual(values = c("#2D68C4", "#F2A900", "#000000")) +
  theme(legend.position = c(0.5, 0.9),
        legend.title = element_blank())

CPI, PCE, A255RD3Q086SBEA

1945-1970

Same Scale

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "A255RD3Q086SBEA"),
         month(date) == 1,
         date >= as.Date("1945-01-01"),
         date <= as.Date("1970-01-01")) |>
  select(date, variable, value) |>
  spread(variable, value) |>
  mutate(CPIAUCSL = 100*(log(CPIAUCSL) - lag(log(CPIAUCSL))),
         A255RD3Q086SBEA = 100*(log(A255RD3Q086SBEA) - lag(log(A255RD3Q086SBEA)))) |>
  gather(variable, value, -date) |>
  left_join(variable, by = "variable") |>
  ggplot() + geom_line(aes(x = date, y = value / 100, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 5),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Inflation Rates (%)") +
  scale_color_manual(values = c("#2D68C4", "#F2A900", "#000000")) +
  theme(legend.position = c(0.5, 0.9),
        legend.title = element_blank())

Different Scale

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "A255RD3Q086SBEA"),
         month(date) == 1,
         date >= as.Date("1945-01-01"),
         date <= as.Date("1970-01-01")) |>
  select(date, variable, value) |>
  spread(variable, value) |>
  mutate(CPIAUCSL = 100*(log(CPIAUCSL) - lag(log(CPIAUCSL))),
         A255RD3Q086SBEA = 20*(log(A255RD3Q086SBEA) - lag(log(A255RD3Q086SBEA)))) |>
  gather(variable, value, -date) |>
  left_join(variable, by = "variable") |>
  ggplot() + geom_line(aes(x = date, y = value / 100, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1),
                     limits = c(-0.035, 0.16)) + 
  xlab("") + ylab("Inflation Rates (%) - CPI, Imports of goods/5") +
  scale_color_manual(values = c("#2D68C4", "#F2A900")) +
  theme(legend.position = c(0.5, 0.9),
        legend.title = element_blank())

1945-

Code
inflation |>
  filter(variable %in% c("DPCCRV1Q225SBEA", "CPIAUCSL", "A255RD3Q086SBEA"),
         month(date) == 1,
         date >= as.Date("1945-01-01")) |>
  select(date, variable, value) |>
  spread(variable, value) |>
  mutate(CPIAUCSL = 100*(log(CPIAUCSL) - lag(log(CPIAUCSL))),
         A255RD3Q086SBEA = 100*(log(A255RD3Q086SBEA) - lag(log(A255RD3Q086SBEA)))) |>
  gather(variable, value, -date) |>
  left_join(variable, by = "variable") |>
  ggplot() + geom_line(aes(x = date, y = value / 100, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 5),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Inflation Rates (%)") +
  scale_color_manual(values = c("#2D68C4", "#F2A900", "#000000")) +
  theme(legend.position = c(0.5, 0.9),
        legend.title = element_blank())

1960-

Same Scale

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "A255RD3Q086SBEA"),
         month(date) == 1,
         date >= as.Date("1960-01-01")) |>
  select(date, variable, value) |>
  spread(variable, value) |>
  mutate(CPIAUCSL = 100*(log(CPIAUCSL) - lag(log(CPIAUCSL))),
         A255RD3Q086SBEA = 100*(log(A255RD3Q086SBEA) - lag(log(A255RD3Q086SBEA)))) |>
  gather(variable, value, -date) |>
  left_join(variable, by = "variable") |>
  ggplot() + geom_line(aes(x = date, y = value / 100, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 5),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Inflation Rates (%)") +
  scale_color_manual(values = c("#2D68C4", "#F2A900")) +
  theme(legend.position = c(0.5, 0.9),
        legend.title = element_blank())

Different Scale

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "A255RD3Q086SBEA"),
         month(date) == 1,
         date >= as.Date("1960-01-01")) |>
  select(date, variable, value) |>
  spread(variable, value) |>
  mutate(CPIAUCSL = 100*(log(CPIAUCSL) - lag(log(CPIAUCSL))),
         A255RD3Q086SBEA = 20*(log(A255RD3Q086SBEA) - lag(log(A255RD3Q086SBEA)))) |>
  gather(variable, value, -date) |>
  left_join(variable, by = "variable") |>
  ggplot() + geom_line(aes(x = date, y = value / 100, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1),
                     limits = c(-0.035, 0.16)) + 
  xlab("") + ylab("Inflation Rates (%) - CPI, Imports of goods/5") +
  scale_color_manual(values = c("#2D68C4", "#F2A900")) +
  theme(legend.position = c(0.5, 0.9),
        legend.title = element_blank())

1995-

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "A255RD3Q086SBEA"),
         month(date) == 1,
         date >= as.Date("1995-01-01")) |>
  select(date, variable, value) |>
  spread(variable, value) |>
  mutate(CPIAUCSL = 100*(log(CPIAUCSL) - lag(log(CPIAUCSL))),
         A255RD3Q086SBEA = 20*(log(A255RD3Q086SBEA) - lag(log(A255RD3Q086SBEA)))) |>
  gather(variable, value, -date) |>
  left_join(variable, by = "variable") |>
  ggplot() + geom_line(aes(x = date, y = value / 100, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1),
                     limits = c(-0.035, 0.06)) + 
  xlab("") + ylab("Inflation Rates (%) - CPI, Imports of goods/5") +
  scale_color_manual(values = c("#2D68C4", "#F2A900")) +
  theme(legend.position = c(0.5, 0.9),
        legend.title = element_blank())

1990-2005

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "A255RD3Q086SBEA"),
         month(date) == 1,
         date >= as.Date("1990-01-01"),
         date <= as.Date("2005-01-01")) |>
  select(date, variable, value) |>
  spread(variable, value) |>
  mutate(CPIAUCSL = 100*(log(CPIAUCSL) - lag(log(CPIAUCSL))),
         A255RD3Q086SBEA = 20*(log(A255RD3Q086SBEA) - lag(log(A255RD3Q086SBEA)))) |>
  gather(variable, value, -date) |>
  left_join(variable, by = "variable") |>
  ggplot() + geom_line(aes(x = date, y = value / 100, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 2) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1),
                     limits = c(-0.035, 0.06)) + 
  xlab("") + ylab("Inflation Rates (%) - CPI, Imports of goods/5") +
  scale_color_manual(values = c("#2D68C4", "#F2A900")) +
  theme(legend.position = c(0.5, 0.9),
        legend.title = element_blank())

1960-1980

Same scale

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "A255RD3Q086SBEA"),
         month(date) == 1,
         date >= as.Date("1960-01-01"),
         date <= as.Date("1980-01-01")) |>
  select(date, variable, value) |>
  spread(variable, value) |>
  mutate(CPIAUCSL = 100*(log(CPIAUCSL) - lag(log(CPIAUCSL))),
         A255RD3Q086SBEA = 100*(log(A255RD3Q086SBEA) - lag(log(A255RD3Q086SBEA)))) |>
  gather(variable, value, -date) |>
  left_join(variable, by = "variable") |>
  ggplot() + geom_line(aes(x = date, y = value / 100, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 2) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 2),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Inflation Rates (%) - CPI, Imports of goods") +
  scale_color_manual(values = c("#2D68C4", "#F2A900")) +
  theme(legend.position = c(0.5, 0.9),
        legend.title = element_blank())

Scale divided by 5

Code
inflation |>
  filter(variable %in% c("CPIAUCSL", "A255RD3Q086SBEA"),
         month(date) == 1,
         date >= as.Date("1960-01-01"),
         date <= as.Date("1980-01-01")) |>
  select(date, variable, value) |>
  spread(variable, value) |>
  mutate(CPIAUCSL = 100*(log(CPIAUCSL) - lag(log(CPIAUCSL))),
         A255RD3Q086SBEA = 20*(log(A255RD3Q086SBEA) - lag(log(A255RD3Q086SBEA)))) |>
  gather(variable, value, -date) |>
  left_join(variable, by = "variable") |>
  ggplot() + geom_line(aes(x = date, y = value / 100, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 2) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-60, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Inflation Rates (%) - CPI, Imports of goods/5") +
  scale_color_manual(values = c("#2D68C4", "#F2A900")) +
  theme(legend.position = c(0.5, 0.9),
        legend.title = element_blank())

Inflation

Code
inflation |>
  filter(variable %in% c("DPCCRV1Q225SBEA")) |>
  left_join(variable, by = "variable") |>
  ggplot() + geom_line(aes(x = date, y = value / 100, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-10, 15, 1),
                     labels = scales::percent_format(accuracy = 1)) + 
  xlab("") + ylab("Breakeven Inflation Rates (%)") +
  
  theme(legend.position = c(0.7, 0.2),
        legend.title = element_blank())

AFGAP Graph

All

  • Association Française des Gestionnaires Actif-Passif - AFGAP. pdf
Code
inflation |>
  filter(variable %in% c("DPCCRV1Q225SBEA", "CPIAUCSL"),
         month(date) == 1,
         date >= as.Date("1960-01-01")) |>
  select(date, variable, value) |>
  spread(variable, value) |>
  mutate(CPIAUCSL = 100*(log(CPIAUCSL) - lag(log(CPIAUCSL)))) |>
  gather(variable, value, -date) |>
  left_join(variable, by = "variable") |>
  ggplot() + geom_line(aes(x = date, y = value / 100, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-10, 18, 1),
                     labels = scales::percent_format(accuracy = 1),
                     limits = c(-0.01, 0.18)) + 
  xlab("") + ylab("Inflation Rates (%)") +
  scale_color_manual(values = c("#2D68C4", "#F2A900")) +
  theme(legend.position = c(0.5, 0.9),
        legend.title = element_blank())

US-Presidents

Code
inflation |>
  filter(variable %in% c("DPCCRV1Q225SBEA", "CPIAUCSL"),
         month(date) == 1,
         date >= as.Date("1960-01-01")) |>
  select(date, variable, value) |>
  spread(variable, value) |>
  mutate(CPIAUCSL = 100*(log(CPIAUCSL) - lag(log(CPIAUCSL)))) |>
  gather(variable, value, -date) |>
  left_join(variable, by = "variable") |>
  ggplot() + geom_line(aes(x = date, y = value / 100, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-10, 18, 1),
                     labels = scales::percent_format(accuracy = 1),
                     limits = c(-0.02, 0.16)) + 
  xlab("") + ylab("Inflation Rates (%)") +
  scale_color_manual(values = c("#2D68C4", "#F2A900")) +
  geom_vline(aes(xintercept = as.numeric(start)), 
             data = US_presidents |>
               filter(start >= as.Date("1960-01-01")) |>
               select(-party),
             colour = "grey50", alpha = 0.5) +
  geom_rect(aes(xmin = start, xmax = end, fill = party),
         ymin = -Inf, ymax = Inf, alpha = 0.1, 
         data = US_presidents |>
               filter(start >= as.Date("1960-01-01"))) +
  geom_text(aes(x = start, y = new, label = name), 
            data = US_presidents |> 
              filter(start >= as.Date("1960-01-01")) |>
              mutate(new = -0.01 + 0.005 * (1:n() %% 2)) |>
              select(-party),
            size = 2.5, vjust = 0, hjust = 0, nudge_x = 50) +
  scale_fill_manual(values = c("white", "grey")) +
  theme(legend.position = c(0.5, 1),
        legend.title = element_blank())

Regressions

All

Code
fit1 <- inflation |>
  filter(variable %in% c("CPIAUCSL", "A255RD3Q086SBEA"),
         month(date) == 1) |>
  select(date, variable, value) |>
  spread(variable, value) |>
  mutate(CPIAUCSL = 100*(log(CPIAUCSL) - lag(log(CPIAUCSL))),
         A255RD3Q086SBEA = 100*(log(A255RD3Q086SBEA) - lag(log(A255RD3Q086SBEA)))) %>%
  lm(CPIAUCSL ~ A255RD3Q086SBEA, data = .)

summary(fit1)
# 
# Call:
# lm(formula = CPIAUCSL ~ A255RD3Q086SBEA, data = .)
# 
# Residuals:
#     Min      1Q  Median      3Q     Max 
# -5.1366 -1.2571 -0.1283  0.9537  5.9348 
# 
# Coefficients:
#                 Estimate Std. Error t value Pr(>|t|)    
# (Intercept)      2.79569    0.23173  12.064  < 2e-16 ***
# A255RD3Q086SBEA  0.24661    0.02744   8.989 1.26e-13 ***
# ---
# Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# 
# Residual standard error: 1.957 on 77 degrees of freedom
#   (1 observation effacée parce que manquante)
# Multiple R-squared:  0.512,   Adjusted R-squared:  0.5057 
# F-statistic: 80.79 on 1 and 77 DF,  p-value: 1.262e-13

1945-1970

Code
fit2 <- inflation |>
  filter(variable %in% c("CPIAUCSL", "A255RD3Q086SBEA"),
         month(date) == 1,
         date >= as.Date("1945-01-01"),
         date <= as.Date("1970-01-01")) |>
  select(date, variable, value) |>
  spread(variable, value) |>
  mutate(CPIAUCSL = 100*(log(CPIAUCSL) - lag(log(CPIAUCSL))),
         A255RD3Q086SBEA = 100*(log(A255RD3Q086SBEA) - lag(log(A255RD3Q086SBEA)))) %>%
  lm(CPIAUCSL ~ A255RD3Q086SBEA, data = .)

summary(fit2)
# 
# Call:
# lm(formula = CPIAUCSL ~ A255RD3Q086SBEA, data = .)
# 
# Residuals:
#     Min      1Q  Median      3Q     Max 
# -4.2259 -0.8899  0.0160  1.0177  3.0392 
# 
# Coefficients:
#                 Estimate Std. Error t value Pr(>|t|)    
# (Intercept)      1.83629    0.37729   4.867 8.21e-05 ***
# A255RD3Q086SBEA  0.29736    0.05328   5.582 1.54e-05 ***
# ---
# Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# 
# Residual standard error: 1.726 on 21 degrees of freedom
#   (1 observation effacée parce que manquante)
# Multiple R-squared:  0.5973,  Adjusted R-squared:  0.5782 
# F-statistic: 31.15 on 1 and 21 DF,  p-value: 1.54e-05

1970-2020

Code
fit3 <- inflation |>
  filter(variable %in% c("CPIAUCSL", "A255RD3Q086SBEA"),
         month(date) == 1,
         date >= as.Date("1970-01-01")) |>
  select(date, variable, value) |>
  spread(variable, value) |>
  mutate(CPIAUCSL = 100*(log(CPIAUCSL) - lag(log(CPIAUCSL))),
         A255RD3Q086SBEA = 100*(log(A255RD3Q086SBEA) - lag(log(A255RD3Q086SBEA)))) %>%
  lm(CPIAUCSL ~ A255RD3Q086SBEA, data = .)

summary(fit3)
# 
# Call:
# lm(formula = CPIAUCSL ~ A255RD3Q086SBEA, data = .)
# 
# Residuals:
#     Min      1Q  Median      3Q     Max 
# -3.0472 -1.3457 -0.3164  0.7497  5.4838 
# 
# Coefficients:
#                 Estimate Std. Error t value Pr(>|t|)    
# (Intercept)      3.19278    0.27458  11.628 2.52e-16 ***
# A255RD3Q086SBEA  0.22993    0.03069   7.491 6.56e-10 ***
# ---
# Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# 
# Residual standard error: 1.948 on 54 degrees of freedom
#   (1 observation effacée parce que manquante)
# Multiple R-squared:  0.5096,  Adjusted R-squared:  0.5006 
# F-statistic: 56.12 on 1 and 54 DF,  p-value: 6.56e-10

Breakeven inflation rates

2017-2020

Code
inflation |>
  filter(variable %in% c("T7YIEM", "T5YIE", "T20YIEM", "T10YIE", "T30YIEM"),
         date >= as.Date("2009-01-01")) |>
  left_join(variable, by = "variable") |>
  mutate(Variable = gsub("7-year", " 7-year", Variable),
         Variable = gsub("5-Year", " 5-year", Variable)) |>
  ggplot() + geom_line(aes(x = date, y = value / 100, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = seq(1870, 2100, 2) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-10, 15, 0.5),
                     labels = scales::percent_format(accuracy = .1)) + 
  xlab("") + ylab("Breakeven Inflation Rates (%)") +
  
  theme(legend.position = c(0.7, 0.2),
        legend.title = element_blank())

2019-2020

Code
inflation |>
  filter(variable %in% c("T7YIEM", "T5YIE", "T20YIEM", "T10YIE", "T30YIEM"),
         date >= as.Date("2019-01-01")) |>
  left_join(variable, by = "variable") |>
  mutate(Variable = gsub("7-year", " 7-year", Variable),
         Variable = gsub("5-Year", " 5-year", Variable)) |>
  ggplot() + geom_line(aes(x = date, y = value / 100, color = Variable)) + theme_minimal() +
  scale_x_date(breaks = "6 months",
               labels = date_format("%b %Y")) + 
  scale_y_continuous(breaks = 0.01*seq(-10, 15, 0.5),
                     labels = scales::percent_format(accuracy = .1)) + 
  xlab("") + ylab("Breakeven Inflation Rates (%)") +
  
  theme(legend.position = c(0.7, 0.2),
        legend.title = element_blank())

Inflation Expectations

T5YIFR - 5-Year, 5-Year Forward Inflation Expectation Rate

This series is a measure of expected inflation (on average) over the five-year period that begins five years from today.

This series is constructed as: (((((1+((BC_10YEAR-TC_10YEAR)/100))10)/((1+((BC_5YEAR-TC_5YEAR)/100))5))^0.2)-1)*100

where BC10_YEAR, TC_10YEAR, BC_5YEAR, and TC_5YEAR are the 10 year and 5 year nominal and inflation adjusted Treasury securities.

Code
inflation |>
  filter(variable %in% c("T5YIFR")) |>
  left_join(variable, by = "variable") |>
  ggplot() + geom_line(aes(x = date, y = value / 100)) + theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 1) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_y_continuous(breaks = 0.01*seq(-10, 15, 0.5),
                     labels = scales::percent_format(accuracy = .1)) + 
  xlab("") + ylab("5-Year, 5-Year Forward Inflation Expectation Rate (%)") +
  
  theme(legend.position = c(0.7, 0.2),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1))