Finding changepoints in time series

In finance and other fields, one looks for changes in the properties of time series. The daily standard deviation of stock market returns (the “volatility”) can be much higher or lower than usual, and the correlation of stock market and government bond returns can change sign. (If the market is worried about deflation, stock and bond returns will be negatively correlated, but they will be positively correlated if inflation is the primary concern.) A project to find changepoints in time series is

Some output from the program that finds changepoints in volatility is below. The stock market during the 2008 financial crisis is apparent, with stocks falling sharply over the period 2008-09-15 to 2008-12-01 with annualized volatility of 78% (about 15% is the median).

BIC-selected model (46 changepoint(s)) -- SPY
       start         end       n    ann_ret%    ann_vol%      min%      max%    first%     last%
  2007-12-20  2008-09-12     184      -15.80       20.39     -3.19      4.15      0.63      0.46
  2008-09-15  2008-12-01      55     -163.89       77.60     -9.84     14.52     -4.76     -8.86
  2008-12-02  2009-04-20      95       15.66       38.53     -5.28      7.18      3.85     -4.19

In one case I found it to be orders of magnitude faster than

which has 2K stars.

6 Likes

Nice work!

Tangentially related, I read this blog post today:

It would be interesting to learn if there is any changepoint in the last weeks. The front-page of HackerNews is flooded with agentic AI programming products:

1 Like