Unit 10, lesson 73

Posterior Prediction and Prior Sensitivity

How the posterior predictive distribution forecasts new outcomes by averaging over parameter uncertainty, why outcomes sharing one unknown probability are dependent, and how prior sensitivity and predictive checks probe a model.

  • Video 73
  • Bayesian Inference

Seven of ten participants succeeded at a task, and with a Beta⁡(2,2)\operatorname{Beta}(2, 2) prior the previous lesson turned that into a Beta⁡(9,5)\operatorname{Beta}(9, 5) posterior for the success probability pp. Now two more participants are about to try. Their outcomes are 00 or 11, and they would remain uncertain even if pp were known exactly, so a forecast has to carry both the uncertainty about pp and the randomness of each attempt. This lesson builds such forecasts, shows why two future outcomes that share one unknown pp are not independent, and then asks how much the conclusions depend on the prior and whether the model can reproduce the data. The data are constructed for teaching.

Key terms

Posterior predictive distribution

Definition Let yy be the observed data and y~\tilde{y} future data from the same model. Assume that, given pp, the future data are independent of the observed data. The posterior predictive distribution gives each possible value of y~\tilde{y} the probability

P(y~∣y)=E(P(y~∣p)∣y),P(\tilde{y} \mid y) = E\bigl(P(\tilde{y} \mid p) \bigm| y\bigr),

the conditional probability of y~\tilde{y} given pp, averaged over the posterior distribution of pp. With a posterior density π(p∣y)\pi(p \mid y) this average is the area under P(y~∣p) π(p∣y)P(\tilde{y} \mid p)\,\pi(p \mid y) over 0<p<10 < p < 1. The same distribution can be approximated by simulation. Draw pp from the posterior, then draw y~\tilde{y} from the model with that pp, and repeat many times.

In plain words A forecast has two layers of uncertainty. The parameter pp is unknown, and even a known pp leaves each outcome random. Plugging a single estimate in for pp keeps the second layer and drops the first. The posterior predictive distribution keeps both, and it inherits the assumption that future participants follow the same model as the observed ones.

Example Number the observed attempts 11 to 1010 and let Y11Y_{11} be the next outcome, with Y11=1Y_{11} = 1 for a success. Given pp, the probability of a success is pp itself, so its posterior average is the posterior mean,

P(Y11=1∣y)=E(p∣y)=914,\begin{aligned} P(Y_{11} = 1 \mid y) &= E(p \mid y) \\[0.4em] &= \frac{9}{14}, \end{aligned}

about 0.6430.643, and P(Y11=0∣y)=5/14P(Y_{11} = 0 \mid y) = 5/14. For this single binary outcome, plugging in the posterior mean gives the same number. That agreement comes from averaging pp itself, and it need not carry over to events whose probability depends on pp in a nonlinear way.

Conditional independence

Definition Outcomes Y11Y_{11} and Y12Y_{12} are conditionally independent given pp if, for every value of pp and all outcomes aa and bb, P(Y11=a,Y12=b∣p)=P(Y11=a∣p) P(Y12=b∣p)P(Y_{11} = a, Y_{12} = b \mid p) = P(Y_{11} = a \mid p)\,P(Y_{12} = b \mid p). Outcomes that are conditionally independent given pp need not be independent once pp is averaged over its posterior. The pair is exchangeable if its joint probabilities do not change when the order of the outcomes is swapped. Exchangeable outcomes need not be independent.

In plain words If pp were known, one participant’s result would say nothing about the next. But pp is unknown and both outcomes depend on the same pp. A success makes larger values of pp more plausible, and that raises the forecast for the next attempt.

Example Given pp, the chance that both Y11Y_{11} and Y12Y_{12} are successes is p2p^2. The predictive probability is therefore the posterior average of p2p^2, which for Beta⁡(9,5)\operatorname{Beta}(9, 5) is

E(p2∣y)=9⋅1014⋅15=37≈0.4286,\begin{aligned} E(p^2 \mid y) &= \frac{9 \cdot 10}{14 \cdot 15} = \frac{3}{7} \\[0.4em] &\approx 0.4286, \end{aligned}

whereas squaring the posterior mean gives

(E(p∣y))2=81196,\bigl(E(p \mid y)\bigr)^2 = \frac{81}{196},

about 0.41330.4133. The gap 3/7−81/196=3/1963/7 - 81/196 = 3/196 is exactly the posterior variance Var⁡(p∣y)\operatorname{Var}(p \mid y), so it is not rounding error. The same answer comes in two steps. The first success has predictive probability 9/149/14, and if it happened the posterior would become Beta⁡(10,5)\operatorname{Beta}(10, 5), giving the second success probability 10/1510/15. The product 914⋅1015\tfrac{9}{14} \cdot \tfrac{10}{15} is 3/73/7. So P(Y12=1∣Y11=1,y)=2/3P(Y_{12} = 1 \mid Y_{11} = 1, y) = 2/3, which is larger than 9/149/14, and the two future outcomes are dependent. They are exchangeable, since success then failure and failure then success both have predictive probability 9⋅514⋅15=314\tfrac{9 \cdot 5}{14 \cdot 15} = \tfrac{3}{14}.

Beta-binomial predictive distribution

Definition Suppose the posterior is Beta⁡(a,b)\operatorname{Beta}(a, b) and mm future trials are conditionally independent given pp, each with success probability pp, and independent of the observed data given pp. The number KK of future successes has the beta-binomial predictive distribution

P(K=k∣y)=(mk)B(a+k,b+m−k)B(a,b)\begin{gathered} P(K = k \mid y) \\[0.4em] = \binom{m}{k} \frac{B(a + k, b + m - k)}{B(a, b)} \end{gathered}

for k=0,1,…,mk = 0, 1, \dots, m, where BB is the constant from the beta density. Its mean is mpˉm\bar{p} with pˉ=a/(a+b)\bar{p} = a/(a + b), the same as the plug-in Binomial⁡(m,pˉ)\operatorname{Binomial}(m, \bar{p}) mean. Its variance is the plug-in variance mpˉ(1−pˉ)m\bar{p}(1 - \bar{p}) multiplied by (a+b+m)/(a+b+1)(a + b + m)/(a + b + 1), a factor larger than 11 when m≥2m \ge 2.

In plain words Given pp the count is binomial, and the posterior says how uncertain pp is. Mixing the two spreads the forecast more widely than the plug-in binomial with pp fixed at pˉ\bar{p}, as soon as m≥2m \ge 2. A simulation has to respect that structure. Draw one pp for the whole group of future trials, then the count. Drawing a fresh pp for every single trial gives independent trials that each succeed with probability pˉ\bar{p}, which is the plug-in binomial again.

Example For the next m=2m = 2 attempts under Beta⁡(9,5)\operatorname{Beta}(9, 5), no successes has probability 5⋅614⋅15\tfrac{5 \cdot 6}{14 \cdot 15}, exactly one success has probability 2⋅9⋅514⋅152 \cdot \tfrac{9 \cdot 5}{14 \cdot 15}, and two successes have probability 9⋅1014⋅15\tfrac{9 \cdot 10}{14 \cdot 15}, so

P(K=0∣y)=1/7,P(K=1∣y)=3/7,P(K=2∣y)=3/7.\begin{aligned} P(K = 0 \mid y) &= 1/7, \\[0.4em] P(K = 1 \mid y) &= 3/7, \\[0.4em] P(K = 2 \mid y) &= 3/7. \end{aligned}

The plug-in Binomial⁡(2,9/14)\operatorname{Binomial}(2, 9/14) gives 25/196≈0.12825/196 \approx 0.128, 45/98≈0.45945/98 \approx 0.459 and 81/196≈0.41381/196 \approx 0.413, with less weight on the two extremes. A 95 percent credible interval for pp is a set of values between 00 and 11, while a predictive set for KK is a set of counts. Here the smallest count set with predictive probability at least 0.950.95 is all of {0,1,2}\{0, 1, 2\}, because leaving out even the least probable count keeps only 6/7≈0.8576/7 \approx 0.857.

Prior sensitivity

Definition Prior sensitivity is the extent to which posterior conclusions change when the prior is replaced by other defensible priors while the data and the likelihood stay the same. A prior sensitivity analysis reports the conclusions under several stated priors, each with its reason. Sensitivity to the likelihood, such as the assumptions of a common pp and of independence, is a separate question that changing the prior does not address.

