From z.yang@ucl.ac.uk  Mon Dec 17 10:03:34 2001
From: z.yang@ucl.ac.uk (Ziheng Yang)
Date: Mon, 17 Dec 2001 10:03:34 +0000
Subject: [Rd] error in qbeta (PR#1201)
In-Reply-To: <x27krrt8zl.fsf@blueberry.kubism.ku.dk>
References: <x2her0xsoy.fsf@blueberry.kubism.ku.dk> <200112091257.NAA17087@pubhealth.ku.dk> <x2her0xsoy.fsf@blueberry.kubism.ku.dk>
Message-ID: <4.3.2.7.2.20011216113200.00d48c50@pop-server.ucl.ac.uk>

Thanks for the update.  I set the value to half the cdf (alpha) myself, and 
it worked for that particular case, but I suppose the initial approximation 
should not generate values out of range and so one should do better than 
that.  I'll do some checking and let you know if I notice anything strange.

Would you mind sending me a copy of the source qbeta.c?

Best wishes,
Ziheng


At 16:50 13/12/01 +0100, Peter Dalgaard BSA wrote:
>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)
Ziheng Yang