[R] Accuracy problem in dchisq for non-central chi-squared

Uffe Høgsbro Thygesen uht at dfu.min.dk
Thu Dec 14 11:01:01 CET 2000


Hi,

I think I have identified a inaccuracy in dchisq when the non-centrality
parameter is non-zero and large. Here's a little test:

sys.dchisq.test <- function(N = 100000,mean = 0)
{
  z <- rnorm(N,mean = mean, sd = 1)
  x <- z^2
  xmin <- min(x)
  xmax <- max(x)
  br <- seq(xmin,xmax,length = 101)
  dbr <- br[2]-br[1]
  hist(x,br)
  p <- dchisq(br,df = 1,ncp = mean^2) * dbr
  lines(br,N*p)
}

par(mfrow = c(2,1))
sys.dchisq.test(mean = 10)
sys.dchisq.test(mean = 15)

Here's my version information:

platform Windows   
arch     x86       
os       Win32     
system   x86, Win32
status             
major    1         
minor    1.1       
year     2000      
month    August    
day      15        
language R         


Any comments on this one?

Best regards,

Uffe

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Uffe H. Thygesen
M.Sc.&Eng., Ph.D.
Danish Institute of Fisheries Research
http://www.dfu.min.dk


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list