In plain words If several reasonable priors lead to the same practical conclusion, that conclusion does not hinge on the choice among them. If they lead to different conclusions, the data alone have not settled the question, and the report should say so. A prior is chosen for a reason given in advance, not after seeing which one gives a preferred answer. A highly concentrated prior is a strong assumption and not extra data.

Example Hold the 77 successes in 1010 attempts fixed and vary the prior.

PriorPosteriorMeanP(p>0.5∣y)P(p > 0.5 \mid y)
Beta⁡(1,1)\operatorname{Beta}(1, 1)Beta⁡(8,4)\operatorname{Beta}(8, 4)0.6670.6670.8870.887
Beta⁡(2,2)\operatorname{Beta}(2, 2)Beta⁡(9,5)\operatorname{Beta}(9, 5)0.6430.6430.8670.867
Beta⁡(20,20)\operatorname{Beta}(20, 20)Beta⁡(27,23)\operatorname{Beta}(27, 23)0.5400.5400.7160.716

The posterior means are exactly 2/32/3, 9/149/14 and 27/5027/50. The two weak priors give similar answers. The Beta⁡(20,20)\operatorname{Beta}(20, 20) prior is concentrated near 12\tfrac12, and in the posterior mean formula its two shape parameters add to 4040, which leaves the ten attempts a weight of only 10/50=1/510/50 = 1/5. Whether that concentration is justified depends on what was known before the study, and the arithmetic cannot decide it.

Prior predictive check

Definition The prior predictive distribution is the distribution of the data implied by the prior and the likelihood together, before any data are observed. It gives each possible data set yy the probability E(P(y∣p))E\bigl(P(y \mid p)\bigr), the average over the prior. A prior predictive check draws pp from the prior, draws a data set with the planned design from the model with that pp, repeats this many times, and compares summaries of the simulated data with what is known to be plausible. With a Beta⁡(α,β)\operatorname{Beta}(\alpha, \beta) prior and nn binomial trials, the prior predictive distribution of the count is the beta-binomial distribution of the earlier card with a=αa = \alpha, b=βb = \beta and m=nm = n.

In plain words Before trusting a prior, look at the data it expects. Parameters are hard to judge directly, but predicted data are often easy to compare with background knowledge. A prior that regularly predicts implausible data needs another look, and so do the likelihood and the measurement scale behind it.

Example For 1010 attempts the flat Beta⁡(1,1)\operatorname{Beta}(1, 1) prior gives every count from 00 to 1010 probability 1/111/11. The Beta⁡(2,2)\operatorname{Beta}(2, 2) prior gives 99 or 1010 successes probability about 0.1080.108. The Beta⁡(20,20)\operatorname{Beta}(20, 20) prior gives 99 or 1010 successes probability only about 0.0190.019 and puts about 0.8480.848 on counts from 33 to 77. If earlier experience suggests that a good instruction card can make nearly every participant succeed, the Beta⁡(20,20)\operatorname{Beta}(20, 20) prior conflicts with that experience, and the check shows the conflict before any data are collected.

Posterior predictive check

Definition A posterior predictive check draws pp from the posterior, draws a replicated data set yrepy^{\text{rep}} with the same design as the observed data from the model with that pp, and repeats this many times. It compares a chosen test quantity TT, computed on each replication, with its observed value T(y)T(y), for example through the proportion of replications with T(yrep)≥T(y)T(y^{\text{rep}}) \ge T(y). The test quantity should target a feature the model might fail to capture. A check can reveal a mismatch, but it cannot prove the model correct. The posterior was fitted to the same data, so the check is not an independent test, and its tail proportion does not behave like a classical p-value in general.

In plain words Ask whether data simulated from the fitted model look like the data actually seen, in the respects that matter for the question. A total that the model was fitted to will usually look fine. A feature such as a difference between groups is a sharper test of a model that assumes one common pp.

Example Suppose the ten attempts came from two sites of five participants each, with 55 successes at one site and 22 at the other, so T(y)T(y), the absolute difference between the site counts, is 33. Draw pp from Beta⁡(9,5)\operatorname{Beta}(9, 5), then two site counts from Binomial⁡(5,p)\operatorname{Binomial}(5, p) with that same pp. Replicated totals are 77 or more in about 51 percent of replications, so the total gives no warning, as expected. A site difference of 33 or more occurs in about 8.3 percent of replications. That is somewhat unusual under one common pp, but ten attempts are too few to settle whether the sites differ. The check points to a question for more data or for the study design, and it does not prove the common-pp model either right or wrong.

