[R] Error message when using optim
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Aug 10 07:57:19 CEST 2006
(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 at 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
More information about the R-help
mailing list