On 22-01-2012, at 19:25, Eliano wrote:

> People,
> 
> I'm researching some Bayesian statistic topics and in the midle of my study
> i found a very simple problem and i'm trying to find a simple package to
> solve this type of equations:
> 
> Lets say that i need to compute beta values for the beta distribution and i
> now for example:
> 
> E(teta)=a/(a+b) = 0,5
> Var(teta)=ab/((a+b)^2(a+b+1))=0.05
> 
> So if i want to solve this to non-linear system to find a,b for the beta
> distribution wich pack should i use?
> 
> I know that a=2 and b=2 because i calculated it. 
> 

There is a package nleqslv which can handle you system.


library(nleqslv)

eqf <- function(x) {
    a <- x[1]
    b <- x[2]
    y <- numeric(2)   
    y[1] <- a/(a+b) - 0.5
    y[2] <- a*b/((a+b)^2 * (a+b+1)) -0.05
    y
}
       
x.start <- c(1,1)

nleqslv(x.start,eqf)


Berend

______________________________________________
R-help@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.

Reply via email to