Search

Search papers and lessons

Bayesian Information Criterion (BIC)

Level 3 · 11 min read

The Bayesian information criterion scores a fitted model by its best fit minus a penalty of ln n per parameter; the lowest score marks the model most likely to have produced the data.

On this page

  • Colour = topic mix
  • Probability
  • Discrete math
  • Inference
  • Learning basics
  • Calculus
  • Losses & regularization
  • ReadReady to readNot yet

TL;DR

The Bayesian information criterion (BIC) is a score for comparing models fitted to the same data. It takes the model's best log-likelihood, which can only improve when you add parameters, and subtracts a penalty of ln⁡n\ln n for each parameter, where nn is the number of observations. The lowest score marks the model with the highest approximate posterior probability, provided every candidate started equally likely. It makes extra parameters earn their place.

Builds on: Model Selection, Marginal Likelihood, Maximum Likelihood Estimation · Leads to: Bayesian Model Averaging, Bayes Factor

Where it's used

Choosing how flexible a regression should be. Suppose you predict house prices from floor area for 200 houses. Your candidates are a straight line, a curve with a squared term, and a curve with a cubic term. Each added term lowers the training error, so training error alone always picks the cubic. BIC scores all three on the same 200 houses and says whether the extra terms pay for themselves. This is the everyday use in Linear Regression work.

Deciding how many groups a mixture has. A Mixture Model of customer spending must be told how many groups to fit. Fitting one group, two groups, or three groups each gives a different likelihood, and more groups always fit the training data at least as well. BIC compares the fits and charges each extra group its share of parameters, so the analyst does not have to guess the number from the histogram.

Approximating model averaging. Bayesian model averaging weights each candidate by its marginal likelihood, which is often an integral with no closed form. BIC gives a quick approximation that is good enough to compute those weights, as used in Bayesian Model Averaging.

How it works

Take one tiny instance from start to finish. There are ten observations, so n=10n = 10. Model A has no free parameters: it predicts the same thing whatever the data look like. Model B has one free parameter that is fitted to the data. Both models are fitted by Maximum Likelihood Estimation.

  1. Fit each model and record its best log-likelihood. For A there is nothing to fit, and its best log-likelihood is −10.0-10.0. For B the fit gives −8.0-8.0. Check: B fits better, as it must, because it has the extra freedom.
  2. Count the free parameters. dA=0d_A = 0 and dB=1d_B = 1. Check: both models are scored on the same ten observations, so the comparison is fair.
  3. Compute the penalty per parameter. ln⁡10≈2.303\ln 10 \approx 2.303. Check: this is a fixed number for the whole comparison, because nn is the same for both models.
  4. Multiply the penalty by the parameter count. A pays 0×2.303=00 \times 2.303 = 0. B pays 1×2.303=2.3031 \times 2.303 = 2.303. Check: a model with no parameters pays nothing.
  5. Turn the fit into a cost and add the penalty. BIC is the penalty minus twice the log-likelihood. For A: 0+20.0=20.00 + 20.0 = 20.0. For B: 2.303+16.0=18.3032.303 + 16.0 = 18.303. Check: −2×(−10.0)=20.0-2 \times (-10.0) = 20.0 and −2×(−8.0)=16.0-2 \times (-8.0) = 16.0.
  6. Pick the lowest score. 18.303<20.018.303 \lt 20.0, so B wins. The extra parameter improved −2L^-2\hat L by 4 units and cost 2.303, so it paid its way. Had B's log-likelihood been −9.5-9.5, its score would be 2.303+19.0=21.3032.303 + 19.0 = 21.303, which loses to A.

The steps can be drawn as a flow:

flowchart LR
  A[Fit each model by maximum likelihood] --> B[Record the best log-likelihood]
  B --> C[Count the free parameters d]
  C --> D["Score = d ln n minus 2 times log-likelihood"]
  D --> E[Pick the lowest score]

The penalty per parameter is what separates BIC from its close cousin AIC. The plot shows how the two penalties grow with the sample size nn.

20406080100012345sample size npenalty per parameter
  • BIC: ln n
  • AIC: 2
The two penalties cross at n = e^2, about 7.4. Beyond that BIC charges more per parameter, and its gap keeps widening.

The math

Definition: Bayesian information criterion

BIC=dln⁡n−2 L^\mathrm{BIC} = d \ln n - 2\,\hat L Here nn is the number of observations, dd is the number of free parameters in the model, ln⁡\ln is the natural logarithm, and L^\hat L is the best log-likelihood the model reaches on the data. Lower is better.

The formula is a direct restatement of the walkthrough. L^\hat L is the value at the maximiser θ^\hat\theta, that is L^=ℓ(θ^)\hat L = \ell(\hat\theta), where ℓ\ell is the log of the likelihood function.

Steps 1 to 3 in symbols

Fitting means finding θ^=arg⁡max⁡θℓ(θ)\hat\theta = \arg\max_\theta \ell(\theta), the parameter value that makes the data most probable. Then L^=ℓ(θ^)\hat L = \ell(\hat\theta). For model A in the walkthrough, L^A=−10.0\hat L_A = -10.0, and dA=0d_A = 0. The penalty term dln⁡nd \ln n needs nn, which is 10 here, and

