[R] How to catch errors regarding the hessian in 'optim'

Simon Zehnder szehnder at uni-bonn.de
Mon Sep 2 20:49:10 CEST 2013


Dear John,

thank you very much for your answer. I take a look at these packages (Rvmmin and Rcgmin). That sounds very interesting. 

For the example: The method relies on data which I always try to avoid to send on the r-help list - not that my data is confidential - but it becomes even more cumbersome when sending datasets over the list. I made the experience, that in such case answers are rare. Maybe you have a suggestion if and how users should send data with their code. I am interested in your opinion and thankful for sharing it.

Best

Simon


On Sep 2, 2013, at 4:42 PM, Prof J C Nash (U30A) <nashjc at uottawa.ca> wrote:

> This may be one of the many mysteries of the internals of L-BFGS-B, which I have found fails from time to time. That is one of the reasons for Rvmmin and Rcgmin (and hopefully sooner rather than later Rtn - a truncated Newton method, currently working for unconstrained problems, but still glitchy for bounds constraints). These are all-R codes so that users and developers can get inside to control special situations.
> 
> If you have a test problem -- the infamous reproducible example -- there are several of us who can likely help to sort out your troubles.
> 
> JN
> 
> 
> On 13-09-02 06:00 AM, r-help-request at r-project.org wrote:
>> Message: 10
>> Date: Sun, 1 Sep 2013 17:09:35 +0200
>> From: Simon Zehnder<szehnder at uni-bonn.de>
>> To: R-help help<r-help at r-project.org>
>> Subject: [R] How to catch errors regarding the hessian in 'optim'
>> Message-ID:<EB37670E-8544-4C89-9172-245EB6CC596A at uni-bonn.de>
>> Content-Type: text/plain; charset=us-ascii
>> 
>> Dear R-Users and R-Developers,
>> 
>> in a comparison between two different estimation approaches I would like to catch errors from optim regarding the hessian matrix.
>> 
>> I use optim with method = "L-BFGS-B" thereby relying on numerical differentiation for the hessian matrix. I do know, that the estimation approach that uses numerical optimization has sometimes problems with singular hessian matrices and I consider it as one of its disadvantages of this method. To show the frequency of such problems in my simulation study I have to set 'hessian = TRUE' and to collect the errors from optim regarding the hessian.
>> 
>> Now I am a little stucked how I could catch specifically errors from the hessian matrix in 'optim'. I do know that such errors are thrown most certainly from function 'La_solve' in Lapack.c. Does anyone has an idea how I could solve this task (clearly with tryCatch but how to choose only errors for the hessian)?
>> 
>> 
>> Best
>> 
>> Simon



More information about the R-help mailing list