Last active
August 7, 2022 16:29
-
-
Save statwonk/55a29e2a8792b6f2d6833d376d4754da to your computer and use it in GitHub Desktop.
Examining US CPI persistence by using using the fractional-differencing technique of time series analysis. In this analysis, I roll the differencing procedure over a 120 month window to expose changes in the underlying process of inflation persistence.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
# CPI | |
# https://data.bls.gov/timeseries/CUSR0000SA0&output_view=pct_1mth | |
readxl::read_xlsx("~/Downloads/SeriesReport-20220807120638_733b06.xlsx", skip = 10) %>% | |
mutate(date = seq.POSIXt(as.POSIXct("1947-02-01"), by = "month", length.out = n())) %>% | |
select(date, cpi = Value) -> cpi | |
cpi %>% | |
filter(date >= as.POSIXct("1949-01-01")) %>% | |
mutate(frac_d = zoo::rollapplyr(cpi, width = 120, fill = NA, function(x) { | |
fracdiff::fracdiff(x, nar = 1)[["d"]] # rolling fractionally-differened ARIMA | |
})) %>% | |
ggplot(aes(date, frac_d)) + | |
geom_line() + geom_point() + | |
ggtitle("US CPI persistence over time (rolling order of integration)") + | |
labs(y = "Fractional d", x = "") + | |
scale_x_datetime(date_breaks = "5 year", date_labels = "%Y") + | |
theme_bw(25) + | |
theme(panel.grid.minor = element_blank()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment