Re: [R] Error message when using optim

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Thu 10 Aug 2006 - 15:57:19 EST

(Subject changed to something less perjorative. This is not `optim error'.)

On Wed, 9 Aug 2006, Frank Black 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.

(Without an example of the optim usage, we have little to go on. This does not occur in the default method, so we don't even know which method was asked for. Please do study the posting guide: we ask to information for good reasons.)

It means that the finite-difference approximation to the gradient is non-finite (as it says). Most likely this occurs when the user-supplied function is returning Inf (so the finite difference is Inf - Inf) or returning NA/NaN.

> 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.

If the function you are optimizing never returns Inf or NA/NaN, the message will not occur. Nor will it occur if you supply a gradient function.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Thu Aug 10 16:01:04 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 10 Aug 2006 - 18:23:21 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.