Let M1,…,MKM_1,\ldots,M_K be candidate models for the data x‾,\underline{x}, where model MkM_k has parameter θk∈Θk,\theta_k\in\Theta_k, likelihood f(x‾∣θk,Mk)f\left(\underline{x}\mid\theta_k,M_k\right) and prior π(θk∣Mk).\pi\left(\theta_k\mid M_k\right). Model uncertainty is uncertainty about which model generated the data, and Bayesian inference treats it like any other uncertainty by placing a prior distribution P(Mk)\mathbb{P}\left(M_k\right) over the models, with ∑k=1KP(Mk)=1.\sum_{k=1}^K\mathbb{P}\left(M_k\right)=1. The marginal likelihood of a model is the probability it assigns to the observed data after integrating out its parameters,

f(x‾∣Mk)=∫Θkf(x‾∣θk,Mk)π(θk∣Mk)dθk,f\left(\underline{x}\mid M_k\right)=\int_{\Theta_k}f\left(\underline{x}\mid\theta_k,M_k\right)\pi\left(\theta_k\mid M_k\right)d\theta_k,

and the posterior model probability follows from Bayes’ theorem.

P(Mk∣x‾)=f(x‾∣Mk)P(Mk)∑j=1Kf(x‾∣Mj)P(Mj)\mathbb{P}\left(M_k\mid\underline{x}\right)=\frac{f\left(\underline{x}\mid M_k\right)\mathbb{P}\left(M_k\right)}{\sum_{j=1}^K f\left(\underline{x}\mid M_j\right)\mathbb{P}\left(M_j\right)}

The Bayes factor in favour of model M1M_1 over model M2M_2 is the ratio of their marginal likelihoods,

B12:=f(x‾∣M1)f(x‾∣M2)=P(M1∣x‾)/P(M2∣x‾)P(M1)/P(M2),B_{12}:=\frac{f\left(\underline{x}\mid M_1\right)}{f\left(\underline{x}\mid M_2\right)}=\frac{\mathbb{P}\left(M_1\mid\underline{x}\right)/\mathbb{P}\left(M_2\mid\underline{x}\right)}{\mathbb{P}\left(M_1\right)/\mathbb{P}\left(M_2\right)},

which is the factor by which the data update the prior odds of the two models into the posterior odds and so measures the evidence the data provide for one model over the other independently of the prior model probabilities. A Bayes factor of 11 is no evidence, and by convention values of B12B_{12} above about 3,3, 1010 and 100100 are read as positive, strong and decisive evidence for M1.M_1. For two simple hypotheses the Bayes factor is the likelihood ratio, and a simple null hypothesis H0:θ=θ0H_0:\theta=\theta_0 is tested against H1:θ≠θ0H_1:\theta\neq\theta_0 by comparing the model with θ\theta fixed at θ0\theta_0 to the model with a prior on θ.\theta.

The marginal likelihood is the prior predictive density of the observed data, so it rewards a model for predicting the data well before seeing them. A model with more parameters or a more diffuse prior spreads its prior predictive distribution over more possible data sets and so assigns lower probability to any particular one unless the extra flexibility is needed, so the Bayes factor automatically penalises complexity, a property known as Occam’s razor. This penalty makes the Bayes factor sensitive to the prior on the parameters: as the prior on θ\theta under H1H_1 becomes more diffuse the marginal likelihood of H1H_1 tends to zero and the Bayes factor favours H0H_0 whatever the data, even when a frequentist test rejects H0H_0 decisively, which is the Jeffreys–Lindley paradox. Improper priors cannot be used for the parameters that differ between models, since the marginal likelihood is then defined only up to an arbitrary constant. Marginal likelihoods are rarely available in closed form and are estimated by importance sampling or bridge sampling, or approximated using the Laplace approximation, which as n→∞n\rightarrow\infty with dkd_k parameters gives

log⁡ef(x‾∣Mk)≈ℓ(θ^k∣x‾)−dk2log⁡en.\log_e f\left(\underline{x}\mid M_k\right)\approx\ell\left(\hat{\theta}_k\mid\underline{x}\right)-\frac{d_k}{2}\log_e n.

The Bayesian information criterion (BIC) is minus twice this approximation,

BICk:=−2 ℓ(θ^k∣x‾)+dklog⁡en,\mathrm{BIC}_k:=-2\,\ell\left(\hat{\theta}_k\mid\underline{x}\right)+d_k\log_e n,

so that 12(BIC2−BIC1)≈log⁡eB12\frac{1}{2}\left(\mathrm{BIC}_2-\mathrm{BIC}_1\right)\approx\log_e B_{12} and the model with the smallest BIC has approximately the largest marginal likelihood. The BIC depends on the prior only through terms that do not grow with nn and is consistent in the sense of selecting the true model with probability tending to one when it is among the candidates.

Bayesian model averaging (BMA) makes inferences and predictions by averaging over the models with their posterior probabilities as weights rather than conditioning on a single chosen model. The posterior predictive distribution of a future observation and the posterior distribution of a quantity Δ\Delta that has the same meaning in every model, such as a prediction or an effect size, are

f(x~∣x‾)=∑k=1Kf(x~∣x‾,Mk)P(Mk∣x‾)f\left(\tilde{x}\mid\underline{x}\right)=\sum_{k=1}^K f\left(\tilde{x}\mid\underline{x},M_k\right)\mathbb{P}\left(M_k\mid\underline{x}\right) π(Δ∣x‾)=∑k=1Kπ(Δ∣x‾,Mk)P(Mk∣x‾).\pi\left(\Delta\mid\underline{x}\right)=\sum_{k=1}^K\pi\left(\Delta\mid\underline{x},M_k\right)\mathbb{P}\left(M_k\mid\underline{x}\right).

