At the beginning of my postdoc, I searched for and compared Python packages for fitting hidden Markov models. As this may be useful to other HMM fans, I am sharing the resulting table, which non-comprehensively covers various features of IOHMM and Dynamax.
| Feature | Description | IOHMM | Dynamax |
|---|---|---|---|
| GaussianHMM | HMM with Gaussian emissions, Gaussian mixture model | UnSupervisedIOHMM with OLS emissions (no covariates) | GaussianHMM |
| LinearModelHMM | linear regression with state-dependent weights, switching linear regression | UnSupervisedIOHMM with OLS emissions | LinearRegressionHMM |
| LogisticModelHMM | logisitic regression with state-dependent weights, switching logistic regression | UnSupervisedIOHMM with GLM emissions – Bernoulli with logistic link function | LogisticRegressionHMM |
| MultinomialHMM | include miss trials | not possible? | MultinomialHMM |
| Covariates affecting transition probability | UnSupervisedIOHMM with transition covariates | not possible | |
| Covariates affecting initial state | UnSupervisedIOHMM with intial state covariates | not possible? | |
| Stickiness | increased probability of self-transitions | not possible? | stickiness parameter |
| Mutiple emissions | with different distributions? | UnSupervisedIOHMM (inc. with different distributions) | not possible? |
| Multidimensional emissions | UnSupervisedIOHMM | any of the above models | |
| Model initialisation | random | kmeans or prior (random sample from prior distribution) | |
| Running time | Time to fit 2-state LinearModelHMM on RTs with contrast as input, 400 trials | 1.6s (initialisation and em fitting) | initialisaton: 0.6s, em fitting: 1.1s |
| Other pros | flexible, easy to add and remove things from the same model | support available from active developers, many more functionalities, Bayesian (returns a distribution, priors are explicit) | |
| Other cons | is it being actively maintained? Seems to be just a couple people working |
Have I missed another package or misrepresented something here? Please let me know!
Update 17/04/2025: I am mainly using Dynamax at this point. While IOHMM was reliable for fitting a LinearRegressionHMM, I found that parameter estimates were unstable and suspicious when fitting a GLM-HMM. Using sensible initial parameters in Dynamax solved this problem.