R/waic_fit.R

Defines functions waic

Documented in waic

#' Widely Applicable Information Criterion (WAIC)
#' 
#' Compute WAIC using the \code{waic()} method of the loo package.
#' 
#' @param fit An object of class \code{fitTK}
#' 
#' @return A numeric containing the WAIC
#' 
#' @export
#' 
#' 
waic <- function(fit){
  fitMCMC = as.matrix(rstan::extract(fit[["stanfit"]], permuted = FALSE))
  waicEval <- loo::waic(fitMCMC)
  return(waicEval$estimates[3,1])
}

Try the rbioacc package in your browser

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

rbioacc documentation built on Sept. 21, 2023, 5:06 p.m.