[R] optim evils

Joshua Wiley jwiley.psych at gmail.com
Wed Sep 4 10:50:14 CEST 2013


Hi Michael,

You do not need to create a self-contained example from the mass of
code where it is embedded, but given that optim() works in many cases,
to file a bug report, you do need to give _an_ example where it is
failing.

Here is an example where it works great:

> optim(1, fn = function(x) x - 5, method = "CG", lower = 3)
$par
[1] 3

$value
[1] -2

$counts
function gradient
       1        1

$convergence
[1] 0

$message
[1] "CONVERGENCE: NORM OF PROJECTED GRADIENT <= PGTOL"

Warning message:
In optim(1, fn = function(x) x - 5, method = "CG", lower = 3) :
  bounds can only be used with method L-BFGS-B (or Brent)

and it gives a warning at the end regarding L-BFGS-B.


On Wed, Sep 4, 2013 at 1:34 AM, Michael Meyer <spyqqqdia at yahoo.com> wrote:
> It would take some effort to extract selfcontained code from the mass of code wherein this optimization is embedded. Moreover I would have to obtain permission from my employer to do so.
>
> This is not efficient.
> However some things are evident from the trace log which I have submitted:
> (a) L-BFGS-B does not identify itself even though it was called overriding the method
> parameter in optim.
> (b) Optim  reports as final converged minimum value a function value that is much larger than
> others computed during the optimization.
>
> I think we can agree on calling this a bug.
>         [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://joshuawiley.com/
Senior Analyst - Elkhart Group Ltd.
http://elkhartgroup.com



More information about the R-help mailing list