[R] stop criteria when "L-BFGS-B needs finite values of 'fn' " in optim

Ben Bolker bolker at ufl.edu
Tue Jul 31 17:21:31 CEST 2007


Dae-Jin Lee <dae-jin.lee <at> uc3m.es> writes:

> 
> 
> I would like to know how to include and "if" condition when this happen,
> could it be something like:
> 
> myfun <- optim(....)         #   run my function
> 
> ????
> if(myfun == ERROR) ..... #   when the error message is "L-BFGS-B needs
> finite values of 'fn'
> ????
> 

  See ?try :

e.g.

 myfun <- try(optim(...))
  if (class(myfun)=="try-error") { ... whatever ...
   } else {
     ... success ...
   }
  
  or tryCatch

  this is FAQ 7.32 ...

  cheers
    Ben Bolker



More information about the R-help mailing list