[R] p-value from chisq.test working strangely on 1.8.1

Marc Schwartz MSchwartz at medanalytics.com
Tue Dec 9 14:55:01 CET 2003


On Tue, 2003-12-09 at 02:23, Torsten Hothorn wrote:
> > Hello everybody,
> >
> > I'm seeing some strange behavior on R 1.8.1 on Intel/Linux compiled
> > with gcc 3.2.2.  The p-value calculated from the chisq.test function is
> > incorrect for some input values:
> >
> >
> >  > chisq.test(matrix(c(0, 1, 1, 12555), 2, 2), simulate.p.value=TRUE)
> >
> >          Pearson's Chi-squared test with simulated p-value (based on 2000
> >          replicates)
> >
> > data:  matrix(c(0, 1, 1, 12555), 2, 2)
> > X-squared = 1e-04, df = NA, p-value = 1
> >
> >  > chisq.test(matrix(c(0, 1, 1, 12556), 2, 2), simulate.p.value=TRUE)
> > [...]
> > data:  matrix(c(0, 1, 1, 12556), 2, 2)
> > X-squared = 1e-04, df = NA, p-value = < 2.2e-16
> >
> >  > chisq.test(matrix(c(0, 1, 1, 12557), 2, 2), simulate.p.value=TRUE)
> > [...]
> > data:  matrix(c(0, 1, 1, 12557), 2, 2)
> > X-squared = 1e-04, df = NA, p-value = 1
> >
> 
> this does not happen with R-1.8.1 and gcc 2.95.4 on Debian stable:
> 
> R> chisq.test(matrix(c(0, 1, 1, 12555), 2, 2),
> simulate.p.value=TRUE)$p.value
> [1] 1
> R> chisq.test(matrix(c(0, 1, 1, 12556), 2, 2),
> simulate.p.value=TRUE)$p.value
> [1] 1
> R> chisq.test(matrix(c(0, 1, 1, 12557), 2, 2),
> simulate.p.value=TRUE)$p.value
> [1] 1
> 
> neither with R-1.9.0 (unstable). Is this reproducible without using
> `set.seed' on your system?
> 
> Best,
> 
> Torsten


<snip>

Confirmed on Fedora Core 1 with R Version 1.8.1 Patched (2003-12-07)
compiled using "gcc (GCC) 3.3.2 20031107 (Red Hat Linux 3.3.2-2)".


> chisq.test(matrix(c(0, 1, 1, 12555), 2, 2), simulate.p.value=TRUE)
...
X-squared = 1e-04, df = NA, p-value = 1

> chisq.test(matrix(c(0, 1, 1, 12556), 2, 2), simulate.p.value=TRUE)

X-squared = 1e-04, df = NA, p-value = < 2.2e-16
...
> chisq.test(matrix(c(0, 1, 1, 12557), 2, 2), simulate.p.value=TRUE)
...
X-squared = 1e-04, df = NA, p-value = 1


HTH,

Marc Schwartz




More information about the R-help mailing list