[R] Error in optim(p, fun,...)

Ben Bolker ben at zoo.ufl.edu
Tue Sep 25 20:07:24 CEST 2001

  My guess is that you should start with the setting of ndeps (see
?optim).  If your function gives bad results for parameters outside of the
bounds you have set, you probably need to set the bounds a tiny bit
smaller and then set ndeps tinier still so that the finite-difference
approximation to the derivatives doesn't try to evaluate the function
outside the bounds ...

  (Q for Brian Ripley: does this seem reasonable?  Or does L-BFGS-B
actually check to make sure that finite differences are always evaluated
inside the boundaries?  Based on my experience with optim/L-BFGS-B I don't
think so, but I'm not sure)

  The other thing you can do for debugging this kind of problem is to turn
on some tracing in your function itself (with a cat() or print()
statement) that reports the parameters at which the function is evaluated.

  Ben Bolker

On Tue, 25 Sep 2001, Tony Long wrote:

> All:
> 	I am getting an error code from the optimization function.  The code is
> Error in optim(p,fun.LLike, lower=low, upper = up, method = "L-BFGS-B", :
>           non-finite finite-difference value [0]
> If I add a trace=6 option to my control list the last message before
> this error is:
>           At X0, 0 variables are exactly at the bounds
> Any ideas on where I should start would be appreciated.  Tony

318 Carr Hall                                bolker at zoo.ufl.edu
Zoology Department, University of Florida    http://www.zoo.ufl.edu/bolker
Box 118525                                   (ph)  352-392-5697
Gainesville, FL 32611-8525                   (fax) 352-392-3704

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list