Learn R Programming

qrjoint (version 2.0-9)

waic: Watanabe Information Criterion

Description

Calculates two versions of the Watanabe information criteria from MCMC draws.

Usage

waic(logliks, print = TRUE)

Value

Returns the two version of the WAIC

Arguments

logliks

a matrix of observation level log-likelihood values, the columns are MCMC iterations and the rows are observations in the data

print

logical whether to print the results

References

Gelman, A., Hwang, J., and Vehtari, A. (2014). Understanding predictive information criterion for Bayesian models. Stat Comput, 24, 997-1016.

See Also

summary.qrjoint

Examples

Run this code
# Plasma data analysis

# recoding variables
data(plasma)
plasma$Sex <- as.factor(plasma$Sex)
plasma$SmokStat <- as.factor(plasma$SmokStat)
plasma$VitUse <- 3 - plasma$VitUse
plasma$VitUse <- as.factor(plasma$VitUse)

# Model fitting with 40 posterior samples from 80 iterations (thin = 2) is for
# illustration only. For practical model fitting, increase iterations, 
# e.g. nsamp = 500, thin = 20
fit.qrj <- qrjoint(BetaPlasma ~ Age + Sex + SmokStat + Quetelet + VitUse + Calories + 
        Fat + Fiber + Alcohol + Cholesterol + BetaDiet, plasma, nsamp = 40, thin = 2)
summary(fit.qrj, more = TRUE)

# the call to summary already shows the waic for the fitted model, it also returns 
# the observation level log-likelihood vales. To calculate waic from last 20 draws 
# we can use:

if (FALSE) {
summary(fit.qrj, more = TRUE)
ll <- sm$ll
waic(ll[,21:40])
}

Run the code above in your browser using DataLab