From p.dalgaard@biostat.ku.dk  Thu Dec 13 15:50:22 2001
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 13 Dec 2001 16:50:22 +0100
Subject: [Rd] error in qbeta (PR#1201)
In-Reply-To: <x2her0xsoy.fsf@blueberry.kubism.ku.dk>
References: <200112091257.NAA17087@pubhealth.ku.dk>
 <x2her0xsoy.fsf@blueberry.kubism.ku.dk>
Message-ID: <x27krrt8zl.fsf@blueberry.kubism.ku.dk>

Peter Dalgaard BSA <p.dalgaard@biostat.ku.dk> writes:

> z.yang@ucl.ac.uk writes:

> > I noticed that qbeta is sometimes wrong and the error is not even due to the
> > beta parameters being too extreme.  I am calculating the quantiles corresponding
> > to cdf = 0.05, 0.15, ..., 0.95.  The value corresponding to cdf=0.25 is wrong
> > while all other values are correct.  
> > 
> > qbeta(0.05, 0.143891, 0.05) = 1.040850e-05   correct
> > qbeta(0.15, 0.143891, 0.05) = 0.021161       correct
> > qbeta(0.25, 0.143891, 0.05) = 3e-308         wrong (correct value is 0.457227)
> > qbeta(0.35, 0.143891, 0.05) = 0.945217       correct
> > 
> > I also used your source file qbeta.c to do the same calculation, and it seems
> > that something might be wrong in the "initial approximation", before the
> > newton-raphson iteration. 

Thanks for reporting this.

We think we have a better version in the current snapshots for 1.4.0
(available at http://www.stats.uwo.ca/faculty/murdoch/software/r-devel)

It turns out that the initial approximation simply isn't very good in
this case, it becomes negative and the algorithms sets it to a small
number. This is true of the original Fortran code too, but we had
chosen a rather smaller small number and that caused the algorithm to
converge falsely. 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] error in qbeta (PR#1201)
Peter Dalgaard BSA