[R] disturbing seed dependence in optim L-BFGS-B method

From: Bob Reilly <rjreilly_at_starband.net>
Date: Tue, 15 Apr 2008 18:59:12 -0400


The the use of optim with the L-BFGS-B method for the following simple function gives erroneous results. Any help appreciated!

Best,
Bob Reilly

# Code:

V=function(p){
p1=p[1];p2=p[2]
y=p1*p2-.4*(p1+p2)
return(-y)}

p=c(.2,.2) # p=c(.8,.8)

max=optim(p,V,method = "L-BFGS-B",lower=c(0,0),upper=c(1,1)) max1=optim(max$par,V,method = "L-BFGS-B",lower=c(0,0),upper=c(1,1)) max2=optim(max1$par,V,method = "L-BFGS-B",lower=c(0,0),upper=c(1,1))

max$par
max1$par
max2$par

-max2$value

-V(c(1,1)) # true maximum occurs at c(1,1)
# setting the seed to p=c(.8,.8) will find it



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. Received on Wed 16 Apr 2008 - 00:57:18 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 16 Apr 2008 - 02:30:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive