Jeffrey Chang
2003-Dec-09 03:53 UTC
[R] p-value from chisq.test working strangely on 1.8.1
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 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
Torsten Hothorn
2003-Dec-09 08:23 UTC
[R] p-value from chisq.test working strangely on 1.8.1
> 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 > >
Federico Calboli
2003-Dec-10 12:50 UTC
[R] Re: p-value from chisq.test working strangely on 1.8.1
Mostly for the record, it happens also on Mandrake 9.1 with R 1.8.1 installed from rpm.>chisq.test(matrix(c(0, 1, 1, 12556), 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, 12556), 2, 2) X-squared = 1e-04, df = NA, p-value = 5e-04 Federico Calboli -- ================================ Federico C. F. Calboli PLEASE NOTE NEW ADDRESS Dipartimento di Biologia Via Selmi 3 40126 Bologna Italy tel (+39) 051 209 4187 fax (+39) 051 251 208 f.calboli at ucl.ac.uk
Seemingly Similar Threads
- chisq.test with simulate.p.value=TRUE (PR#13292)
- chisq.test using amalgamation automatically (possible ?!?)
- Why two chisq.test p values differ when the contingency table is transposed?
- 2 x 2 chisq.test (PR#8415)
- Chi-squared approximation may be incorrect in: chisq.test(x)