BRAGA

02 Writing02-02 Notes02-02-477

Bayes Factor (Model Comparison)

Published 16 Apr 20263 min read
Contents
  1. 01Deep Breakdown
  2. 02Flowchart
B12=p(D∣M1)p(D∣M2)B_{12} = \dfrac{p(D \mid M_1)}{p(D \mid M_2)}
(1)

We are working on the Bayes Factor for Bayesian model comparison, with canonical formula B12=p(D∣M1)p(D∣M2)B_{12} = \dfrac{p(D \mid M_1)}{p(D \mid M_2)}, where p(D∣Mj)p(D \mid M_j) is the marginal likelihood of model MjM_j for dataset DD. The domain is Bayesian model comparison under models with well-defined priors and likelihoods. If B12>1B_{12} > 1, the data favors M1M_1 over M2M_2; if B12<1B_{12} < 1, the data favors M2M_2. This connects directly to posterior odds and, asymptotically, to BIC-style approximations to log marginal likelihood.

Deep Breakdown

The Bayes Factor is a core tool for comparing two probabilistic models using observed data. Instead of asking only which model fits the sample best at its best parameter value, the Bayes Factor asks which model gives a better overall explanation of the data after averaging over that model’s parameter uncertainty. For two models M1M_1 and M2M_2, the Bayes Factor is:

B12=p(D∣M1)p(D∣M2)B_{12} = \frac{p(D \mid M_1)}{p(D \mid M_2)}
(2)

Here:

  • DD is the observed dataset,
  • M1M_1 and M2M_2 are competing models,
  • p(D∣Mj)p(D \mid M_j) is the marginal likelihood of model MjM_j.

The marginal likelihood is not just the likelihood evaluated at one parameter estimate.

It is:

p(D∣Mj)=∫p(D∣θj,Mj) p(θj∣Mj) dθjp(D \mid M_j) = \int p(D \mid \theta_j, M_j)\, p(\theta_j \mid M_j)\, d\theta_j
(3)

This means: 1. take the likelihood of the data under parameter value θj\theta_j, 2. weight it by the prior probability of that parameter value, 3. integrate over all possible parameter values.

This is important because it automatically balances:

  • fit to the data, and
  • model complexity. A model with many flexible parameters may fit some settings extremely well, but if it spreads probability mass across too many possibilities, its average support for the observed data may be lower.

That is one reason the Bayes Factor is often described as an automatic Occam’s razor mechanism.

Why it matters in DA/DS:

  • Model selection: compare different predictive or explanatory models.
  • Hypothesis comparison: compare null vs alternative models.
  • Evidence quantification: give a direct evidence ratio, not just a p-value.
  • Complexity penalty: reward models that explain data well without needing too much flexibility.
  • Decision-making: useful in forecasting, A/B testing, attribution, risk modeling, and scientific inference.

The Bayes Factor itself compares only the evidence from the data. To get posterior odds between models, you multiply by prior odds:

p(M1∣D)p(M2∣D)=B12⋅p(M1)p(M2)\frac{p(M_1 \mid D)}{p(M_2 \mid D)} = B_{12} \cdot \frac{p(M_1)}{p(M_2)}
(4)

So:

  • Bayes Factor = what the data contributes,
  • prior odds = what you believed before seeing the data,
  • posterior odds = what you believe after combining both. A frequent practical issue is that exact marginal likelihoods can be hard to compute.

In large-sample settings, criteria like BIC are used as approximations because:

BIC≈−2log⁡p(D∣M)+constant\mathrm{BIC} \approx -2 \log p(D \mid M) + \text{constant}
(5)

So differences in BIC can approximate differences in log marginal likelihood.

Flowchart

Start withobserveddataset DChoose twocompetingmodels M_1 andM_2Specifylikelihood andprior for eachmodelComputemarginallikelihood p(D |M_1)Computemarginallikelihood p(D |M_2)Form BayesFactor B_12 =p(D | M_1) / p(D| M_2)Interpretevidence fromdataCombine withprior odds to getposterior oddsUse for modelselection orhypothesiscomparison

#machine-learning#machine-learning-foundations#empirical-risk-and-its-minimisation

Keyboard shortcuts

Single keys, ignored while typing in a field or with Cmd, Ctrl or Alt held.

0
Home
1 2 3 4
Work, Writing, Tools, About
j / k
Next / previous section on this page
n / p
Next / previous project or essay
u
Up one level
l
Deutsch
t
Light or dark theme
?
This list
Esc
Close