advanced35 min studyLesson 266 in Mathematics

Marginal likelihood and Bayes factors

Compare fully specified predictive models while retaining normalizers, prior scales, and model odds.

On this page

What you’ll understand

  • Integrate a proper prior to calculate a marginal likelihood.
  • Convert a Bayes factor and prior model odds into posterior odds.
  • Explain why improper prior constants and arbitrary likelihood scaling can invalidate comparison.

Two models can fit the observations equally well at their best parameter values but assign very different predictive probability to those observations before fitting. A marginal likelihood averages a model's likelihood over its parameter prior, so it rewards neither fit nor simplicity in isolation. A Bayes factor compares these model-level predictive densities. Its interpretation depends on the complete prior specification and the observation being compared. Treating it as a parameter-free score hides choices that can strongly affect the resulting evidence.

Average likelihood within each model

For model MkM_k, define a sampling density on a common observed-data space and a proper parameter prior. Integrate their product to obtain mk(y)m_k(y). Distinct models may have different parameter dimensions, but their marginal densities must refer to the same observed event or density convention. A model with no free parameters simply supplies its sampling density. Integration averages over the prior rather than taking the maximum; a parameter region with excellent fit may contribute little if it receives very little prior mass.

Use positive finite marginal densities when forming a finite Bayes factor. Continuous-data densities can exceed one and carry units, while a ratio between densities for the same observations and base measure is dimensionless. A common transformation of the data introduces a common Jacobian that cancels; unrelated density conventions do not. For a binomial experiment, the probability of an ordered sequence differs from the probability of its success count. A combinatorial factor cancels only if it is genuinely the same factor in both models.

mk(y)=∫p(y∣θk,Mk)πk(θk) dθk,B10(y)=m1(y)m0(y)m_k(y)=\int p(y\mid\theta_k,M_k)\pi_k(\theta_k)\,d\theta_k,\qquad B_{10}(y)=\frac{m_1(y)}{m_0(y)}
Each prior must be normalized for the ordinary marginal likelihood, and the likelihoods must describe the same observed data.↔ Scroll wide equations horizontally.

Evidence multiplies odds

Assign prior probabilities to the candidate models separately from their within-model parameter priors. Bayes' rule then shows that posterior model odds equal prior model odds times the Bayes factor. A factor greater than one favors the numerator model relative to the denominator, but does not specify its posterior probability without prior model odds. With more than two candidate models, normalize all prior-probability times marginal-likelihood products. The resulting probabilities are conditional on the candidate list; omitted possibilities do not receive probability automatically.

Prior scale can have a large effect because the marginal likelihood averages over all prior predictions, including predictions far from the observed data. Widening a proper prior may reduce this average even when the posterior near a well-supported mode barely changes. This is a reason to examine predictive implications and sensitivity, rather than to search for a universal diffuse prior. An improper prior has an arbitrary multiplicative constant, which generally remains in its marginal likelihood. Proper posterior estimation alone does not make an ordinary cross-model Bayes factor well-defined.

Pr⁡(M1∣y)Pr⁡(M0∣y)=B10(y)Pr⁡(M1)Pr⁡(M0)\frac{\Pr(M_1\mid y)}{\Pr(M_0\mid y)}=B_{10}(y)\frac{\Pr(M_1)}{\Pr(M_0)}
Bayes factors are likelihood ratios at the model level; posterior odds additionally require prior model probabilities.↔ Scroll wide equations horizontally.

Computation and interpretation are separate

Terms constant in a model's parameter can be dropped for some posterior computations but cannot generally be dropped for marginal likelihoods. The same caution applies to normalized priors: their constants depend on prior scales. Numerical integration, specialized bridge methods, or carefully validated importance sampling may estimate marginal likelihoods. A stable-looking posterior chain is insufficient evidence that such an estimate is accurate, since marginal likelihood methods can depend strongly on regions that ordinary posterior summaries barely inspect.

A Bayes factor is not a posterior probability that a scientific theory is true, nor a measure of future predictive quality independent of the chosen prior. Predictive evaluation on held-out data answers a different conditioning question and may be preferable for a specific forecasting objective. For scientific comparison, report the data model, prior specification, direction of the ratio, prior odds if posterior probabilities are quoted, and sensitivity to reasonable alternatives. If both models fail predictive checks, strong relative evidence can still select an inadequate model.

A fixed coin versus an uncertain coin

Observe one ordered sequence of three Bernoulli trials with two successes and one failure. Model M0 fixes theta=1/2; model M1 gives theta a uniform Beta(1,1) prior. Compute B10 and posterior model probability when prior odds M1:M0 are 3:1.

  1. For the ordered sequence under M0, the likelihood is (1/2) cubed, or 1/8. Under M1 integrate theta squared times (1−theta) from zero to one, obtaining 1/3−1/4=1/12.

  2. The Bayes factor favoring M1 relative to M0 is (1/12)/(1/8)=2/3. The data favor the fixed model in this comparison, despite the alternative allowing more possible parameter values.

  3. Multiply prior odds 3 by 2/3 to obtain posterior odds 2. Converting odds 2:1 gives posterior probability 2/3 for M1. If the observation were the count rather than this ordered sequence, both marginal likelihoods would be multiplied by three and the ratio would remain 2/3.

The result

B10=2/3, yet M1 has posterior probability 2/3 because its prior odds were 3:1. Evidence and posterior belief need not point to the same favorite.

Explore the model

Interactive lab

Interactive lab · probability

Count likelihoods at specified parameters

Pause and Reset, then set both controls to p=0.50 and n=3; predict probability 3/8 for count two. Reset and set p=0.80 and n=3; predict 3×0.80²×0.20=0.384. These bars evaluate conditional count probabilities. The marginal likelihood requires integrating the relevant bar over a specified prior; the instrument does not perform that integration.

Count likelihoods at specified parametersThese are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Current readings: Mean · np: 5; Variance · np(1−p): 2.5; Total probability: 1. All parameters are adjustable with the labeled controls below.03581000.070.150.220.3Successes kP(X = k)k = 0 · P = 9.77e-4
Exact probabilityHighlighted outcomeMean np
Mean · np
5
Variance · np(1−p)
2.5
Total probability
1
t = 0 s

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 forA likelihood at a chosen parameter is one ingredient of a marginal likelihood, not a substitute for its prior average.

Check your understanding

A model has a proper posterior under a within-model improper prior. What follows for an ordinary Bayes factor against another model?

Try it yourself

For one observed Bernoulli success, compare M0 with theta=1/2 against M1 with a Beta(2,1) prior. With equal prior model probabilities, find B10 and the posterior probability of M1.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

For one success the marginal likelihood is the prior mean success probability. Check that the beta prior is normalized.

Compare with the solution

The Beta(2,1) density is 2theta on [0,1], so M1 assigns success probability the integral of 2theta², equal to 2/3. M0 assigns probability 1/2. Thus B10=(2/3)/(1/2)=4/3. Equal prior odds leave posterior odds 4:3, so the posterior probability of M1 is 4/7. The event being compared is the same single success in both models, and both within-model data distributions are normalized.

Take it with you

  • Marginal likelihood integrates over a normalized within-model prior.
  • Bayes factors multiply prior model odds rather than replacing them.
  • Dropping constants or using improper priors can invalidate model comparison.

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.