waic {qrjoint}R Documentation

Watanabe Information Criterion

Description

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

Usage

 
waic(logliks, print = TRUE)

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

Value

Returns the two version of the WAIC

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

 
# 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:

## Not run: 
summary(fit.qrj, more = TRUE)
ll <- sm$ll
waic(ll[,21:40])

## End(Not run)

[Package qrjoint version 2.0-9 Index]