Model averaging propagates model uncertainty into the final inference, so its intervals are wider and better calibrated than those from the single best model, and its predictions have lower expected loss under the logarithmic score than those of any single model when the true model is among the candidates.

Model selection chooses a single model, which is the Bayes action under the zero-one loss that charges one unit for choosing any model other than the true one: the model with the largest posterior probability, or equivalently the largest Bayes factor against each alternative when the prior model probabilities are equal. When no candidate model is believed to be true, models are instead compared by how well they predict new data. The log predictive density of a new observation under a model is log⁡ef(x~∣x‾,Mk),\log_e f\left(\tilde{x}\mid\underline{x},M_k\right), and the expected log predictive density is its expectation over the true distribution of X~,\tilde{X}, which is estimated without new data by leave-one-out cross-validation,

elpdloo:=∑i=1nlog⁡ef(xi∣x‾−i,Mk),\mathrm{elpd}_{\mathrm{loo}}:=\sum_{i=1}^n\log_e f\left(x_i\mid\underline{x}_{-i},M_k\right),

where x‾−i\underline{x}_{-i} is the data with the ii-th observation removed, or approximated by an information criterion. The deviance of a model at parameter value θ\theta is D(θ):=−2log⁡ef(x‾∣θ),D\left(\theta\right):=-2\log_e f\left(\underline{x}\mid\theta\right), and the deviance information criterion (DIC) is the posterior mean deviance plus a penalty equal to the effective number of parameters pD,p_D, the difference between the posterior mean deviance and the deviance at the posterior mean,

DIC:=D‾+pD,D‾:=E[D(θ)∣x‾]\mathrm{DIC}:=\overline{D}+p_D,\qquad\overline{D}:=\mathbb{E}\left[D\left(\theta\right)\mid\underline{x}\right] pD:=D‾−D(E[θ∣x‾])p_D:=\overline{D}-D\left(\mathbb{E}\left[\theta\mid\underline{x}\right]\right)

which is computed directly from posterior draws. The widely applicable information criterion (WAIC) is a more stable alternative that uses the pointwise posterior predictive densities,

WAIC:=−2(∑i=1nlog⁡eE[f(xi∣θ)∣x‾]−∑i=1nvar[log⁡ef(xi∣θ)∣x‾]),\mathrm{WAIC}:=-2\left(\sum_{i=1}^n\log_e\mathbb{E}\left[f\left(x_i\mid\theta\right)\mid\underline{x}\right]-\sum_{i=1}^n\mathrm{var}\left[\log_e f\left(x_i\mid\theta\right)\mid\underline{x}\right]\right),

in which the first sum is the log pointwise predictive density and the second is the effective number of parameters, and it asymptotically equals −2 elpdloo.-2\,\mathrm{elpd}_{\mathrm{loo}}. Lower values of DIC and WAIC indicate better expected predictive performance. Unlike the Bayes factor these criteria are insensitive to diffuse priors and do not require the true model to be among the candidates, but they do not deliver posterior probabilities of the models.

Model comparison only ranks the candidates, so a model should also be checked against the data on its own. Let x‾rep\underline{x}^{\mathrm{rep}} be a replicated data set, a hypothetical new data set of the same size and structure as x‾\underline{x} drawn from the posterior predictive distribution,

f(x‾rep∣x‾)=∫Θf(x‾rep∣θ)π(θ∣x‾)dθ,f\left(\underline{x}^{\mathrm{rep}}\mid\underline{x}\right)=\int_{\Theta}f\left(\underline{x}^{\mathrm{rep}}\mid\theta\right)\pi\left(\theta\mid\underline{x}\right)d\theta,

which is simulated by drawing θ(s)\theta^{(s)} from the posterior and then x‾rep(s)\underline{x}^{\mathrm{rep}(s)} from the population distribution at θ(s).\theta^{(s)}. Posterior predictive checking compares the observed data with the replicated data sets: if the model is adequate the observed data should look like a typical draw from the posterior predictive distribution. A test quantity T(x‾,θ)T\left(\underline{x},\theta\right) is a function of the data, and possibly the parameter, chosen to capture a feature of the data that the model should reproduce, such as the proportion of zeros, the maximum, the autocorrelation or a goodness-of-fit statistic. The posterior predictive pp-value is the posterior probability that the test quantity of replicated data is at least as extreme as that of the observed data,

pB:=P(T(x‾rep,θ)≥T(x‾,θ)∣x‾)≈1S∑s=1S1{T(x‾rep(s),θ(s))≥T(x‾,θ(s))},p_B:=\mathbb{P}\left(T\left(\underline{x}^{\mathrm{rep}},\theta\right)\geq T\left(\underline{x},\theta\right)\mid\underline{x}\right)\approx\frac{1}{S}\sum_{s=1}^S\mathbf{1}_{\left\{T\left(\underline{x}^{\mathrm{rep}(s)},\theta^{(s)}\right)\geq T\left(\underline{x},\theta^{(s)}\right)\right\}},

and values near 00 or 11 indicate that the model does not reproduce that feature of the data. The posterior predictive pp-value is not a frequentist pp-value and is not uniformly distributed under the model, since the data are used both to fit the model and to assess it, which makes it conservative; it is a measure of discrepancy rather than a formal test, and graphical comparisons of the observed data with replicated data sets are often more informative than a single number. A prior predictive check draws replicated data from the prior predictive distribution instead and shows whether the prior and likelihood together produce plausible data before any are observed, which is how prior choices are calibrated. A sensitivity analysis repeats the analysis under alternative priors and model specifications to assess how much the conclusions depend on choices that the data cannot settle.