Mixture of hierarchical model

There are quite a few discussion here on how to improve sampling of mixture models, eg:
Properly sampling mixture models. In your case, you should try to:

  1. rewrite the model using pm.Mixture
    A latent mixture is usually better as you can use NUTS to sample all parameters - otherwise mixing Gibbs Sampler and NUTS might not always works.

  2. restrict the order of the slopes
    In this way you limit the mode switching problem, see How to improve fit of Poisson Mixture Model in PyMC3?

  3. better prior
    More informative prior for mu_a and mu_b would also help.

1 Like