To minimize a function with respect to 3 parameters, I use the optim function and "L-BFGS-B" method. Here is the error message :
Error in optim(c(3, 0.01, 0.75), fn = f, lower = c(0.6, 0.0001, 0.1), : L-BFGS-B needs finite values of 'fn'
I already checked the values of the function when at least one of the three parameters reaches the "border" (ie the lower or the upper values) but it never gives an infinite value.
How to know which values gave an infinite value in the optim function?
A quick and dirty way would be to wrap your function and just print out the parameters being passed to it. Here is an example session of doing that.
and call it using optim...
Now wrap the code...
And now we can see what is being called...
So in this example it ended up trying to evaluate .7441084 which gave an error by how the function was defined.