One of the main concerns with finite mixture models is how to decide the number of components. A rule of thumb is to begin with a relatively small number of components and then increase it in order to improve the model-fit evaluation. As usual, model-fit is evaluated using posterior-predictive checks, measures such as WAIC or LOO, and on the basis of the expertise of the modeler(s).
Let us compare the model for . In order to do this, we are going to fit the model four times, and we are going to save the trace and model objects for later use:
clusters = [3, 4, 5, 6]models = []traces = []for cluster in clusters: with pm.Model() ...