Algorithm Search⌘K

Techniqueadvanced

Bayesian model averaging

Also called BMA.

Average predictions or estimates over a set of models, each weighted by its posterior probability, instead of choosing one model.

Bayesian model averaging (BMA) handles uncertainty about the model in the same way that Bayesian inference handles uncertainty about a parameter: it puts a prior on the models, computes their posterior probabilities from the marginal likelihoods, and averages over them. A prediction or an estimate is the average of the answers of the separate models, each weighted by the posterior probability of its model. In contrast to fitting one selected model, the answer keeps the uncertainty about which model is right. When the set of models and the priors are correct, the averaged predictive distribution has the best expected log score of all predictive distributions.

In plain words

Suppose several models could explain your data, and none is clearly best. If you pick one and report its answer, you act as if you were sure of that model, and your intervals are too narrow. Model averaging asks each model for its answer and mixes the answers. A model that predicted the data well gets a large weight, and a model that predicted them badly gets a small one. The weight also includes how plausible you thought the model was before. The mix is wider than any single answer when the models disagree, which is the honest result.

When it applies

  • A list of models for the same data. Models M1,…,MKM_1, \ldots, M_K, each with a sampling density fk(x∣θk)f_k(x \mid \theta_k) and a proper prior πk(θk)\pi_k(\theta_k), and prior model probabilities P(Mk)P(M_k) that sum to 1.
  • A quantity with the same meaning in every model. The target Δ\Delta is a future observation, a prediction, or a parameter that every model defines in the same way. A regression coefficient whose meaning depends on the other regressors in the model is not such a quantity.
  • Marginal likelihoods that can be computed. Exactly with conjugate priors, approximately with a Laplace approximation, the BIC, bridge sampling or nested sampling, or implicitly with a sampler that moves between models.
  • The true model, or a good approximation to it, is in the list. This is the M-closed case. If no model in the list is close to the truth, the weights still converge to one model, and stacking is a better way to combine predictions.

The template

The holes are the list of models M, the priors P(M_k) and π_k, the method ML that computes or approximates each marginal likelihood, and the quantity Δ.

  1. BAYESIAN-MODEL-AVERAGING(x, M₁, ..., M_K, P, π, ML, Δ)
  2. 1for k ← 1 to K do
  3. 2ℓ_k ← log P(M_k) + log ML(x; f_k, π_k) ▷ log m_k(x) = log ∫ f_k(x | θ_k) π_k(θ_k) dθ_k
  4. 3c ← max_k ℓ_k
  5. 4for k ← 1 to K do
  6. 5w_k ← exp(ℓ_k − c) / Σ_j exp(ℓ_j − c) ▷ P(M_k | x), computed on the log scale
  7. 6p(Δ | x) ← Σ_k w_k · p(Δ | x, M_k) ▷ mixture of the posteriors of Δ under each model
  8. 7return p(Δ | x), (w₁, ..., w_K)

Line L5 is Bayes's theorem on the models, P(Mk∣x)∝P(Mk) mk(x)P(M_k \mid x) \propto P(M_k)\, m_k(x), and the ratio of two weights is the prior odds times the Bayes factor. Line L6 is the law of total probability. From L6, the posterior mean and variance of a real Δ\Delta are

E[Δ∣x]=∑kwk Δ^k,Var[Δ∣x]=∑kwk Var[Δ∣x,Mk]+∑kwk (Δ^k−E[Δ∣x])2,\mathbb{E}[\Delta \mid x] = \sum_k w_k\, \hat\Delta_k, \qquad \mathrm{Var}[\Delta \mid x] = \sum_k w_k\, \mathrm{Var}[\Delta \mid x, M_k] + \sum_k w_k\, \big(\hat\Delta_k - \mathbb{E}[\Delta \mid x]\big)^2,

with Δ^k=E[Δ∣x,Mk]\hat\Delta_k = \mathbb{E}[\Delta \mid x, M_k]. The second sum is the part of the uncertainty that comes from not knowing the model; selecting one model sets it to zero.

Why average: the log score. Let p(Δ∣x)p(\Delta \mid x) be the averaged predictive distribution of a future observation Δ\Delta from L6. For any other predictive density qq,

