Hi!
I implemented a Hidden Markov Model with gaussian emissions to get posterior samples from multiple sequences of observations and my chains seem to be converging, however I am having label switching problems. Below you can find the code and results.
- Code
N_states = 8
coord = {'emissions': np.arange(0, N_states)}
with pm.Model(coords = coord) as model:
observations = pm.Data('data', observations, mutable = True)
Pt = pm.Dirichlet("p_transition", np.ones( (N_states, N_states) ), shape=(N_states, N_states))
P0 = pm.Dirichlet("p_init", np.ones((N_states,)), shape=(N_states,))
logp_initial_state = at.log(P0)
logp_transition = at.log(Pt)
mu = pm.Normal('mu', mu = [-30,-25, -20, -16, -12,-9,-6,-5], sigma = [2]*5+[1]*3)
sigma = pm.InverseGamma('sigma', alpha= 40, beta=80, dims='emissions')
loglike = pm.Potential( "hmm_loglike", hmm_logp_value_grad_op( observations, mu, sigma, logp_initial_state, logp_transition) )
-
Results
After some research, I found that label switching is a common problem in mixture models and is caused by symmetry in the likelihood of the model parameters, but it is still not very clear to me the reasoning behind this problem. Can anyone recommend some literature about this topic?
Why does this happen and what can I do to prevent this?
Thank you in advance.