| waic | R Documentation |
Generic function calculating widely applicable information criterion (WAIC) from the pointwise log-likelihood.
waic(loglik, method = 2)
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 |
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.
Returns numeric scalar of the widely applicable information criterion.
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.
dmWAIC for computing widely applicable information criteria for Dirichlet-multinomial regression models.
mlWAIC for computing widely applicable information criteria for multivariate logistic regression models.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.