Is there an example on how to work with generalized mixture models?


#1

I am working on a simplest complex example to record my learning journey here.

Working with Normal Mixtures works fine, but I’m not quite sure how to debug the error that I’m getting at the bottom of the notebook when trying to do generalized Mixtures. Am I setting up the model incorrectly?


#2

The correct syntax is changing:
components = pm.Poisson('components', mu=lam, shape=(2,))
to
components = pm.Poisson.dist(mu=lam, shape=(2,))

Also, careful of label switching in this case. More information see https://gist.github.com/junpenglao/4d65d1a9bf80e8d371446fadda9deb7a


#3

Thanks @junpenglao! I must have missed the .dist(...) thing somewhere. Was this documented in the docs? Perhaps I can put in a PR to show how this syntax gets used?

Btw, I got the Poisson Mixture working! Thanks for your help! :smile:


#4

I think it is in the doc somewhere but you are right, it is not very clear from the docstring. It would be great to add an Example into the docstring like what you are adding for Normal etc!


#5

Thanks @junpenglao! One thing I’m finding is I’m getting errors with putting together Weibull mixtures. Might you have an intuition as to what’s happening? I updated my mixture-model notebook (https://github.com/ericmjl/bayesian-analysis-recipes/blob/master/notebooks/mixture-model.ipynb), and it can be found at the bottom.

The error message is two-fold:

  • No modes.
  • Object not iterable.

Neither makes sense to me, as I’m following the pattern above for the Poisson mixtures.


#6

It might not work directly out of the box… There are some problem with the mixture model in terms of dimension etc, for example:

There are some work needs to be done there…


#7

I noticed that the Weibull distribution doesn’t have a mode defined. Is that because of the definition of the Weibull mode being conditionally dependent on the value of the alpha parameter? (https://en.wikipedia.org/wiki/Weibull_distribution)

Can we have conditional modes in PyMC3 distributions, or do they have to be analytical, non-conditional modes?