Skip to content

Instantly share code, notes, and snippets.

library(MASS)
library(rstan)
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())
waic <- function(loglik){
te <- -mean(log(colMeans(exp(log_lik))))
fv <- mean(colMeans(log_lik^2) - colMeans(log_lik)^2)
waic <- te + fv
return(waic)