https://github.com/cran/bild
Raw File
Tip revision: 6661b7703cf2271cb13756a6ff2969ef8e1d88f3 authored by M. Helena Goncalves on 03 November 2023, 14:40:02 UTC
version 1.2-1
Tip revision: 6661b77
num_info.R
# compute numerical second derivatives
#
num.info <- function(coefficients, FUN, X, data)
{
  FUN <- get(FUN, inherits = TRUE)
  values <- FUN(coefficients, X, data)
  p <- length(values)
  Info <- matrix(0, p, p)
  h <- rep(0, p)
  delta <- cbind((abs(coefficients) + 1e-012) * 0.0001, rep(1e-012, p))
  delta <- apply(delta, 1, max)
  for(i in 1:p) {
    h[i] <- delta[i]
    new.values <- FUN(coefficients + h, X, data)
    Info[, i] <- (new.values - values)/delta[i]
    h[i] <- 0
  }
  Info
}
back to top