I am using optim
to solve an optimization problem. It is a standard minimization of L2 norm, so it is positive, well behaved. However, when using optim, I run into some issues. First I call
> lambda2
$par
[1] 4.6105840762 0.1268444008 -0.8488319926 -0.1734999439 -0.8090172550 -0.0006518246
$value
[1] 0.004230469
$counts
function gradient
1317 NA
$convergence
[1] 0
$message
NULL
Which seems fine. However, lambda2$value
is still large. If I run another iteration, using lambda2$par
, I get a better result. As you can see from the results, the number of iterations has not reached maxit
and the tolerance is still above the desired one. My tolerance is really low, pretty much unreachable, but I would like to run more iterations.
Here is the outcome if I call the function again
> lambda2=optim(lambda2$par,fn,control = list(maxit=100000,abstol=10e-08))
> lambda2
$par
[1] 3.8098969475 0.1892906218 -1.4387655921 -0.3345618667 -1.2719792359 -0.0000129872
$value
[1] 0.001079045
$counts
function gradient
1529 NA
$convergence
[1] 0
$message
NULL
I found the following question, but the suggested solution only work for one method of optim, therefore I was not able to apply it to my problem. How can I force r optim to run more iterations?