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. Thanks, Frank
(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
Hi, 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 http://www.mif.vu.lt/katedros/eka/katedra/zemlys.php