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) )
  
}
mfasiolo/esaddle documentation built on June 28, 2021, 8:49 a.m.