Greetings, I am in great anguish as the routine stats::optim shows unexplicable behaviour of various sorts. For one it is immune to the choice of optimization method and seems to always do the same. The following trace log
N = 21, M = 5 machine precision = 2.22045e-16 At X0, 0 variables are exactly at the bounds At iterate 0 f= 1756.8 |proj g|= 0.73581 At iterate 1 f = 911.52 |proj g|= 0.70136 At iterate 2 f = 791.62 |proj g|= 0.68563 At iterate 3 f = 749.81 |proj g|= 1 ..... ..... At iterate 87 f = 666.91 |proj g|= 0.98217 At iterate 88 f = 666.9 |proj g|= 0.96966 Bad direction in the line search; refresh the lbfgs memory and restart the iteration. At iterate 89 f = 9022.8 |proj g|= 1.0426 iterations 89 function evaluations 132 segments explored during Cauchy searches 128 BFGS updates skipped 0 active bounds at final generalized Cauchy point 18 norm of the final projected gradient 1.04257 final function value 9022.84 F = 9022.84 final value 9022.836050 converged by each of the following calls to optim: optPars <- optim( pars,OF,#gradientOF, method = "CG", lower = pars_lb,upper=pars_ub, control = list(fnscale=1,trace=3,REPORT=1) ) optPars <- optim( pars,OF,#gradientOF, method = "Nelder-Mead", lower = pars_lb,upper=pars_ub, control = list(fnscale=1,trace=3,REPORT=1) ) optPars <- optim( pars,OF,#gradientOF, method = "L-BFGS-B", lower = pars_lb,upper=pars_ub, control = list(fnscale=1,trace=3,REPORT=1) ) If method != "L-BFGS-B", then the routine complains about the uses of bounds for the parameters as expected, however the trace log above reminas the same. Note also that the routine makes fine progress toward a minimum (as desired) but in the last iteration reverses course and returns a function value much larger than the starting value. What is going on here? All help is much appreciated. Michael Meyer [[alternative HTML version deleted]]
______________________________________________ R-help@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.