I would like to learn how optim(..., hessian=TRUE)
computes a Hessian, so I took a look at the function's definition. Near its end, it includes this call to .External2()
:
if (hessian)
res$hessian <- .External2(C_optimhess, res$par, fn1,
gr1, con)
Looks like there's a call to an external C function named C_optimhess
, so I grep
'd the R source directory for C_optimhess
, but came up emptyhanded. There are only two occurrences of that string in R's code base, one in optim
and one in optimHess
. Both functions are defined in $R_SOURCE_DIR/src/library/stats/R/optim.R
, and that file includes no additional hints/comments/references.
optim
's help file references code on which several of the function's optimization methods were based, but doesn't (seem to) point to the source of C_optimhess
.
In a case like this, where should I look to find the C code being called by .External2
?