lindermanlab / ssm

Bayesian learning and inference for state space models
MIT License
545 stars 199 forks source link

Add support for hierarchical hidden Markov models (not just hierarchical priors on the transitions and observations) #49

Open r-shruthi11 opened 5 years ago

r-shruthi11 commented 5 years ago

Hello, Thanks for creating this package! I was wondering if you could help me with an example to create a hierarchical HMM? I'm looking to have two levels of states - the higher governs the structure of the transitions between the lower states with a simple Gaussian observation model - I was wondering how to instantiate such a model. Thanks again! Shruthi

slinderman commented 5 years ago

Hi Shruthi,

Thanks for raising this issue. The "hierarchical" extensions are a bit poorly named, unfortunately. They refer to having a hierarchical prior distribution on the observation and/or transition distributions, and they interact with the tag kwarg in the HMM interfaces. For example, in some recent work we used these types of models to capture variability in the observation models from one individual to the next. (Though to be honest, I ended up writing special case code for this purpose, which I still need to merge into the master branch.)

That said, it wouldn't be too hard to put together a simple hierarchical HMM with multiple levels of discrete states. That's something I've wanted to do for a long time. The straightforward implementation is to just expand the state space to make it a cross product of the higher and lower levels, but this would yield suboptimal message passing performance. A proper HHMM message passing algorithm would be a very feature to add. I'll mark this as a feature request for now and hope to get to it asap!

r-shruthi11 commented 5 years ago

Hi Scott,

Thanks for clarifying that! I'm a big fan of your work with the worm data :) Yeah, I think the HHMM feature would be really helpful to model nested processes/actions along multiple timescales. I'll keep an eye out for that feature when you add it!

mackancurtaincheeks commented 3 years ago

Is this implemented by now? :)