From p.dalgaard@biostat.ku.dk  Sat Mar 10 01:24:18 2001
From: p.dalgaard@biostat.ku.dk (p.dalgaard@biostat.ku.dk)
Date: Sat, 10 Mar 2001 02:24:18 +0100 (MET)
Subject: [Rd] Re: [R] Bug in qchisq? (PR#875)
Message-ID: <200103100124.CAA25085@pubhealth.ku.dk>

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)

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

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

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

(Mailed to r-bugs)
-- 
   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] Re: [R] Bug in qchisq? (PR#875)
p.dalgaard@biostat.ku.dk