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:
-
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. -
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? -
better prior
More informative prior formu_a
andmu_b
would also help.