Thursday, March 20, 2014

Is It Structurally Broke? bfast breakpoints

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.


  1. The parameter "h" is the minimal segment size, i.e., the minimum number of observations in each segment. It can either be specified relative to the sample size (e.g., 0.15) or in absolute numbers (h). As its manual page explains, some more points are available on the manual page of breakpoints() and accompanying documentation.

    "h" should only be big enough so that the basic model can be reliably estimated. And then it shouldn't matter how big exactly "h" is.

    In your example, "h" does play an inmportant role but that's because a season+trend model makes little sense for this data. If the market works well, then the prices should be close to a random walk (potentially with a drift). Thus, there is a stochastic trend but not a deterministic trend. If you wanted to carry out a structural change analysis, you should really look at the means of the corresponding returns. There you might find some more stable patterns. One might have to consider a stronger persistency in the data, though.

    In any case, the kind of data you are looking at is very different from the kind of data this particular model was designed for.

  2. honored to hear from you. Ok if I either promote your comments into the body of the post or do an entirely new post working through your valuable feedback? Thanks so much for all of your fine work.

  3. A new post would probably be more helpful. Maybe with an example of a time series where a deterministic season plus trend makes sense and another example of a return time series.

  4. thanks for this explanation. Would like to know about iteration concept...On the which basis we should define the number of iterations??