From bbo|ker @end|ng |rom gm@||@com  Tue Feb 19 22:07:16 2019
From: bbo|ker @end|ng |rom gm@||@com (Ben Bolker)
Date: Tue, 19 Feb 2019 16:07:16 -0500
Subject: [Rd] mle (stat4) crashing due to singular Hessian in covariance
 matrix calculation
In-Reply-To: <b379c738-7b0c-c47f-800f-1014d51185ee@unican.es>
References: <b379c738-7b0c-c47f-800f-1014d51185ee@unican.es>
Message-ID: <242f0229-5221-0e3f-6429-8b1c779733b4@gmail.com>


  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 at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



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