Path: blob/master/notebooks/book2/03/hierarchical_binom_rats.ipynb
1193 views
Kernel: Python [conda env:py3713]
A hierarchical binomial model for rat-tumor problem
author: @karm-patel
We fit a hierarchical beta-binomial model to some count data derived from rat survival. We use Blackjax's HMC method for inference. Based on https://www.pymc.io/projects/examples/en/latest/generalized_linear_models/GLM-hierarchical-binomial-model.html
See also this notebook for a pymc3 version, that automagically performs change of variables.
See also this notebook for an illustration of the deleterious effects of forgetting to apply the change of variable formula.
Here is the model:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
DeviceArray(-1072.9049, dtype=float32)
In [ ]:
In [ ]:
In [ ]:
CPU times: user 9.76 s, sys: 0 ns, total: 9.76 s
Wall time: 9.67 s
In [ ]:
In [ ]:
In [ ]:
Theta MLE
In [ ]:
Text(0.5, 1.0, 'Theta MLE')
Theta Posterior
In [ ]:
<matplotlib.collections.LineCollection at 0x7f12ec4bd050>
In [ ]:
/home/patel_karm/sendbox/probml-utils/probml_utils/plotting.py:26: UserWarning: LATEXIFY environment variable not set, not latexifying
warnings.warn("LATEXIFY environment variable not set, not latexifying")
In [ ]:
/home/patel_karm/sendbox/probml-utils/probml_utils/plotting.py:80: UserWarning: set FIG_DIR environment variable to save figures
warnings.warn("set FIG_DIR environment variable to save figures")
In [ ]:
In [ ]:
/home/patel_karm/sendbox/probml-utils/probml_utils/plotting.py:80: UserWarning: set FIG_DIR environment variable to save figures
warnings.warn("set FIG_DIR environment variable to save figures")
In [ ]:
In [ ]: