[R] optimized value worse than starting Value

Ravi Varadhan rvaradhan at jhmi.edu
Wed Sep 8 16:08:07 CEST 2010


Dieter Menne had already told you what the problem is.  You have 2 local
minima.  One is a global minimum.  Depending on your starting interval, the
optimizer can converge to one of the two local minima. If you want to be
reasonably sure that you always find the global minimum, you either have to
use problem-specific knowledge or try a sufficiently large number of
starting values and pick the best solution.  Here is one approach:

require(BB)
p0 <- matrix(rnorm(20), 20, 1)  # 20 random starting values
ans <- multiStart(par=p0, fn=f, action="optimize", P=c(0.99,1.01), U=c(1,0))
ans

Hope this helps,
Ravi.

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Michael Bernsteiner
Sent: Wednesday, September 08, 2010 8:36 AM
To: r-help at r-project.org
Subject: [R] optimized value worse than starting Value


Dear all,

I'm optimizing a relatively simple function. Using optimize the optimized
parameter value is worse than the starting.
why?

f<-function(delta,P,U){
    minimiz<-P+delta*U
    x<-minimiz[1]
    y<-minimiz[2]
    z<-100*(y-x^2)^2+(1-x)^2
    return(z)
}
  
result<-optimize(f, interval=c(-10, 10), P=c(0.99,1.01), U=c(1,0))
result

Output:

> result<-optimize(f, interval=c(-10, 10), P=c(0.99,1.01), U=c(1,0))
> result
$minimum
[1] -1.990015

$objective
[1] 4.01

Function Value at Starting Point with free parameter=0:

> f(0,c(0.99,1.01),c(1,0))
[1] 0.089501


It seems as if optimize doesn't check the whole interval.

> result<-optimize(f, interval=c(-1, 10), P=c(0.99,1.01), U=c(1,0))
> result
$minimum
[1] 0.01497394

$objective
[1] 2.481504e-05


Changing the lower interval value leads to the result I am looking for. How
do I find this result when I have no idea where the optimal values lies and
want to look in an interval that is as wide as possible?
any ideas?

Michael


 		 	   		  
	[[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.



More information about the R-help mailing list