I just encountered that myself using optim in S-Plus 6.1. For a
certain set of parameter values, the function I wanted to minimize
returned NaN (not a number). To fix this problem, I set a trace with
something like options(trace=99) using, I think, method = "CG". This
printed out all the parameter values tested including the one that
generated the offense. I then took that set of parameter values to the
function to be optimized and figured out a way to limit the range of the
computations. I used a construct like the following:
good.num.limit = c(.Machine$double.xmin, .Machine$double.xmax)^(1/3)
Then I constrained certain positive numbers to lie within these bounds,
thereby avoiding 0 and Inf.
Then I tested the result using method = "Nelder-Mead",
"BFGS", and
"CG". For my particular installation, for some unknown reason,
Nelder-Mead bombed S-Plus, BFGS returned a nonsense answer, but CG was
sensible. Just a few minutes ago, I restarted my (several hour) job. I
think it should be more likely to finish now.
hope this helps.
spencer graves
Werner Bier wrote:> Dear all,
>
> I am using the optim() function which it stops with the following error
messagge:
>
> error in optim(...) non-finite finite-difference value
>
> I was wondering if somebody might suggest me a way to fix it please.
>
> Thanks in advance to all of you.
> Kind regards,
> Tom
>
> __________________________________________________
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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