[R] optim seems to be finding a local minimum

John C Nash nashjc at uottawa.ca
Fri Nov 11 15:10:36 CET 2011

I won't requote all the other msgs, but the latest (and possibly a bit glitchy) version of
optimx on R-forge

1) finds that some methods wander into domains where the user function fails try() (new
optimx runs try() around all function calls). This includes L-BFGS-B

2) reports that the scaling is such that you really might not expect to get a good solution


3) Actually gets a better result than the

> xlf<-myfunc(c(0.888452533990788,94812732.0897449))
> xlf
[1] 334.607

with Kelley's variant of Nelder Mead (from dfoptim package), with

> myoptx
  method                        par       fvalues fns  grs itns conv  KKT1
4 LBFGSB                     NA, NA 8.988466e+307  NA NULL NULL 9999    NA
2 Rvmmin           0.1, 200186870.6      25593.83  20    1 NULL    0 FALSE
3 bobyqa 6.987875e-01, 2.001869e+08      1933.229  44   NA NULL    0 FALSE
1   nmkb 8.897590e-01, 9.470163e+07      334.1901 204   NA NULL    0 FALSE
   KKT2 xtimes  meths
4    NA   0.01 LBFGSB
2 FALSE   0.11 Rvmmin
3 FALSE   0.24 bobyqa
1 FALSE   1.08   nmkb

But do note the terrible scaling. Hardly surprising that this function does not work. I'll
have to delve deeper to see what the scaling setup should be because of the nature of the
function setup involving some of the data. (optimx includes parscale on all methods).

However, original poster DID include code, so it was easy to do a quick check. Good for him.


> ## Comparing this solution to Excel Solver solution:
> myfunc(c(0.888452533990788,94812732.0897449))
> -- Dimitri Liakhovitski marketfusionanalytics.com

More information about the R-help mailing list