Bayesian Monte Carlo and MCMCLesson 76 of 76 · 10 min

Predict new observations

Propagate posterior parameter uncertainty into a future outcome distribution.

Posterior predictive sampling first draws a parameter from its posterior, then draws new observations conditional on that parameter. The resulting distribution accounts for parameter uncertainty and future outcome variability under the model. It is distinct from the posterior distribution of the parameter alone.

For the beta-binomial example, draw p from beta(20,14), then generate a future count among 20 observations with that p. Plugging the posterior mean directly into a binomial omits uncertainty in p. Both have the same expected count here, but the predictive mixture has greater variance.

The beta-binomial distribution gives an exact predictive mean and variance to check the simulation. Predictive checks compare features of replicated and observed data to reveal mismatch. A tail comparison under the fitted predictive model can be useful criticism, but does not by itself validate the prior or observation model. Keep numerical accuracy separate from model adequacy.

A future group includes parameter uncertainty
  1. Draw an uncertain parameter
    p∼Beta⁡(20,14)p\sim\operatorname{Beta}(20,14)
  2. Draw a future group
    K∣p∼Binomial⁡(20,p)K\mid p\sim\operatorname{Binomial}(20,p)
  3. Keep the targets distinct
    parameter pfuture count K\begin{gathered}\text{parameter }p\\\text{future count }K\end{gathered}
Reference illustration. A plug-in forecast fixes p at its posterior mean and discards parameter variation. Predictive count quantiles, posterior parameter intervals and numerical MC error describe different quantities.

Can the plug-in and full predictive distributions share a mean but have different spreads?

Write a prediction (optional)

Seeded teaching simulation

Select Run Python below with the code unchanged.

Tools
About Python ↗

The code is editable. Press Ctrl+Enter or ⌘+Enter to run Python from the editor.

Published example output

This result comes from the original Python. Your runs appear above. Build environment ↗

Full predictive mean / variance: 11.762 7.519
Exact beta-binomial mean / variance: (np.float64(11.764705882352942), np.float64(7.474048442906574))
Plug-in mean / variance: 11.753 4.742
Full predictive count quantiles: [ 7. 12. 16.]
Posterior p quantiles: [0.446 0.591 0.722]

Read the first result

Count quantiles describe future group outcomes; p quantiles describe a parameter. Neither is the numerical error bar on an estimated mean.

Try an edit

Replace a, b, future_n, draws = 20, 14, 20, 20000 with a, b, future_n, draws = 20, 14, 100, 20000. Select Run Python again. Compare the second numbers in Full predictive mean / variance and Plug-in mean / variance. What happens to the variance gap when more outcomes share the same uncertain probability?

Back to the Python editor

Scope. The model assumes future observations share the same p and sampling mechanism as the invented evidence. Changing conditions and model uncertainty require further analysis.

Try a fresh case

Which simulation represents the full posterior predictive count?

Choose an answer
Need a hint?
Hint 1

Write the units of p and of the count.

Hint 2

First sample the uncertain parameter, then the conditional observation.

Your notes