# [R-SIG-Finance] Splitting time series into blocks/regimes?

Whit Armstrong armstrong.whit at gmail.com
Wed Feb 29 13:55:58 CET 2012

```It's not easy to do this.

http://dss.ucsd.edu/~jhamilto/palgrav1.pdf
http://www.econ.washington.edu/user/cnelson/markov/prgmlist.htm

Most people use gibbs sampling or other mcmc methods.

as it happens, I have some software you can use if you don't mind
https://github.com/armstrtw/CppBugs

or you can just use BUGS/JAGS.

also, some code is here:
http://faculty.chicagobooth.edu/hedibert.lopes/teaching/sa2011/sa2011.html

-Whit

On Wed, Feb 29, 2012 at 7:24 AM, R. Michael Weylandt
<michael.weylandt at gmail.com> wrote:
> I find this idea methodologically iffy, but perhaps you could do a
> little bit to make it a well posed question:
>
> i) Are you picking these periods as relatively equal divisions or time
> or as ex-post artifacts of "all that mess"
>
> ii) What is "the clustering algorithm"? Aren't there quite a few?
>
> iii) What does this mean: "the 3 big blocks/regimes need to be
> contiguous within each block/regime itself..."
>
> Perhaps you should look into reformulating your idea in terms of
> regime switching models.
>
> Michael Weylandt
>
> On Tue, Feb 28, 2012 at 12:55 PM, Michael <comtech.usa at gmail.com> wrote:
>> Hi all,
>>
>> I have a time series of historical SP500 returns.
>> How do I split it into a few non-overlapping blocks(regimes) in time in an
>> automated fashion?
>> For example, given a prespecified number N which is the number of
>> blocks/regimes, lets say 3.
>> And given 5 year history of SP500 time series and returns.
>> Manually, the period before Sept. 2008 is one regime. The period in-between
>> Sept. 2008 and arguably May 2010 is the 2nd regime.
>> Then the third regime is from May 2010 until today.
>> So then we have three blocks/regimes splitted.
>> Is there a way to split automatically?
>> I have been thinking about using clustering algorithm on the returns.
>> However, what is needed is a constrained version of the clustering
>> algorithm, i.e. the 3 big blocks/regimes need to be contiguous within each
>> block/regime itself...
>> I am looking for a way to do this in R...
>> Any thoughts are highly appreciated!
>> Thanks a lot!
>>
>> FYI: I have asked a similar question before on this list but somehow I felt
>> it's probably better to renew the question with my newer and more concrete
>> examples. Also I've listed my question here so the answers to my question
>> could be reference for fellow statisticians in the future...
>> http://stats.stackexchange.com/questions/23817/splitting-time-series-data-into-blocks-regimes
>>
>>        [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-SIG-Finance at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> -- Subscriber-posting only. If you want to post, subscribe first.
>> -- Also note that this is not the r-help list where general R questions should go.
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.

```