[Rd] Re: [R] Bug in qchisq? (PR#875)

maechler@stat.math.ethz.ch maechler@stat.math.ethz.ch
Tue, 13 Mar 2001 10:43:54 +0100 (MET)


>>>>> "PD" == p dalgaard <p.dalgaard@biostat.ku.dk> writes:

    PD> Kenneth Cabrera <krcabrer@epm.net.co> writes:
    >> Hello developers and users:
    >> 
    >> My system fails (the computer freezes) when I use the ncp  parameter,
    >> with the lower.tail=FALSE option in the qchisq function.
    >> 
    >> qchisq(0.025,31,ncp=1,lower.tail=FALSE)

    PD> Yup, that's a bug. We have in pnchisq.c

    PD> 48   for (ux = 1.0; pnchisq(ux, n, lambda, lower_tail, log_p) < p; 
    PD> 	ux *= 2);
    PD> 49   for (lx = ux;  pnchisq(lx, n, lambda, lower_tail, log_p) > p;
    PD> 	lx *= 0.5);

    PD> but if we look at the opposite tail, we also need to reverse that
    PD> logic since pnchisq(x,...) is now decreasing in x. Otherwise the
    PD> algorithm will get stuck in one of the for loops.

Now fixed for R-devel (to become 1.3.0), together with the "FIXME" comment
a few lines above.

Martin Maechler <maechler@stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO D10	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._