As indicated in PyMC doc, HERE :
“Prior predictive checks […] allow you to check whether you are indeed incorporating scientific knowledge into your model – in short, they help you check how credible your assumptions before seeing the data are.”
The most important point, in my opinion, is the assumption “before seeing the data”, which seems logical.
However, it gives me a modeling problem, which I explain below:
Let B
be a certain random variable following a Bernoulli law, where the parameter involved is, say, θ
. Suppose I plan an experiment consisting of n
i.i.d
realizations of B
; the number x∈[[0,n]]
of successes follows a binomial distribution X~Binom(n,θ)
and the likelihood of x
knowing θ
is, unless I err:
f(x|θ)= \begin{pmatrix}n\\x \end{pmatrix} θ^x (1-θ)^{(n-x)}
Previous knowledge on that particular B
suggest me that θ
must be close to 0
or 1
. I then take as prior the beta distribution Beta(1⁄2,1⁄2)
and write:
import pymc as pm
with pm.Model() as model:
p = pm.Beta("p", alpha=0.5, beta=0.5) idata = pm.sample() pm.sample_prior_predictive(return_inferencedata=True) idata.extend(pm.sample_prior_predictive())
Note that, for the moment, neither n
nor x
have been defined and I have no data yet…
My first miscomprehension comes from the fact that both groups idata.posterior
and idata.prior
contain the same variable p
with different values and shapes: idata.posterior ["p"].shape= (4, 1000)
and idata.prior ["p"].shape= (1, 500)
.
- How can this be explained to someone new to Bayesian inference?
My second miscomprehension comes from the PyMC doc
sentence: “help you check how credible your assumptions before seeing the data are”.
The only assumption made so far is to include the beta distribution Beta(1⁄2,1⁄2)
in the model, so…
- How can someone new to Bayesian inference check if this assumption is credible, knowing that
idata
contains only the groupsposterior
,sample_stats
andprior
?
I know something still escapes me in the logic of all this… But could my two questions be answered, as basic as they are, to help me progress?
I hope I have been understandable and not excessively tedious.