[R] Why two chisq.test p values differ when the contingency

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Wed Jul 16 12:33:28 CEST 2003


"Shi, Tao" <shidaxia at yahoo.com> writes:

> Hi, Ted:
>  
> I guess this problem is platform-dependent. I just tied it on a R
> 1.6.1 runing on Win2K, it gave me two different p values. But when I
> tried it on R1.7.0 on a Linux Server, I got the similar result as
> you did. I have filed a bug-report as Peter suggested.

And to add to the confusion, I checked it on r-devel (1.8.0-pre) on
Redhat Linux, so it is likely to be compiler dependent too. 

[As we have seen in another thread, you cannot trust "==" with floating
point operations. There are cases where you don't even get x==y
when x and y are computed in the exact same way! Optimizing compilers
will do that to you quite easily. With Intel chips, the typical issue
is that a double is stored in 8 bytes but the FPU uses 10 bytes
internally. Generally, this increases precision, but you can end up
comparing a value to a truncated value of itself if one instance is
stored in memory and the other is in an FPU register.]

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list