Hidden Markov model with unknown latent variables

Hello!

I’m trying to estimate a Gaussian HMM with unknown discrete latent variables. Is it possible to consider an augmented approach where the latent variables are generated according to the full conditional distributions (sampling from a categorical distribution with probabilities evaluated at each MCMC iteration)?

hidenmarkovmodel Modeling RStan #latentvariables

Hey, typically we need to marginalise over the latent variables. There are examples in the User’s guide and I also recently wrote a blogpost about doing this for ecological models. Hope they help!

We have built-ins for HMMs now so you don’t have to manually marginalize:

https://mc-stan.org/docs/functions-reference/hidden_markov_models.html

The Stan built-ins assume a homogeneous HMM, which just means the transition probabilities remain constant from state-to-state (and thus can’t depend on state-dependent covariates, as they might in some ecological models, like animal movement models).

If you need to do posterior sampling on states, you can use hmm_latent_rng. If you just want marginals on state probabilities at each position, you can use hmm_hidden_state_prob.