Steps 4 to 6 in symbols

For model B, dB=1d_B = 1, so the penalty is 1⋅ln⁡10=2.3031 \cdot \ln 10 = 2.303. The score is

BICB=1⋅ln⁡10−2(−8.0)=2.303+16.0=18.303.\mathrm{BIC}_B = 1 \cdot \ln 10 - 2(-8.0) = 2.303 + 16.0 = 18.303.

For A, BICA=0⋅ln⁡10−2(−10.0)=20.0\mathrm{BIC}_A = 0 \cdot \ln 10 - 2(-10.0) = 20.0. The rule is to pick arg⁡min⁡kBICk\arg\min_k \mathrm{BIC}_k, which is B.

Where the formula comes from

BIC is an approximation to the marginal likelihood, the probability of the data averaged over the model's prior on its parameters:

P(D∣M)=∫P(D∣θ,M) π(θ) dθ.P(D \mid M) = \int P(D \mid \theta, M)\, \pi(\theta)\, d\theta.

Here π(θ)\pi(\theta) is the prior density. The integral is hard to evaluate. The Laplace approximation replaces the integrand with a Gaussian bump centred on its peak, at θ^\hat\theta. The bump gets narrower as nn grows, and its volume depends on dd and on ln⁡n\ln n. Keeping only the terms that grow with nn gives

log⁡P(D∣M)≈L^−d2ln⁡n.\log P(D \mid M) \approx \hat L - \frac{d}{2}\ln n.

Multiplying by −2-2 gives −2log⁡P(D∣M)≈BIC-2\log P(D \mid M) \approx \mathrm{BIC}. The dropped terms do not grow with nn, so they matter less and less as data accumulate. This is why the approximation is good for large samples and rough for small ones.

If the candidates start with equal prior probability, the posterior probability of model kk is proportional to P(D∣Mk)P(D \mid M_k), so it is roughly proportional to exp⁡(−BICk/2)\exp(-\mathrm{BIC}_k / 2). That is how the lowest BIC turns into a probability ranking, and how differences in BIC turn into weights.

Worked examples

Example
Tiny: two models, n = 100

Model A has d=1d = 1 and L^=−50.0\hat L = -50.0. Model B has d=2d = 2 and L^=−49.4\hat L = -49.4. Both are fitted to 100 observations, and ln⁡100≈4.605\ln 100 \approx 4.605.

  1. Penalty for A: 1×4.605=4.6051 \times 4.605 = 4.605. Score: 4.605+100.0=104.6054.605 + 100.0 = 104.605.
  2. Penalty for B: 2×4.605=9.2102 \times 4.605 = 9.210. Score: 9.210+98.8=108.0109.210 + 98.8 = 108.010.
  3. Compare: 104.605<108.010104.605 \lt 108.010, so A has the lower score.

Interpretation: B's extra parameter raised the log-likelihood by only 0.60.6, which is worth 1.21.2 on the −2L^-2\hat L scale. That is less than the 4.6054.605 penalty, so A is kept.

Example
Standard: linear or quadratic, n = 100

A regression of a response on one predictor is compared with and without a squared term. The linear model has d=2d = 2 (intercept and slope) and L^=−150\hat L = -150. The quadratic has d=3d = 3 and L^=−146\hat L = -146. Again n=100n = 100 and ln⁡100≈4.605\ln 100 \approx 4.605.

  1. Linear penalty: 2×4.605=9.2102 \times 4.605 = 9.210. Linear score: 9.210+300.0=309.2109.210 + 300.0 = 309.210.
  2. Quadratic penalty: 3×4.605=13.8153 \times 4.605 = 13.815. Quadratic score: 13.815+292.0=305.81513.815 + 292.0 = 305.815.
  3. Compare: 305.815<309.210305.815 \lt 309.210, so the quadratic wins by 3.3953.395.

Interpretation: the squared term improved −2L^-2\hat L by 8.08.0. The penalty for the one extra parameter is 4.6054.605, and 8.0−4.605=3.3958.0 - 4.605 = 3.395 is the net gain in favour of the quadratic.

Example
Realistic: how many customer groups?

A survey of n=400n = 400 customers records two numbers per customer. A two-dimensional Gaussian group has two means, three covariance entries and one mixing weight, so six parameters. Subtracting one for the weights, which must sum to one, gives d=6K−1d = 6K - 1 for KK groups. Here d=5d = 5, 1111 and 1717 for K=1K = 1, 22 and 33. The best log-likelihoods are −2100-2100, −2030-2030 and −2022-2022. Also ln⁡400≈5.9915\ln 400 \approx 5.9915.

  1. One group: 5×5.9915=29.9585 \times 5.9915 = 29.958. Score: 29.958+4200.0=4229.95829.958 + 4200.0 = 4229.958.
  2. Two groups: 11×5.9915=65.90711 \times 5.9915 = 65.907. Score: 65.907+4060.0=4125.90765.907 + 4060.0 = 4125.907.
  3. Three groups: 17×5.9915=101.85617 \times 5.9915 = 101.856. Score: 101.856+4044.0=4145.856101.856 + 4044.0 = 4145.856.
  4. Lowest score: two groups, at 4125.9074125.907.

