Algorithm Search⌘K

Definitionadvanced

Widely applicable information criterion

Also called WAIC, Watanabe-Akaike information criterion.

An estimate of out-of-sample predictive accuracy for Bayesian models. It is the log pointwise posterior predictive density minus the posterior variance of the log likelihood.

The widely applicable information criterion (WAIC) estimates how well a fitted Bayesian model will predict new data points from the same source. It takes the log of each point's posterior predictive density, sums over the data, and subtracts a penalty: the sum over the points of the posterior variance of the log likelihood. Watanabe (2010) defined it and proved that it is asymptotically equivalent to Bayesian leave-one-out cross-validation, also for singular models such as mixtures and neural networks where the posterior is not close to normal. It is computed from posterior draws, like PSIS-LOO, which estimates the same target.

Definition

Let y1,…,yny_1, \ldots, y_n be the data, f(yi∣θ)f(y_i \mid \theta) the density of one point given the parameter, and p(θ∣y)p(\theta \mid y) the posterior. Write Epost\mathbb{E}_{\text{post}} and Varpost\mathrm{Var}_{\text{post}} for the mean and variance over θ∼p(θ∣y)\theta \sim p(\theta \mid y).

The target is the expected log pointwise predictive density for new data y~1,…,y~n\tilde y_1, \ldots, \tilde y_n drawn from the true distribution qq:

elpd=∑i=1nEy~i∼q[log⁡p(y~i∣y)],p(y~∣y)=Epost[f(y~∣θ)].\mathrm{elpd} = \sum_{i=1}^n \mathbb{E}_{\tilde y_i \sim q}\big[\log p(\tilde y_i \mid y)\big], \qquad p(\tilde y \mid y) = \mathbb{E}_{\text{post}}\big[f(\tilde y \mid \theta)\big].

Up to a term that does not depend on the model, −elpd/n-\mathrm{elpd}/n is the Kullback-Leibler divergence from qq to the posterior predictive distribution, so a larger elpd means a predictive closer to the truth.

WAIC. With the log pointwise predictive density and the penalty

lppd=∑i=1nlog⁡Epost[f(yi∣θ)],pWAIC=∑i=1nVarpost[log⁡f(yi∣θ)],\mathrm{lppd} = \sum_{i=1}^n \log \mathbb{E}_{\text{post}}\big[f(y_i \mid \theta)\big], \qquad p_{\mathrm{WAIC}} = \sum_{i=1}^n \mathrm{Var}_{\text{post}}\big[\log f(y_i \mid \theta)\big],

the estimate of elpd is

elpd^WAIC=lppd−pWAIC,WAIC=−2 elpd^WAIC.\widehat{\mathrm{elpd}}_{\mathrm{WAIC}} = \mathrm{lppd} - p_{\mathrm{WAIC}}, \qquad \mathrm{WAIC} = -2\, \widehat{\mathrm{elpd}}_{\mathrm{WAIC}}.

The factor −2-2 puts WAIC on the deviance scale of AIC, where smaller is better. Watanabe's own definition is per observation and without the −2-2: the Bayes training loss −lppd/n-\mathrm{lppd}/n plus the functional variance pWAICp_{\mathrm{WAIC}} divided by nn. All three scales order models in the same way.

From draws. With posterior draws θ(1),…,θ(S)\theta^{(1)}, \ldots, \theta^{(S)}, replace Epostf(yi∣θ)\mathbb{E}_{\text{post}} f(y_i \mid \theta) by 1S∑sf(yi∣θ(s))\frac1S\sum_s f(y_i \mid \theta^{(s)}), computed as a log-sum-exp, and Varpost\mathrm{Var}_{\text{post}} by the sample variance of log⁡f(yi∣θ(s))\log f(y_i \mid \theta^{(s)}). The standard error of elpd^WAIC\widehat{\mathrm{elpd}}_{\mathrm{WAIC}} is n\sqrt n times the standard deviation of the nn pointwise terms. The function waic of the PSIS-LOO implementation computes exactly this.

