I have been trying to use the rbeta() function to generate random beta variates with a particular mean and standard deviaiton for some simulation problems I am working on, however I am unsure of the relationship between the parameters shape1 and shape2 and the mean and standard deviation of the beta distribution. I am guessing that there is a formula for this, but I am unsure what it is. Can anyone advise me? Regards, Michael Scroggie Dr Michael Scroggie Scientist - Fauna Ecology Arthur Rylah Institute for Environmental Research Department of Natural Resources and Environment 123 Brown St Heidelberg 3084 Phone +61 3 9450 8745 Victoria Fax: +61 3 9450 8799 AUSTRALIA email: michael.scroggie at nre.vic.gov.au -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Mon, 17 Jun 2002 Michael_Scroggie at nre.vic.gov.au wrote:> > I have been trying to use the rbeta() function to generate random beta > variates with a particular mean and standard deviaiton for some simulation > problems > I am working on, however I am unsure of the relationship between the > parameters shape1 and shape2 and the mean and standard deviation of the > beta > distribution. I am guessing that there is a formula for this, but I am > unsure what it is. Can anyone advise me?There is indeed. mean = a / (a + b) var = ab / [(a + b)2 (a + b + 1)] where a=shape1, b=shape2. This is in a lot of textbooks, and is easily Googled, and you can do an example eg> var(rbeta(10000,2,1))[1] 0.05524684> 2/(3*3*4)[1] 0.05555556 to confirm that you've got the right formula. -thomas -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Michael_Scroggie at nre.vic.gov.au said:> I have been trying to use the rbeta() function to generate random beta > variates with a particular mean and standard deviaiton for some > simulation problems I am working on, however I am unsure of the > relationship between the parameters shape1 and shape2 and the mean and > standard deviation of the beta distribution. I am guessing that there > is a formula for this, but I am unsure what it is. Can anyone advise > me?This gives an excellent opportunity to find someone to check what I have done earlier and correct my equations --- I had a similar problem, and then I worked it out like this. First, the mean mu and variance sigma^2 expressed with alpha and beta are: mu = alpha/(alpha + beta) sigma^2 = (alpha*beta)/[(alpha+beta)^2 * (alpha+beta+1)] Then you need "only" solve these for alpha and beta. The following may be correct: alpha = mu*(mu^2-mu+sigma^2)/sigma^2 beta = (mu^2-mu+sigma^2)*(m-1)/sigma^2 cheers, jari oksanen -- Jari Oksanen -- Dept Biology, Univ Oulu, 90014 Oulu, Finland Ph. +358 8 5531526, cell +358 40 5136529, fax +358 8 5531061 email jari.oksanen at oulu.fi, homepage http://cc.oulu.fi/~jarioksa/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._