Is there any code out there that implements the baum-welch algorithm for a very basic problem? It would be very helpful to actually see the algorithm in action to better understand how it works.

I understand the forward and the backward procedures and already implemented them in R for a simple example. However, up to now, I haven't succeeded in implementing the baum-welch algorithm to actually estimate the parameters of a HMM. Numerical example to understand Expectation-Maximization helped me to grasp the logic of EM. However, I still do not fully understand how this translates to the baum-welch algorithm in a HMM.

Can anyone share native R code (without complex rcpp functions etc.) of a very basic version of the baum-welch algorithm in a simple HMM?

I think that there are many others who would profit from a working example of the algorithm. Something that makes the formulas come alive in a simple example.


Here is a DIY answer, with the building blocks provided:

You are probably aware R has an HMM package. One thing to highlight is that you can view all available functions in a package as shown on this link. And, the final piece of the puzzle: you can view function source code in R as follows.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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