Effective number of parameters. pWAICp_{\mathrm{WAIC}} plays the role of the parameter count kk in AIC. An older form, pWAIC1=2∑i(log⁡Epostf(yi∣θ)−Epostlog⁡f(yi∣θ))p_{\mathrm{WAIC1}} = 2\sum_i\big(\log \mathbb{E}_{\text{post}} f(y_i \mid \theta) - \mathbb{E}_{\text{post}} \log f(y_i \mid \theta)\big), has the same limit in regular models; Gelman, Hwang and Vehtari (2014) recommend the variance form.

What is proved and what is not. Watanabe (2010) proved that the expectation of WAIC over data sets equals that of the generalization loss up to o(1/n)o(1/n), and that WAIC and Bayesian leave-one-out cross-validation differ by op(1/n)o_p(1/n) per observation, under conditions that include singular models. These are asymptotic results. For a given finite data set, WAIC is an estimate whose error is only measured, and Vehtari, Gelman and Gabry (2017) found that it is less reliable than PSIS-LOO when some observations are very influential.

Examples and non-examples

Example: a normal mean, exact. Let y=(0.5,1,2,2.5,4)y = (0.5, 1, 2, 2.5, 4), f(yi∣θ)=N(yi;θ,1)f(y_i \mid \theta) = N(y_i; \theta, 1) and a flat prior on θ\theta. The posterior is N(yˉ,v)N(\bar y, v) with yˉ=2\bar y = 2 and v=1/n=0.2v = 1/n = 0.2. Write di=yi−yˉd_i = y_i - \bar y, so ∑idi2=7.5\sum_i d_i^2 = 7.5.

  • The posterior predictive of a point is N(yˉ,1+v)N(\bar y, 1 + v), so lppd=∑i(−12log⁡(2π⋅1.2)−di2/2.4)=−8.1755\mathrm{lppd} = \sum_i \big(-\tfrac12\log(2\pi \cdot 1.2) - d_i^2/2.4\big) = -8.1755.
  • Since yi−θ=di−ey_i - \theta = d_i - e with e∼N(0,v)e \sim N(0, v), Varpost[(yi−θ)2/2]=di2v+v2/2\mathrm{Var}_{\text{post}}\big[(y_i - \theta)^2/2\big] = d_i^2 v + v^2/2. The pointwise penalties are 0.47,0.22,0.02,0.07,0.820.47, 0.22, 0.02, 0.07, 0.82, and pWAIC=nv2/2+v∑idi2=0.1+1.5=1.6p_{\mathrm{WAIC}} = n v^2/2 + v\sum_i d_i^2 = 0.1 + 1.5 = 1.6.
  • So elpd^WAIC=−9.7755\widehat{\mathrm{elpd}}_{\mathrm{WAIC}} = -9.7755 and WAIC=19.551\mathrm{WAIC} = 19.551.

The exact leave-one-out value is ∑ilog⁡N(yi;yˉ−i,1+1/(n−1))=−9.8401\sum_i \log N(y_i; \bar y_{-i}, 1 + 1/(n - 1)) = -9.8401, close to WAIC. The outlying point y5=4y_5 = 4 carries the largest penalty. With S=1000S = 1000, 40004000 and 1600016000 posterior draws from random.Random(1), the estimates from draws are −9.7808-9.7808, −9.7489-9.7489 and −9.7506-9.7506; the Monte Carlo error is in the penalty, not in the lppd.

Example: the penalty tracks the fit of the model. In the same model with v=1/nv = 1/n, the expected penalty over data sets is about 11, the number of parameters, when the data really have variance 1. If the data have variance 4, the model's likelihood is too narrow and pWAICp_{\mathrm{WAIC}} goes to about 44; for n=200n = 200 points drawn by random.Random(5) it is 1.261.26 for variance 1 and 5.045.04 for variance 4. AIC would still charge 11. This is the case where the posterior variance penalty, like Takeuchi's criterion, is the more honest one.

