Optimize multiple confounded parameters using optim()

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Optimize multiple confounded parameters using optim()


I was wondering if anyone could help me with an issue I an experiencing while attempting to optimize a function with regards to multiple parameters, while setting their bounds to be dependent on one another.

Here is a basic example: say that I want to optimize the below function named "test', with regards to vector v, with the following constraint: 0<=v[1]<=v[2]<=1:
test <-function(v=c(0,1)) {return(v[2]-v[1])}

Now, calling optim() with the following settings:
res = optim(c(a,b), test, lower=c(0,a), upper=c(b,1),method="L-BFGS-B")

Yields optimized values:

It appears that the constraint was not satisfied, but the bounds still had some  affect on the result. This makes me suspect that I didn't set the lower and upper bounds correctly when calling optim().
Could you please let me know what I did wrong?

Many thanks!