[R] optim error

Vaidotas Zemlys mpiktas at gmail.com
Thu Aug 10 16:07:17 CEST 2006


On 8/9/06, Frank Black <fb572 at hotmail.com> wrote:
> Dear all,
> There have been one or two questions posted to the list regarding the optim
> error "non-finite finite-difference value [4]."  The error apparently means
> that the 4th element of the gradient is non-finite.  My question is what
> part(s) of my program should I fiddle with in an attempt to fix it?
> Starting values?  Something in the log-likelihood itself?  Perhaps the data
> (which is generated)?  Any thoughts would be greatly appreciated.

Use Nelder-Mead algorithm for finding apropriate starting values. This
algorithm does not use gradients, so you will not aforementioned
error. After Nelder-Mead you can try again with gradient methods, like
BFGS. If that does not help, try scaling your data. Optim behaves
better (IMHO) when all parameters are of the same order. If you do not
need hessian, and BFGS fails, use only Nelder-Mead, it will at least
give you something.

Vaidotas Zemlys
Doctorate student, Vilnius University

More information about the R-help mailing list