Check yourself

  1. Under the Beta⁡(9,5)\operatorname{Beta}(9, 5) posterior, find the predictive probability that the next two attempts contain exactly one success. Compare it with the plug-in binomial calculation that fixes p=9/14p = 9/14, and say which model each calculation uses.
Show the answer

Success then failure has predictive probability 914⋅515\tfrac{9}{14} \cdot \tfrac{5}{15}, because after a hypothetical success the posterior would be Beta⁡(10,5)\operatorname{Beta}(10, 5). Failure then success has the same probability 514⋅915\tfrac{5}{14} \cdot \tfrac{9}{15}. The total is

2⋅9⋅514⋅15=90210=37,\frac{2 \cdot 9 \cdot 5}{14 \cdot 15} = \frac{90}{210} = \frac{3}{7},

about 0.4290.429. The plug-in calculation gives 2⋅914⋅514=45/98≈0.4592 \cdot \tfrac{9}{14} \cdot \tfrac{5}{14} = 45/98 \approx 0.459. The plug-in model treats pp as known to equal 9/149/14 and the two attempts as independent. The predictive calculation averages over the posterior uncertainty about the shared pp, which moves probability away from the mixed result, one success and one failure, toward the two extremes, both successes or both failures.

  1. A colleague says that the 95 percent equal-tailed credible interval [0.386,0.861][0.386, 0.861] for pp is also a 95 percent prediction for the next participant’s outcome. What is wrong, and what is the smallest set of outcomes with predictive probability at least 0.950.95?
Show the answer

The interval describes uncertainty about the parameter pp. The next outcome is 00 or 11, so it never lies in [0.386,0.861][0.386, 0.861]. Its predictive distribution gives probability 9/14≈0.6439/14 \approx 0.643 to a success and 5/14≈0.3575/14 \approx 0.357 to a failure. A set containing only one outcome has predictive probability at most 0.6430.643, so the smallest set with probability at least 0.950.95 is {0,1}\{0, 1\}. For a single binary outcome the 95 percent predictive set is trivial, and the predictive probabilities themselves are the informative summary.

  1. Keep the data fixed at 77 successes in 1010 attempts. Find the predictive probability that the next attempt succeeds and that the next two both succeed, under the Beta⁡(1,1)\operatorname{Beta}(1, 1) prior and under the Beta⁡(20,20)\operatorname{Beta}(20, 20) prior. If the two weaker priors Beta⁡(1,1)\operatorname{Beta}(1, 1) and Beta⁡(2,2)\operatorname{Beta}(2, 2) give similar answers, does that show the model is correct?
Show the answer

Under Beta⁡(1,1)\operatorname{Beta}(1, 1) the posterior is Beta⁡(8,4)\operatorname{Beta}(8, 4). The next attempt succeeds with probability 8/12=2/38/12 = 2/3, and the next two both succeed with probability 8⋅912⋅13=6/13≈0.462\tfrac{8 \cdot 9}{12 \cdot 13} = 6/13 \approx 0.462. Under Beta⁡(20,20)\operatorname{Beta}(20, 20) the posterior is Beta⁡(27,23)\operatorname{Beta}(27, 23), with probabilities 27/50=0.5427/50 = 0.54 and 27⋅2850⋅51=126/425≈0.296\tfrac{27 \cdot 28}{50 \cdot 51} = 126/425 \approx 0.296. The Beta⁡(2,2)\operatorname{Beta}(2, 2) answers, 9/14≈0.6439/14 \approx 0.643 and 3/7≈0.4293/7 \approx 0.429, sit close to the Beta⁡(1,1)\operatorname{Beta}(1, 1) answers, so the forecasts change only a little between those two priors. The Beta⁡(20,20)\operatorname{Beta}(20, 20) forecasts are much lower, so a strongly concentrated prior would change the conclusion and needs its own justification. Agreement between the weaker priors does not show the model is correct. All three analyses share the same likelihood, with one common pp and attempts that are independent given pp, and if participants at different sites have different success probabilities, the weaker priors can agree while the model they share is wrong. Agreement across reasonable priors shows stability with respect to the prior, while checks of the likelihood and the design address the rest.

How this lesson connects