R/I_laplApprox.R

Defines functions .laplApprox

# Calculates the laplace approximation given the value (f) of a function at its
# maximum and the Hessian (H)

.laplApprox <- function(f, H, log = FALSE)
{
  
  d <- ncol(H)
  
  out <- d/2 * log(2*pi) - determinant(H, logarithm = T)$modulus/2 + f
  
  if( !log )
  {
    out <- exp( out )
  }
  
  return( as.numeric(out) )
  
}

Try the esaddle package in your browser

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

esaddle documentation built on April 26, 2021, 5:06 p.m.