Ep[log⁡p(Δ∣x)]−Ep[log⁡q(Δ)]=KL(p(⋅∣x) ∥ q)≥0,\mathbb{E}_{p}\big[\log p(\Delta \mid x)\big] - \mathbb{E}_{p}\big[\log q(\Delta)\big] = \mathrm{KL}\big(p(\cdot \mid x)\, \Vert\, q\big) \ge 0,

by Gibbs's inequality: Ep[log⁡(q/p)]≤log⁡Ep[q/p]≤log⁡1=0\mathbb{E}_p[\log(q/p)] \le \log \mathbb{E}_p[q/p] \le \log 1 = 0 by Jensen's inequality, with equality only if q=pq = p almost everywhere. Here Ep\mathbb{E}_p is the expectation under the joint model, that is, with the model, the parameter and Δ\Delta drawn from the prior and the sampling densities given the data xx. So under its own assumptions, the averaged predictive scores at least as well in expectation as the predictive of any single model, and strictly better unless that model has all the weight. This is Madigan and Raftery's argument. It is a statement about expectations under the prior over models; it does not say that BMA wins when the data come from outside the list.

Classic examples

A coin, exact. Toss a coin n=20n = 20 times and see y=15y = 15 heads. M0:θ=1/2M_0: \theta = 1/2 and M1:θ∼M_1: \theta \sim Beta(1,1)(1, 1), with prior odds 1. The Bayes factor is B10=65536/20349B_{10} = 65536/20349, so w1=65536/85885≈0.7631w_1 = 65536/85885 \approx 0.7631. The probability that the next toss is a head is 8/118/11 under M1M_1 (Laplace's rule, (y+1)/(n+2)(y + 1)/(n + 2)) and 1/21/2 under M0M_0, and the average is

w1⋅811+w0⋅12=254483377894≈0.6734.w_1 \cdot \tfrac{8}{11} + w_0 \cdot \tfrac12 = \frac{254483}{377894} \approx 0.6734.

For θ\theta itself, the averaged posterior has mean 0.67340.6734 and variance 0.015920.01592: 0.006580.00658 within the models plus 0.009340.00934 between them. Model M1M_1 alone gives the variance 0.008620.00862, so selecting M1M_1 almost halves the reported variance. If the next toss is drawn from the averaged predictive, its expected log score is −0.6317-0.6317 for the average, −0.6388-0.6388 for M1M_1 alone and −0.6931-0.6931 for M0M_0 alone, in line with the inequality above.

Variable selection in linear regression. With pp candidate regressors there are 2p2^p models. Under Zellner's gg prior on the coefficients, or a mixture of gg priors (Liang et al. 2008), each marginal likelihood is a closed form function of the R2R^2 of the model, so L2 is cheap. Raftery, Madigan and Hoeting (1997) average over the subsets, and the posterior inclusion probability of regressor jj is the sum of wkw_k over the models that contain it. A spike-and-slab prior on the coefficients of one Bayesian linear regression is the same thing written as one model: its posterior is the model average.

Model composition by Markov chain (MC³). When 2p2^p is too large to list, Madigan and York (1995) run a Metropolis-Hastings chain on the models. A proposal adds or removes one regressor or edge, and the move from MM to M′M' is accepted with probability min⁡(1,P(M′)m(M′)/(P(M)m(M)))\min\big(1, P(M')m(M') / (P(M)m(M))\big). The visit frequencies estimate the wkw_k. When the marginal likelihoods have no closed form, reversible jump MCMC moves between models and parameters at once.

BIC weights. If each log⁡mk\log m_k is replaced by −12BICk-\tfrac12 \mathrm{BIC}_k, the weights become wk∝P(Mk) e−BICk/2w_k \propto P(M_k)\, e^{-\mathrm{BIC}_k/2}. This is a large-sample approximation to BMA that ignores the priors πk\pi_k. Weights e−AICk/2e^{-\mathrm{AIC}_k/2} from the Akaike information criterion look similar but aim at the predictive Kullback-Leibler risk, not at posterior model probabilities, and they are not BMA.

Variations

  • Occam's window. Madigan and Raftery (1994) drop the models whose posterior probability is below a fraction of the best one, and the models that have a simpler submodel with higher probability. The average is over the much smaller set that remains.
  • Stacking. Stacking chooses the weights that maximize the leave-one-out log score of the mixture, with the leave-one-out densities from PSIS-LOO. Yao et al. (2018) show that it predicts better than BMA when no model in the list is true. Pseudo-BMA uses weights proportional to exp⁡(elpd^k)\exp(\widehat{\mathrm{elpd}}_k) instead.
  • Median probability model. If one model must be reported, the model with the regressors whose inclusion probability is at least 1/21/2 is optimal for prediction under squared error in some normal linear models (Barbieri and Berger, 2004).
  • Averaging inside one model. A continuous mixture over a model index, such as a prior on the degree of a polynomial or on the number of components of a mixture, is BMA over an infinite list.

Pitfalls

  • Prior sensitivity of the weights. The marginal likelihoods depend on how diffuse the priors πk\pi_k are, and they do not forget them as nn grows. A very wide prior on the extra parameters of a model drives its weight to 0, as the Lindley paradox shows. Improper priors give undefined weights.
  • The model prior is not neutral. A uniform prior on 2p2^p regression models puts most of its mass on models with about p/2p/2 regressors. A prior on the model size, such as a beta-binomial prior, gives a multiplicity correction (Scott and Berger, 2010).
  • Weights collapse. As nn grows, the weights concentrate on one model, even when no model is true. Then BMA is model selection with extra steps, and it does not express that the models are all wrong.
  • Averaging quantities that differ between models. The coefficient of a regressor in a model with a correlated second regressor is not the same quantity as its coefficient in a model without it. Average predictions, or define Δ\Delta so that it has one meaning.
  • Bad marginal likelihood estimates. The harmonic mean of the likelihood over posterior draws has infinite variance in common cases. Errors of a few units in log⁡mk\log m_k change the weights by large factors.

Exercises

  1. Prove the variance decomposition after the template from the law of total variance.
  2. In the coin example, compute the averaged predictive probability that the next two tosses are both heads, and check that it is not the square of 0.67340.6734.
  3. Show that for two models with prior odds 1, the weight of M1M_1 is B10/(1+B10)B_{10}/(1 + B_{10}), and compute it for B10=3B_{10} = 3, 1010 and 100100.
  4. Write the MC³ acceptance probability for a proposal that adds one of the p−∣M∣p - \lvert M\rvert absent regressors or removes one of the ∣M∣\lvert M\rvert present ones with probability 1/21/2 each, chosen uniformly. Show that the proposal is not symmetric in general and correct the acceptance probability.
  5. Let the data come from N(μ,4)N(\mu, 4) while M0:x∼N(0,1)M_0: x \sim N(0, 1) and M1:x∼N(μ,1)M_1: x \sim N(\mu, 1) with μ∼N(0,1)\mu \sim N(0, 1). Argue that the weight of M1M_1 goes to 1 when μ≠0\mu \ne 0, and explain why the averaged predictive is still too narrow.

References

  1. Jennifer A. Hoeting, David Madigan, Adrian E. Raftery and Chris T. Volinsky, Bayesian model averaging: a tutorial, Statistical Science 14(4), 1999, the definition, the computation by Occam's window and MC³, and the predictive performance (general locator)
  2. David Madigan and Jeremy York, Bayesian graphical models for discrete data, International Statistical Review 63(2), 1995, the Markov chain Monte Carlo model composition (MC³) sampler on the space of models (general locator)
  3. Madigan and Raftery 1994, Occam's window and the log score argument for averaging (general locator)
  4. Raftery, Madigan and Hoeting 1997, model averaging over subsets of regressors (general locator)
  5. Liang, Paulo, Molina, Clyde and Berger 2008, closed form marginal likelihoods for regression models under g priors (general locator)
  6. Yao, Vehtari, Simpson and Gelman 2018, stacking of predictive distributions and its comparison with model averaging when no model is true (general locator)
  7. Barbieri and Berger 2004, the median probability model (general locator)
  8. Scott and Berger 2010, priors on the model size and the multiplicity correction they give (general locator)

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • three classic examples