From |r@nc|@co@m@torr@@ @end|ng |rom un|c@n@e@  Tue Feb 19 18:02:29 2019
From: |r@nc|@co@m@torr@@ @end|ng |rom un|c@n@e@ (Francisco Matorras)
Date: Tue, 19 Feb 2019 18:02:29 +0100
Subject: [Rd] mle (stat4) crashing due to singular Hessian in covariance
 matrix calculation
Message-ID: <b379c738-7b0c-c47f-800f-1014d51185ee@unican.es>

Hi, R developers.
when running mle inside a loop I found a nasty behavior. From time to 
time, my model had a degenerate minimum and the loop just crashed. I 
tracked it down to "vcov <- if (length(coef)) solve(oout$hessian)" line, 
being the hessian singular.
Note that the minimum reached was good, it just did not make sense to 
calculate the covariance matrix as the inverse of a singular Hessian. In 
my case i am just interested on the value of the log-likelihood. For my 
application, I patched it easily in a local version of mle just removing 
this call since I am not using vcov at all, but i wonder if it can be 
improved in the official release. I can imagine of two simple solutions, 
either including vcov calculation as an option or avoiding the call to 
solve if the hessian is singular (setting vcov to NA). I am willing to 
write a few lines of coded if you think it is worth.

regards

Francisco Matorras
Instituto de F?sica de Cantabria
Universidad de Cantabria



[Rd] mle (stat4) crashing due to singular Hessian in covariance matrix calculation
Francisco Matorras