From nothnagel at medinfo.uni-kiel.de  Wed Jan 31 15:16:02 2007
From: nothnagel at medinfo.uni-kiel.de (nothnagel at medinfo.uni-kiel.de)
Date: Wed, 31 Jan 2007 15:16:02 +0100 (CET)
Subject: [Rd] Bug in 'pchisq' for x=0.0 (PR#9485)
Message-ID: <20070131141602.B2F745A7B5@slim.kubism.ku.dk>

The function 'pchisq' from the 'stats' library gives a wrong result if the
argument equals exactly zero:

# Upper tail of central 1-df chi^2 distribution
> pchisq(1         , 1, ncp=0, lower.tail = F, log.p = FALSE)
[1] 0.3173105
> pchisq(0.5       , 1, ncp=0, lower.tail = F, log.p = FALSE)
[1] 0.4795001
> pchisq(0.01      , 1, ncp=0, lower.tail = F, log.p = FALSE)
[1] 0.9203443
> pchisq(0.0001    , 1, ncp=0, lower.tail = F, log.p = FALSE)
[1] 0.9920213
> pchisq(0.00000001, 1, ncp=0, lower.tail = F, log.p = FALSE)
[1] 0.9999202
> pchisq(0.00      , 1, ncp=0, lower.tail = F, log.p = FALSE)
[1] 0   ## Should be 1.0

The error occurred with R version 2.4.0 (windows) and version 2.3.1 (linux).


Best regards,

Michael Nothnagel

---
Dr. Michael Nothnagel
Institute of Medical Informatics and Statistics, 
University of Kiel
http://capella.uni-kiel.de/
---



[Rd] Bug in 'pchisq' for x=0.0 (PR#9485)
nothnagel at medinfo.uni-kiel.de