[Rd] Re: [R] too large alpha or beta in dbeta ? (PR#643)

maechler@stat.math.ethz.ch maechler@stat.math.ethz.ch
Fri, 25 Aug 2000 15:20:10 +0200 (MET DST)


>>>>> "TL" == Thomas Lumley <thomas@biostat.washington.edu> writes:

    TL> On Thu, 24 Aug 2000, Troels Ring wrote:
    >> Dear friends.
    >> 
    >> Is this as expected ? Is alpha and beta too large simply ?
    >> 
    >> > dbeta(.1,534,646)
    >> [1] NaN
    >> Warning message:
    >> NaNs produced in: dbeta(x, shape1, shape2, log)

    TL> well, it should work, but the correct answer is effectively zero.
    TL> pbeta(.1,534,646) gives 3.6e-213

    TL> Perhaps more worrying is 
    >> dbeta(.25,534,646)
    TL> [1] Inf
yes.
and I see that it is one case where the log-density seems to be alright:

> dbeta(.25,534,646,log=TRUE)
[1] -109.939612

and also for the NaN case :

> dbeta(.1,534,646, log=TRUE)
[1] -480.725168

A workaround is  using   exp( log-density  ), i.e.

  exp(dbeta(x,a,b, log = TRUE)) :

Look at

> plot(function(x)    dbeta(x, 534,646, log = TRUE), n = 1001)
or
> plot(function(x)exp(dbeta(x, 534,646, log = TRUE)), n = 1001)

--
I'll have a look.

Martin


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._