Re: [R] Solving equations with optim

From: ianfiske <ianfiske_at_gmail.com>
Date: Sat, 15 Mar 2008 11:07:08 -0700 (PDT)

If you want to find the value of x such that f(x) = 0, then you can minimize f^2 or abs(f) using optim. Hope this helps,

Ian

francogrex wrote:
>
> 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-tp16070263p16070698.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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 Sat 15 Mar 2008 - 18:13:03 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 Sun 16 Mar 2008 - 09:30:22 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