[R-sig-ME] Optimize multiple confounded parameters using optim()
Keren Halabi
h@l@bikeren @ending from gm@il@com
Thu May 17 13:07:10 CEST 2018
Dear list,
My apologies in advance if this is not the relevant forum for the below
question.
I wish to define a codon site model, which is mixture model over multiple
dN/dS ratios.
Thus, I want to constrain each dN/dS ratio by its preceding ratio in the
mixture and its following ratio in the mixture. I was thinking of using the
bounds parameter of the optim() function to achieve this.
However, I am experiencing an issue while attempting to optimize a function
with regards to multiple parameters. Specifically, due to setting the
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:
a=0
b=1
res = optim(c(a,b), test, lower=c(0,a), upper=c(b,1),method="L-BFGS-B")
Yields optimized values:
a=1
b=0
test(c(a,b))=-1
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!
Keren
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list