AmpersandTV / pymc3-hmm

Hidden Markov models in PyMC3
Other
96 stars 13 forks source link

Allow estimation for non-homogeneous HMMs #14

Closed brandonwillard closed 4 years ago

brandonwillard commented 4 years ago

We want to estimate non-homogeneous HMMs; specifically, ones with time-varying transition probabilities.

This will require updates to the logp and random methods in SwitchingProcess and HMMStateSeq, as well as the function ffbs_astep in step_methods.py. The current implementations assume that the transition probabilities (i.e. Gamma matrix) does not change over time.

After that, we should try logistic-like regression for fixed-effects on the transition probabilities. In other words, the transition probabilities for each conditional state (i.e. from one state to all the others) which are normally Dirichlet distributed priors are now changed to logit-inverse/"softmax"-derived probability vectors driven by a design matrix + covariate vector regression. I.e. p_0 = tt.nnet.softmax(X.dot(beta_0)) for constant matrix X and vector beta_0 with some prior distribution (e.g. normal).

We can start with a simulation study with variations across time that produces zero counts at "late" hours, medium counts and some zeros through mid-day Mon-Fri, and high counts during afternoons and weekends.

brandonwillard commented 4 years ago

It's worth noting that this work and related model updates are also covered/obviated by the use of Theano-based "model graphs" (i.e. standard Theano graphs that use the RandomVariable operators from symbolic_pymc).

Using Theano model graphs, it's considerably more straightforward to define very complex time-series and HMM models (e.g. the HMMs implemented here can be re-implemented using model graphs in only about a dozen lines of nicely formatted code).

See the discussion in #18 for another example of how Theano model graphs can dramatically improve our modelling process.