Thursday, April 26, 2012

Structural Breaks (Bull or Bear?)

When I spotted the bfast R package, I could not resist attempting to apply it to identify bull and bear markets.  For all the details that I do not understand, please see the references:

Jan Verbesselt, Rob Hyndman, Glenn Newnham, Darius Culvenor (2010). Detecting Trend and
  Seasonal Changes in Satellite Image Time Series. Remote Sensing of Environment, 114(1),
  106-115. doi:10.1016/j.rse.2009.08.014

Jan Verbesselt, Rob Hyndman, Achim Zeileis, Darius Culvenor (2010). Phenological Change
  Detection while Accounting for Abrupt and Gradual Trends in Satellite Image Time
  Series. Remote Sensing of Environment, 114(12), 2970 - 2980.

I believe the result on the S&P 500 (even with a high h and only one iteration) is a fairly close marker for bull and bear markets, and I thoroughly enjoyed applying forestry techniques to financial time series.

From TimelyPortfolio
From TimelyPortfolio
From TimelyPortfolio

R code from GIST:


  1. Nice application! you can also detect seasonal breaks. also check some new near real-time disturbance detection functionality using bfastmonitor()
    cheers, Jan

  2. Thanks for the interesting post. However I guess it would really make more sense to analyze the returns because one wouldn't expect trend stationarity for the (log) prices. Note also that bfast leverages tools from the strucchange package which has its roots in econometrics. There are write a few publications on analyzing structural change in return time series. Best regards, Achim

    1. Achim, you meant that the analysis can only be applied to stationary time series, so that we have to transform log prices into returns first? Thank you!

  3. GSPC.bfast <- bfast(GSPC.ts,h=0.2,max.iter=10,season="none")

    I changed to max.iter=10 and the result is the same as before(at least seen from the trend Breakpoints plot)?

  4. I really appreciate the comments, and it certainly seems your statistical knowledge exceeds mine. However, based on my understanding of trend stationarity, for my purposes, it is not necessary to transform the series and is actually harmful to detrend. It seems almost like removing the moving average from a moving average system. Please let me know how I have this wrong. Rather than removing the trend I want to highlight it and figure out how I can benefit from it.