R/WAIC.R

Defines functions WAIC

Documented in WAIC

###########################################################################
# WAIC                                                                    #
#                                                                         #
# The purpose of the WAIC function is to calculate the Widely Applicable  #
# Information Criterion.                                                  #
###########################################################################

WAIC <- function(x)
     {
     lppd <- sum (log(rowMeans(exp(x))))
     pWAIC1 <- 2*sum(log(rowMeans(exp(x))) - rowMeans(x))
     pWAIC2 <- sum(.rowVars(x))
     WAIC <- -2*lppd + 2*pWAIC2
     return(list(WAIC=WAIC, lppd=lppd, pWAIC=pWAIC2, pWAIC1=pWAIC1))
     }

#End

Try the LaplacesDemon package in your browser

Any scripts or data that you put into this service are public.

LaplacesDemon documentation built on May 29, 2017, 11:54 p.m.