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

Torsten Hothorn Torsten.Hothorn at rzmail.uni-erlangen.de
Tue Dec 9 09:23:53 CET 2003


> 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

>
> In these three calls to chisq.test, I'm varying the input matrix by
> only 1 observation, but the p-value changes by 16 orders of magnitude.
> This is reproducible on my system.  Please let me know if any other
> information would be useful.
>
> chisq.test works properly for these inputs on Mac OS X 10.3.1 with R
> 1.8.0.  I don't know if the problem is with Linux or 1.8.1.
>
> This bug looks very similar to bug 4718, which was reported in R 1.8.0
> and fixed in R 1.8.1.  They may be related.
> http://r-bugs.biostat.ku.dk/cgi-bin/R/Analyses-fixed?id=4718;
> user=guest;selectid=4718
>
> Jeff
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
>




More information about the R-help mailing list