The R package bfast enthralls me. I have posted 3 times on bfast but still did not understand the impact of the h parameter. Armed now with some d3.js, angular.js, and rCharts I thought I could see it better with a fancy interactive visualization. Here is the result when applied to the S&P 500 monthly price series since 1950. You should see it embedded in an iframe below. For the full effect, click here.
Thursday, March 20, 2014
Is It Structurally Broke? bfast breakpoints
Thursday, January 16, 2014
Retail Relative Strength
So back before Thanksgiving I did a post Something to Think About Before Black Friday | rChart + dygraphs. Well since then I have noticed that Retail relative strength has deteriorated considerably. I thought it would be a good time to use good old bfast (see posts) to look for a structural breakpoint. Below is the output. And yes, I do plan to make interactive eventually with rCharts.
The remainder is what I think is very interesting.
Code:
Friday, April 27, 2012
Real Time Structural Break
Yesterday as I played with bfast I kept thinking “Yes, but this is all in hindsight. How can I potentially use this in a system?” Fortunately, one of the fine authors very generously commented on my post Structural Breaks (Bull or Bear?):
“Jan Verbesselt Apr 27, 2012 02:01 AM
Nice application! you can also detect seasonal breaks. also check some new near real-time disturbance detection functionality using bfastmonitor() http://bfast.r-forge.r-project.org/Verbesselt+Zeileis+Herold-2012.pdf
cheers, Jan”
And away I went on an unexpected but very pleasant journey into bfastmonitor. Please see the following paper for all the details.
Jan Verbesselt, Achim Zeileis, Martin Herold (2011). Near Real-Time Disturbance
Detection in Terrestrial Ecosystems Using Satellite Image Time Series: Drought
Detection in Somalia. Working Paper 2011-18. Working Papers in Economics and
Statistics, Research Platform Empirical and Experimental Economics, Universitaet
Innsbruck. URL http://EconPapers.RePEc.org/RePEc:inn:wpaper:2011-18
Doing a walk-forward test seemed like the best method of testing and illustration, so I chose the excruciating and incredibly volatile period from late 2008 to early 2009 as our example. Amazingly, it picked with no optimizing or manual intervention March 2009 as the breakpoint. Of course, we would not know this until the end of March, but picking real-time with only a month lag is unbelievable to me. Please try it out, and let me know your results. Of course, I already have the 30 year bond bull in mind as a next trial.
Thanks to Yihui Xie who resurfaced again (see posts on knitr) with his animation package, which I used to create a good old-fashioned animated GIF. I wish I had time to play more with the prettier and more robust options offered by the package.
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:
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 |


