Skip to content
Prev 61200 / 63424 Next

Bug in optim for specific orders of magnitude

The optim help page mentions scaling in the discussion of the "control" 
argument.  Specifically under the parscale description:

"Optimization is performed on par/parscale and these should be 
comparable in the sense that a unit change in any element produces about 
a unit change in the scaled value."

In your function a unit change in x[1] makes a change of 1e-317 in the 
function value, and changing x[2] has no effect at all.

It would be nice if violating the rule only led to inefficiencies or 
poor stopping decisions, but the numbers you are working with are close 
to the hardware limits (the smallest positive number with full precision 
is .Machine$double.xmin, about 2e-308), and sometimes that means 
assumptions in the code about how arithmetic works are violated, e.g. 
things like x*1.1 > x may not be true for positive x below 
.Machine$double.xmin .

Duncan Murdoch
On 23/12/2022 12:30 p.m., Collin Erickson wrote: