[Rd] 2 x 2 chisq.test (PR#8415)

From: <cig69410_at_syd.odn.ne.jp>
Date: Tue 20 Dec 2005 - 13:28:01 GMT


Full_Name: nobody
Version: 2.2.0
OS: any
Submission from: (NULL) (219.66.34.183)

2 x 2 table, such as

> x

     [,1] [,2]
[1,] 10 12
[2,] 11 13

> chisq.test(x)

	Pearson's Chi-squared test with Yates'
	continuity correction

data: x
X-squared = 0.0732, df = 1, p-value = 0.7868

but, X-squared = 0.0732 is over corrected.

when abs(a*d-b*c) <= sum(a,b,c,d), chisq.value must be 0!, and P-value must be 1!

code of chisq.test must be as follows

 #           if (correct && nrow(x) == 2 && ncol(x) == 2) {
 #               YATES <- 0.5
 #               METHOD <- paste(METHOD, "with Yates' continuity correction")
 #           }
 #           else YATES <- 0
 #           STATISTIC <- sum((abs(x - E) - YATES)^2/E)
 ## replace begin
             if (correct && nrow(x) == 2 && ncol(x) == 2) {
                 STATISTIC <- if (abs(x[1,1]*x[2,2]-x[1,2]*x[2,1]) < sum(x)/2) 0
   
                              else sum((abs(x - E) - 0.5)^2/E)
                 METHOD <- paste(METHOD, "with Yates' continuity correction")
             }
             else STATISTIC <- sum((abs(x - E))^2/E)
 ## replace end

R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Dec 21 00:44:20 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:35 GMT