I have started reading about HMM it gives an intuitive idea about what HMM is all about. I am looking out for example where its applied to Equity model using R / Excel. The material which I read so far is about its application to speech recognition.

  • 1
    $\begingroup$ Am curious about this too as I am working on HMM right now, interesting question. $\endgroup$
    – Matt Wolf
    Dec 26, 2012 at 11:05

3 Answers 3


Systematic Investor also did a two part series implementation in R which is also quite helpful as he details the pitfalls too.

Post One: http://systematicinvestor.wordpress.com/2012/11/01/regime-detection/

Part Two: http://systematicinvestor.wordpress.com/2012/11/15/regime-detection-pitfalls/

Updated version after the 'RHmm' library was taken down from CRAN repository: http://systematicinvestor.github.io/Regime-Detection-Update


The clearest and most intuitive article I have seen so far is
Kritzman et al., Regime Shifts: Implications for Dynamic Strategies in FAJ (May / June 2012)

It not only shows how you can use HMM for financial modelling but it also goes through the actual estimation algorithm (Baum-Welch) step-by-step and even gives full MATLAB-code.

From the abstract:

Regime shifts present significant challenges for investors because they cause performance to depart significantly from the ranges implied by long-term averages of means and covariances. But regime shifts also present opportunities for gain. The authors show how to apply Markov-switching models to forecast regimes in market turbulence, inflation, and economic growth. They found that a dynamic process outperformed static asset allocation in backtests, especially for investors who seek to avoid large losses.

I brought the paper to the attention of the renowned blog Quantivity and they started a series on reproducing the results in R: Here.

(I am not aware of a freely accessible copy of the paper - if you find one, please include it in a comment - I will change the answer accordingly.)

For your own experiments with HMM in R you can use the RHmm package.

Unfortunately the RHmm package has been deprecated. A good alternative seems to be the depmixS4 package.

  • 3
    $\begingroup$ This is very nice $\endgroup$
    – pyCthon
    Dec 27, 2012 at 19:54
  • 1
    $\begingroup$ Free link to the paper. $\endgroup$
    – Zhubarb
    Sep 25, 2014 at 9:41

Have a look at the following two papers, one from Chris Rogers and Liang Zhang where they introduce a model using HMM which captures stylized facts of financial returns. And the second where we extended this model to risk measures.

Implementation in R is strait forward using ML as mentioned in the paper.




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.