Closed rbchan closed 4 years ago
I have been working on this a little bit. Assuming you still want to change this, is the desired behavior when the Hessian can't be inverted to throw a warning and return a matrix of NAs?
I was thinking of adding a common function that all fitting functions would use for this, for example:
invertHessian <- function(optimOut, nparam, SE){
blankMat <- matrix(NA, nparam, nparam)
if(!SE) return(blankMat)
tryCatch(solve(optimOut$hessian),
error=function(e){
warning("Hessian is singular. Try providing starting values or using fewer covariates.", call.=FALSE)
return(blankMat)
})
}
That looks great, thanks.
When hessian can't be inverted, it fails instead of returning NA.