Interpretation: going from one group to two improves −2L^-2\hat L by 140140, which far exceeds the extra penalty of about 3636. Going from two groups to three improves it by only 1616, less than the penalty of about 3636, so the third group is not supported.

Try it: suppose the three-group log-likelihood were −2000-2000 instead of −2022-2022. Which KK does BIC choose now? Answer: the three-group score becomes 101.856+4000.0=4101.856101.856 + 4000.0 = 4101.856, which is lower than 4125.9074125.907, so BIC chooses three groups. Measured against the two-group fit, the three-group fit improves −2L^-2\hat L by 6060 (from 40604060 to 40004000), which outweighs the extra penalty of about 3636.

Common mistakes and tradeoffs

It is tempting to think that the model with the lowest BIC is the true model. In fact BIC only ranks the candidates it was given. If the truth is not among them, the winner is merely the least bad. Its approximation is about posterior probability among the candidates, not about truth in the world.

It is tempting to think that a BIC value is a probability. In fact the absolute value means nothing; only differences matter. A difference Δ\Delta between two models corresponds to a ratio of approximate posterior probabilities of exp⁡(Δ/2)\exp(\Delta / 2) under equal priors. A difference of 2 is a ratio of about e≈2.72e \approx 2.72.

It is tempting to compare BIC values across datasets. In fact the comparison is valid only when both models are fitted to the same observations with the same response. Dropping a row with a missing value changes nn, and the scores are no longer comparable.

It is tempting to count parameters loosely. In fact dd must be counted the same way for every model, and the count must include every free parameter that was fitted. Forgetting a variance in one model and including it in another silently favours the model with the smaller count.

Finally, the approximation depends on nn being large compared with dd. With small samples the dropped terms matter, and a held-out check is safer.

SituationBIC is a good choiceUse something else
Large sample, a true structure is among the candidatesYes: BIC tends to find the smaller true model
Prediction is the goal and data are plentifulOften picks too small a modelAIC or held-out error
Very few observationsPenalty approximation is weakCross-Validation
Models are far from the truthApproximations break downHeld-out scoring

History

Gideon Schwarz published the criterion in 1978 in a short paper on estimating the dimension of a model. He derived it as a large-sample approximation to the posterior probability of each model, which is why it carries the Bayesian name. Hirotugu Akaike had proposed a different penalised score in 1974, the AIC, which starts from prediction error instead.

The criterion's appeal was that it turned a judgement about which model to trust into a calculation with a clear penalty. In the 1990s Adrian Raftery and colleagues promoted BIC as a practical approximation to the marginal likelihood, which made it a common shortcut for model averaging.

Recap

  • A fitted model's best log-likelihood always improves when parameters are added, so raw fit cannot choose a model.
  • BIC subtracts a penalty of dln⁡nd \ln n from the fit, scored as dln⁡n−2L^d \ln n - 2\hat L.
  • The penalty comes from a Laplace approximation to the marginal likelihood, and it is accurate for large nn.
  • The lowest BIC is the model with the highest approximate posterior probability, when the candidates start equally likely.
  • Read next: Bayesian Model Averaging for weighting models by BIC, and Bayes Factor for the exact comparison that BIC approximates.

Check yourself

QuestionRecall: what does the BIC penalty per parameter grow with, and what does that mean for large datasets?Show answer

The penalty per parameter is ln⁡n\ln n, which grows with the sample size nn. With more data, each parameter costs more, so BIC increasingly favours simpler models. A model's extra parameters must improve the fit by a larger amount as nn grows.

QuestionComputation: a model has d=4d = 4, L^=−200\hat L = -200, and n=50n = 50. Compute its BIC. Use ln⁡50≈3.912\ln 50 \approx 3.912.Show answer

The penalty is 4×3.912=15.6484 \times 3.912 = 15.648. The fit term is −2×(−200)=400-2 \times (-200) = 400. Adding them gives BIC=15.648+400=415.648\mathrm{BIC} = 15.648 + 400 = 415.648.

QuestionWhy: why can't you pick the best model by comparing training log-likelihoods alone?Show answer

Adding a parameter never lowers the best training log-likelihood, because the larger model contains the smaller one as a special case. So training fit always favours the most flexible model, including one that fits the noise. The penalty is what offsets this bias.

QuestionApplied: two models are fitted to the same 1000 observations. Model X has BIC 500.0 and model Y has BIC 502.0. Which is preferred, and roughly how much more probable is it under equal prior probabilities?Show answer

Model X is preferred, since it has the lower score. The difference is 2.0, so the approximate posterior probability ratio is exp⁡(2.0/2)=e≈2.72\exp(2.0 / 2) = e \approx 2.72. X is roughly 2.7 times as probable as Y, which is a real but modest preference, not a certainty.

Sources