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 Nov. 22, 2017, 6:34 p.m.