waic: Widely Applicable Information Criterion

View source: R/waic.R

waicR Documentation

Widely Applicable Information Criterion

Description

Generic function calculating widely applicable information criterion (WAIC) from the pointwise log-likelihood.

Usage

waic(loglik, method = 2)

Arguments

loglik

Numeric matrix of the pointwise log-likelihood. Each record represents a Markov chain Monte Carlo (MCMC) sample, and each field represents an observation.

method

Numeric scalar. Options are 1 or 2, representing the alternative WAIC bias correction formulas (pWAIC1 and pWAIC2, respectively) described in Gelman et al. (2014). As recommended by Gelman et al. (2014), the default method (2) uses the pWAIC2 bias correction formula.

Details

Given the pointwise log-likelihood, calculates WAIC (Watanabe 2010) using the formulas described in Gelman et al. (2014). The expected log pointwise predictive density (elppd) is estimated as the log pointwise predictive density (lppd) adjusted by a bias correction (either pWAIC1 or pWAIC2). To reflect the deviance scale, WAIC is defined as the elppd times negative two. As recommended by Gelman et al. (2014), pWAIC2 is used as the default bias correction (method = 2). See Gelman et al. (2014) for details.

Value

Returns numeric scalar of the widely applicable information criterion.

References

Gelman A, Hwang J, and Vehtari A. 2014. Understanding predictive information criteria for Bayesian models. Statistics and Computing, 24(6): 997-1016. DOI: 10.1007/s11222-013-9416-2

Watanabe S. 2010. Asymptotic equivalence of Bayes cross validation and widely applicable information criterion in singular learning theory. Journal of Machine Learning Research, 11(116): 3571-3594.

See Also

dmWAIC for computing widely applicable information criteria for Dirichlet-multinomial regression models.

mlWAIC for computing widely applicable information criteria for multivariate logistic regression models.

Examples

# Define example data file path.
path<-system.file("extdata",
                  "example_regression_data.rds",
                  package="LocaTT",
                  mustWork=TRUE)

# Read in example regression data.
data<-readRDS(file=path)

# Compute WAIC from pointwise log-likelihood.
out<-waic(loglik=data$loglik)

LocaTT documentation built on June 14, 2026, 1:06 a.m.