Posterior predictive checking
Integrate parameter uncertainty, design revealing replicated-data summaries, and separate model checking from calibration.
On this page
The question for today
What you’ll understand
- Calculate a posterior predictive distribution rather than a plug-in law.
- Select discrepancies that can expose a model's failure.
- Distinguish posterior predictive checking from held-out evaluation and simulation-based calibration.
A model can estimate a parameter precisely while reproducing the data poorly. Posterior predictive checking asks whether data sets generated from the fitted model resemble the observed data in relevant ways. The question is richer than whether the fitted mean is close. It can reveal too little variation, missing extremes, implausible dependence, or incorrect differences between groups. The replicated data are conditional on the fitted model and observed information; discrepancies motivate criticism of that model rather than a declaration that its posterior is universally calibrated.
Replicate the experiment you actually modeled
A posterior predictive draw first samples from its posterior and then samples replicated observations from the sampling distribution at that parameter. For a replication of the original experiment, keep the same design, exposure, or predictors unless their generation is explicitly part of the model. Replicating a new group in a hierarchy may require drawing a new group effect, whereas replicating measurements from an existing group conditions on that group's inferred effect. Those are different questions with different predictive distributions.
The predictive law averages conditional distributions; it is not generally the conditional distribution at an averaged parameter. When the second moments are finite, total predictive variance includes average observation variance plus variance of the conditional observation mean. This separates irreducible sampling noise from parameter uncertainty. Conditional independence can disappear after integration: several future observations sharing one unknown parameter become dependent in the predictive distribution. Retaining a common parameter draw for an entire replicated data set preserves that dependence; independently redrawing the parameter for every observation changes the experiment.
Choose a statistic with something to reveal
A discrepancy should address a feature that matters and that the model is not guaranteed to match. A fitted location parameter often reproduces the sample mean, so checking only that mean may miss heavy tails or clustering. For counts, examine both dispersion and zeros; for time series, examine runs or residual autocorrelation; for grouped data, examine differences at the relevant group level. Plot multiple replicated data sets beside the observations before reducing every check to one scalar, since distinct failures can cancel in an aggregate summary.
A posterior predictive tail probability can summarize how often a replicated statistic exceeds its observed value. Because the observations help fit the posterior and also supply the comparison statistic, these values are not generally uniform under repeated data generation from a fixed model. They are not ordinary significance-test p-values and are not posterior probabilities that the model is true. An extreme value can reveal a mismatch; a moderate value says only that this particular discrepancy did not reveal one. Discrete statistics also introduce ties whose treatment should be stated.
Three checks answer three questions
An in-sample predictive check diagnoses whether the fitted model can reproduce features of the data used to fit it. Held-out prediction instead evaluates predictions for observations withheld during fitting, respecting any grouping or time ordering needed to avoid leakage. A model can pass a narrow in-sample check yet predict poorly on a new population. Conversely an unusual observed feature can be scientifically useful even when an overall held-out score is acceptable. Neither comparison replaces examining the assumptions that make the target population relevant.
Simulation-based calibration examines computation under the assumed generative model. Repeatedly draw parameters from the prior, simulate data, fit the model, and compare each generating parameter with its posterior draws using appropriately constructed ranks. Under correct computation and the required sampling conditions those ranks have a known reference behavior. This can detect implementation errors or biased approximation, but it cannot establish that the assumed model describes the real world. Predictive criticism, held-out assessment, and computational calibration complement one another because their conditioning and failure targets differ.
Work it through
Two future trials under a beta posterior
Suppose the fitted posterior is Beta(5,3). Two future trials share its unknown success probability and are conditionally independent. Find the predictive probabilities for zero, one, and two successes.
The probability of two successes is the posterior second moment: 5 times 6 divided by 8 times 9, equal to 5/12. The probability of zero is the second moment of the failure probability: 3 times 4 divided by 8 times 9, equal to 1/6.
The remaining probability for exactly one success is 1−5/12−1/6=5/12. Equivalently it is twice the posterior expectation of theta times (1−theta). All three masses are nonnegative and sum to one.
The predictive mean is 0 times 1/6 plus 1 times 5/12 plus 2 times 5/12, or 5/4. The second moment is 5/12+4 times 5/12=25/12, so variance is 25/12−25/16=25/48.
The probabilities are (1/6,5/12,5/12). Predictive variance 25/48 exceeds the plug-in Binomial(2,5/8) variance 15/32 because the future trials share uncertain theta.
The living notebook
Explore the model
Interactive lab · probability
Expose what a plug-in check misses
Pause and Reset, then set both controls to p=0.50 and n=2; predict masses (0.25,0.50,0.25). Reset and set p=0.60 and n=2; predict masses (0.16,0.48,0.36). Compare those exact fixed-p laws with the beta-mixture calculation above. The instrument displays binomials, not posterior predictive replications or random fitted models.
- Mean · np
- 5
- Variance · np(1−p)
- 2.5
- Total probability
- 1
These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forMatching a predictive mean does not guarantee matching its dispersion or joint dependence.
Pause & reason
Check your understanding
Your turn
Try it yourself
A Poisson count has a rate whose posterior is Gamma(shape 4, rate 2). For one new unit-exposure count, find the predictive mean, variance, and probability of zero.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Use total variance and average exp(−lambda) under the gamma posterior; its rate convention matters.
Compare with the solution
The posterior mean rate is 4/2=2 and its variance is 4/2²=1. Conditional Poisson mean and variance both equal lambda, so the predictive mean is 2 and variance is 2+1=3. Integrating exp(−lambda) against the shape-rate gamma density changes its rate from 2 to 3; the integral is (2/3)^4=16/81. A plug-in Poisson(2) would have variance 2 and zero probability exp(−2), so matching the mean does not match the predictive law.
Keep the idea
Take it with you
- Predictive replication must preserve the modeled sharing of unknown parameters.
- A check can miss a failure when its chosen summary cannot reveal it.
- Predictive adequacy, held-out performance, and computational calibration are distinct.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.