I don't know if this will get much response from the R developers; they might just recommend that you protect your mle() call in a try() or tryCatch() to stop it from breaking your loop. Alternatively, you could try mle2() function in the bbmle package, which started out long ago as a slightly more flexible and robust version of stats4::mle(); I don't remember/can't promise that it handles fits with singular Hessians, but I'm guessing it does ...
cheers Ben Bolker On 2019-02-19 12:02 p.m., Francisco Matorras wrote: > 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 > > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel