From cig69410 at syd.odn.ne.jp  Tue Dec 20 14:28:01 2005
From: cig69410 at syd.odn.ne.jp (cig69410@syd.odn.ne.jp)
Date: Tue, 20 Dec 2005 14:28:01 +0100 (CET)
Subject: [Rd] 2 x 2 chisq.test (PR#8415)
Message-ID: <20051220132801.5314619A39@slim.kubism.ku.dk>

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



[Rd] 2 x 2 chisq.test (PR#8415)
cig69410@syd.odn.ne.jp