Bayesian Model Selection
Marginal likelihood, Bayes factors, BIC and Occam’s razor.
A more flexible model always fits the training data at least as well, so fit alone cannot choose between models. The Bayesian answer, the marginal likelihood, penalizes flexibility automatically: a model that could have explained anything gets little credit for explaining what happened. This lesson derives that Occam's razor, its BIC approximation, its famous paradox, and the predictive criteria that compete with it.
What you’ll learn
- Compare models with the marginal likelihood and Bayes factors, and compute both for a coin.
- Derive the Laplace approximation to the evidence and the BIC, and identify the Occam factor.
- Contrast BIC with AIC: consistency versus predictive efficiency, and why no criterion has both.
- Explain Lindley's paradox and the prior sensitivity of Bayes factors.
- Estimate predictive accuracy with PSIS-LOO and WAIC, and say when they and the evidence disagree.
The evidence compares models
Treat the model itself as unknown. Bayes' rule over models needs each model's marginal likelihood, or evidence: the probability of the data averaged over that model's prior.
The Bayes factor is the factor by which the data change the odds between two models. By the chain rule, : the evidence is the model's cumulative score at predicting each observation from the ones before it, starting from no data at all. Averaged over all orderings, this equals exhaustive leave--out cross-validation with the log predictive score, summed over every (Fong & Holmes, 2020).
| Evidence for | ||
|---|---|---|
| 0 to ½ | 1 to 3.2 | not worth more than a bare mention |
| ½ to 1 | 3.2 to 10 | substantial |
| 1 to 2 | 10 to 100 | strong |
| above 2 | above 100 | decisive |
Model : the coin is fair. Model : its is unknown, uniform on . You see 60 heads in 100 flips, which a likelihood-ratio test rejects at the 5% level. What is the Bayes factor in favor of ?
Show the answer
0.91
, so , while . So : the data slightly favor the fair coin. With 70 heads instead, , decisive. The next step explains how a better-fitting model can lose.
Occam's razor, automatically
A flexible model spreads its prior predictive probability over many possible datasets, so it can give only a little to each; a rigid model concentrates its probability on few datasets, and wins whenever the data land there. Laplace's method makes this quantitative (MacKay, 2003, chapter 28).
Write , with mode and negative Hessian there. A second-order expansion turns the evidence into a Gaussian integral:
The evidence is the best fit times an Occam factor: in one dimension, with a flat prior of width and posterior width , the factor is , the fraction of the prior's range that survives the data.
For i.i.d. data, with the per-observation information, so . Dropping every term that stays bounded as grows (prior density, , , and the gap between mode and MLE) leaves Schwarz's criterion (Schwarz, 1978):
Check it on the coin. 's best fit is , two nats better than the fair coin's . Its Occam factor is over a prior width of 1, about , or nats. The penalty slightly exceeds the gain:
BIC versus AIC
Two penalized likelihoods dominate practice. The BIC approximates times the log evidence. The AIC (Akaike, 1974),
estimates something else: times the expected log-likelihood of the fitted model on fresh data, correcting the training optimism of nats that a regular model with parameters enjoys. Leave-one-out cross-validation is asymptotically equivalent to AIC (Stone, 1977). Applied to Gaussian mixtures fitted to three well-separated blobs, both criteria pick the right number of components, but with very different margins:
| parameters | best | BIC | AIC | |
|---|---|---|---|---|
| 1 | 5 | 424.3 | 408.8 | |
| 2 | 11 | 229.1 | 194.9 | |
| 3 | 17 | 153.8 | 101.0 | |
| 4 | 23 | 174.5 | 103.0 | |
| 5 | 29 | 194.0 | 103.9 | |
| 6 | 35 | 215.2 | 106.5 |
Two nested regular models differ by one parameter, and the smaller one is true. With a large sample, how often does AIC choose the larger model?
Show the answer
15.7 %
AIC prefers the larger model when the likelihood-ratio statistic exceeds 2, its extra penalty. Under the smaller model that statistic is asymptotically (Wilks), and , whatever the sample size. BIC's threshold grows: is 3.2% at and 0.24% at , tending to zero.
Lindley's paradox and prior sensitivity
Let , and compare with . Under , integrating out gives . With and :
Hold the evidence fixed in the frequentist sense, (a two-sided -value of 0.05), and let grow. The exponential factor tends to while grows without bound:
So the same "significant at 5%" result is evidence for the null once exceeds about 42, and overwhelming evidence for it in huge samples (Lindley, 1957). Letting at fixed does the same: a vaguer alternative spreads its prior over ever more implausible effects and loses (Bartlett, 1957).
The paradox is not an error on either side. A -value asks how surprising the data are under ; a Bayes factor asks which hypothesis predicted them better, and a diffuse predicts poorly. But it exposes the prior sensitivity of Bayes factors: posteriors within a model forget the prior as grows, while the evidence keeps depending on its scale, roughly through the Occam factor . An improper prior, , makes the Bayes factor undefined.
Remedies calibrate the prior instead of making it vague: Zellner-type -priors and their mixtures for regression (Liang, Paulo, Molina, Clyde & Berger, 2008), and intrinsic or fractional Bayes factors, which spend part of the data turning an improper prior into a proper one (Berger & Pericchi, 1996; O'Hagan, 1995).
In a very large trial, a treatment effect has (). The alternative is a diffuse prior on the effect. What can the Bayes factor do as grows with fixed?
- It always favors the alternative, since
- It converges to the likelihood ratio at the MLE
- It is unaffected by , because priors wash out
- It increasingly favors the null: the observed effect shrinks toward 0, which the point null predicts far better than a diffuse alternative
Show the answer
D. It increasingly favors the null: the observed effect shrinks toward 0, which the point null predicts far better than a diffuse alternative
With fixed the observed effect is of order , tiny compared with the alternative's spread . grows like , so eventually the null wins however small is.
Predictive alternatives: PSIS-LOO and WAIC
If the goal is prediction, score each model by its expected log predictive density on new data, , and estimate it without refitting. Leave-one-out uses , and a single set of posterior draws suffices, because
an importance-sampling identity with ratios . Raw ratios can have infinite variance. Pareto-smoothed importance sampling fits a generalized Pareto distribution to the largest ratios and replaces them by its quantiles (Vehtari, Gelman & Gabry, 2017); the fitted shape is a diagnostic, and the estimate is considered reliable when (Vehtari et al., 2024). WAIC instead subtracts a variance penalty from the log pointwise predictive density:
Watanabe (2010) proved that WAIC and Bayesian leave-one-out cross-validation are asymptotically equivalent, also for singular models such as mixtures and neural networks, where AIC and BIC lose their justification.
| Criterion | What it estimates | Strengths | Weaknesses |
|---|---|---|---|
| Evidence, Bayes factor | probability of the data under the prior predictive | coherent model probabilities; consistent when a candidate is true | prior-scale sensitive; undefined with improper priors; hard to compute |
| BIC | evidence, up to | one fit; consistent | ignores the prior; invalid for singular models |
| AIC | expected out-of-sample deviance | one fit; efficient for prediction | regular models only; ignores posterior uncertainty |
| PSIS-LOO, WAIC | expected log predictive density of the Bayesian predictive | uses posterior draws; diagnostics (); valid for singular models (WAIC) | needs a good posterior sample; LOO assumes exchangeable data |
Key takeaways
- The evidence averages the likelihood over the prior; Bayes factors multiply prior model odds into posterior odds, and the log evidence is a cumulative one-step-ahead prediction score.
- Laplace's method gives evidence ≈ best fit × Occam factor; dropping bounded terms gives . A model that fits slightly better can lose, as 60 heads in 100 () shows.
- BIC () is consistent when a candidate is true; AIC () targets out-of-sample deviance and overfits nested models with probability about 0.157. By Yang's theorem no criterion is both consistent and minimax-rate optimal.
- Lindley's paradox: at fixed -value, the Bayes factor for a point null grows like . Bayes factors stay sensitive to the prior's scale, so default priors must be calibrated, not merely vague.
- PSIS-LOO and WAIC estimate predictive accuracy from posterior draws, with a diagnostic for LOO and validity for singular models (Watanabe); in the M-open setting, stacking often beats selecting a single model.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
Model contains as a special case, so its maximized likelihood is at least as high. How can the evidence still favor ?
- It cannot: the evidence always favors the model with the higher maximized likelihood
- Because the evidence counts parameters directly, subtracting one unit per parameter
- Because 's prior spreads over many parameter values that fit the data badly, and the evidence averages the likelihood over that prior
- Only if the prior of is improper
Show the answer
C. Because 's prior spreads over many parameter values that fit the data badly, and the evidence averages the likelihood over that prior
The evidence is the prior-weighted average of the likelihood, not its maximum. Laplace's method splits it into the best fit times an Occam factor, roughly the fraction of prior volume consistent with the data. A small fit improvement does not pay for a large loss of prior volume.
The true model is one of several fixed-dimensional candidates. As , which statement is correct?
- BIC selects the true model with probability tending to one; AIC keeps a fixed positive probability of choosing a larger model
- AIC selects the true model with probability tending to one; BIC underfits
- Both are consistent, since both penalize parameters
- Neither is consistent, since penalties are constants
Show the answer
A. BIC selects the true model with probability tending to one; AIC keeps a fixed positive probability of choosing a larger model
BIC's penalty grows with , so the chance that noise buys an extra parameter vanishes. AIC's penalty does not grow: with one extra parameter it overfits with probability forever. In exchange, AIC predicts better when no candidate is exactly true (Yang, 2005).
What do PSIS-LOO and WAIC estimate?
- The posterior probability that each model is true
- The marginal likelihood, more cheaply than the Laplace approximation
- The expected log predictive density of the model's posterior predictive on new data
- The number of parameters in the model
Show the answer
C. The expected log predictive density of the model's posterior predictive on new data
Both estimate out-of-sample predictive accuracy from one set of posterior draws: leave-one-out by Pareto-smoothed importance weights, WAIC by penalizing the in-sample log predictive density with the posterior variance of the log-likelihood. They answer "which model predicts better?", not "which model is true?".
Further reading
- R. E. Kass & A. E. Raftery, "Bayes factors," Journal of the American Statistical Association 90(430), 773–795 (1995).
- G. Schwarz, "Estimating the dimension of a model," Annals of Statistics 6(2), 461–464 (1978).
- D. J. C. MacKay, Information Theory, Inference, and Learning Algorithms (Cambridge University Press, 2003), chapter 28.
- A. Vehtari, A. Gelman & J. Gabry, "Practical Bayesian model evaluation using leave-one-out cross-validation and WAIC," Statistics and Computing 27(5), 1413–1432 (2017).
- S. Watanabe, "Asymptotic equivalence of Bayes cross validation and widely applicable information criterion in singular learning theory," Journal of Machine Learning Research 11, 3571–3594 (2010).