Non-example: AIC. AIC =−2log⁡f(y∣θ^)+2k= -2\log f(y \mid \hat\theta) + 2k uses the maximum likelihood plug-in, not the posterior, and the count kk, not a variance. In the example, log⁡f(y∣θ^)=−8.3447\log f(y \mid \hat\theta) = -8.3447 and AIC=18.689\mathrm{AIC} = 18.689. AIC estimates the predictive accuracy of the plug-in density f(⋅∣θ^)f(\cdot \mid \hat\theta); WAIC estimates that of the posterior predictive. See Akaike information criterion.

Non-example: BIC. BIC=−2log⁡f(y∣θ^)+klog⁡n\mathrm{BIC} = -2\log f(y \mid \hat\theta) + k \log n approximates −2log⁡m(x)-2\log m(x), the log marginal likelihood. Its target is the posterior probability of a model, not predictive accuracy, and its penalty grows with nn. See Bayesian information criterion. Watanabe's WBIC (2013) is the singular-model counterpart of BIC and is a different criterion from WAIC.

Non-example: DIC. The deviance information criterion plugs in the posterior mean, −2log⁡f(y∣θˉ)+2pD-2\log f(y \mid \bar\theta) + 2p_D with pD=2(log⁡f(y∣θˉ)−Epostlog⁡f(y∣θ))p_D = 2\big(\log f(y \mid \bar\theta) - \mathbb{E}_{\text{post}}\log f(y \mid \theta)\big). It uses the joint likelihood of all the data, not a sum of pointwise terms, and it is not invariant to reparametrization. In the example pD=1.0p_D = 1.0 and pWAIC1=1.338p_{\mathrm{WAIC1}} = 1.338, against pWAIC=1.6p_{\mathrm{WAIC}} = 1.6.

Non-example: the Bayes factor. A Bayes factor compares how well models predicted all the data from the prior. WAIC compares how well they predict each point from the posterior. A Bayes factor changes without limit as a prior becomes more diffuse; WAIC changes very little.

  • PSIS-LOO. Estimates the same elpd by importance sampling for each left-out point, and its k^\hat k values flag the points where the estimate is unreliable. WAIC has no such diagnostic.
  • Cross-validation. Exact leave-one-out cross-validation refits the model nn times. WAIC and PSIS-LOO are two ways to avoid that.
  • Akaike information criterion. The plug-in, regular-model ancestor. In a regular model with a weak prior and much data, pWAIC→kp_{\mathrm{WAIC}} \to k when the model is correct and WAIC is close to AIC.
  • Bayesian information criterion. A different target: model probability rather than prediction.
  • Deviance statistic. WAIC on the −2-2 scale is a penalized deviance.
  • Stacking. Uses pointwise predictive densities like those of WAIC or PSIS-LOO to choose weights for combining models.
  • Posterior predictive check. Asks whether the data look like draws from the predictive, not how well the model will predict new data.

References

  1. Watanabe 2010, pages 3571 to 3594 (the definition of WAIC as the Bayes training loss plus the functional variance over n, and its asymptotic equivalence with Bayes leave-one-out cross-validation; general locator)
  2. Andrew Gelman, Jessica Hwang and Aki Vehtari, Understanding predictive information criteria for Bayesian models, Statistics and Computing 24(6), 2014, the comparison of AIC, DIC, WAIC and leave-one-out cross-validation, the two penalties p_WAIC1 and p_WAIC2, and the deviance scale (general locator)
  3. Aki Vehtari, Andrew Gelman and Jonah Gabry, Practical Bayesian model evaluation using leave-one-out cross-validation and WAIC, Statistics and Computing 27(5), 2017, pages 1413 to 1432 (the estimates from posterior draws, their standard errors, and the cases where WAIC is less reliable than PSIS-LOO; general locator)
  4. Andrew Gelman, John B. Carlin, Hal S. Stern, David B. Dunson, Aki Vehtari and Donald B. Rubin, Bayesian Data Analysis, 3rd edition, CRC Press, 2013, Chapter 7, Sections 7.1 and 7.2 (log predictive density, AIC, DIC and WAIC)
  5. Watanabe 2013, WBIC, an approximation to the log marginal likelihood that is a different criterion from WAIC (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)
WritingW4 complete
  • a review of the text: no review record reviews/TPJ777/text.yaml