On Sat, 15 Mar 2008, ianfiske wrote:
>
> 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,
For all but the (default) Nelder-Mead method you will be better off with
f^2 or some other differentiable function than abs(f), sin
There is one obvious way:
> test <- function(x, value = 0) {
a <- x[1]
b <- x[2]
ex <- if (all(x > 0))
(((a/(a+b))*(beta(a,b)/(beta(a,b)-beta(a,b+6-0.35259)
else Inf
(ex - value)^2
}
> opt <- optim(c(1,2),test)
>
> opt[c("par", "value")]
$par
[1] 0.514127
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 a
3 matches
Mail list logo