Learn R Programming

brms (version 0.4.0)

WAIC: Compute the WAIC

Description

Compute the Watanabe-Akaike Information Criterion based on the posterior likelihood

Usage

WAIC(x, ..., se = FALSE)

Arguments

x
A fitted model object typically of class brmsfit.
...
Optionally more fitted model objects.
se
A flag to indicate if the standard error of the WAIC should be estimated. When the samples size is low, this estimation should be interpreted with caution.

Value

  • If just one object is provided, a numeric value with the corresponding WAIC. If multiple objects are provided, a named list of numeric values with the corresponding WAICs.

Details

When comparing models fitted to the same data, the smaller the WAIC, the better the fit.

References

Gelman, A., Hwang, J., & Vehtari, A. (2014). Understanding predictive information criteria for Bayesian models. Statistics and Computing, 24, 997-1016. Watanabe, S. (2010). Asymptotic equivalence of Bayes cross validation and widely applicable information criterion in singular learning theory. The Journal of Machine Learning Research, 11, 3571-3594.

Examples

Run this code
#model with fixed effects only
fit_i1 <- brm(rating ~ treat + period + carry,
              data = inhaler, family = "gaussian", WAIC = TRUE)
WAIC(fit_i1)

#model with an additional random intercept for subjects
fit_i2 <- brm(rating ~ treat + period + carry + (1|subject),
             data = inhaler, family = "gaussian", WAIC = TRUE)
#compare both models
WAIC(fit_i1, fit_i2)

Run the code above in your browser using DataLab