Hi,
if you have two models for the same dataset, you’d typically use a model comparison metric. There are some examples in Model comparison — PyMC3 3.11.4 documentation
If it’s actually the same model and you’re interested in the probability that a parameter (e.g. sales) for company A is higher than for company B, it depends:
-
If you did one
pm.sample(), fitting the PyMC model to all data at the same time, the posterior draws are correlated and you can simply dop_B_greater_A = numpy.mean(posterior.sales_B > posterior.sales_A). -
If you did multiple
pm.sample(), fitting the same model to two different datasets, you’ll not have any correlation betweensales_Aandsales_B. Now you want to get thep_B_greater_Agiven let’s say 10_000 posterior draws ofsalesfrom a model fitted to company A data and say 5_000 posterior draws ofsalesfrom a model fitted to company B data. Here you can’t do an elementwise comparison, but need to consider all10_000 * 5_000combinations. So “What’s the probability that a random posterior sample from B is greater than a random posterior sample from A?”. Doing this exactly for N>2 candidates to compare is surprisingly difficult to implement, but you can just use mypyrffpackage for that:p_best = pyrff.sampling_probabilities([posteriorA.sales, posteriorB.sales], correlated=False). See the test case for some simple examples.
cheers