[R] Solving equations with optim

francogrex francogrex at mail.com
Sat Mar 15 18:23:48 CET 2008


Hello, optim searches for min (or max) of a function, but is it possible to
solve for a specific value? I mean, I want to find the value of a and b that
give the function value closest to ZERO (and not min or max) in the below.
is it possible? thanks

test=function(x){
a=x[1]
b=x[2]
if (all(x>0))(((a/(a+b))*(beta(a,b)/(beta(a,b)-beta(a,b+6))))-0.35259)
else Inf
}
optim(c(1,2),test)

-- 
View this message in context: http://www.nabble.com/Solving-equations-with-optim-tp16070263p16070263.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list