I don't quite understand the difference between the two methods for performing a chi-squared test on contingency tables: summary(table()) and chisq.test() They may different results. E.g.: aa <- gl(2, 10) bb <- as.factor(c(1,2,2,2,1,2,1,2,2,2,1,2,2,2,1,1,1,2,1,1)) aa <- c(aa, aa) bb <- c(bb, bb) table(aa, bb) summary(table(aa, bb)) chisq.test(aa, bb) Could somebody give me some clues? Thanks in advance Juli -- Juli G. Pausas Centro de Estudios Ambientales del Mediterraneo (CEAM) C/ C.R. Darwin 14, Parc Tecnologic, 46980 Paterna, Valencia, SPAIN Tel: (+ 34) 96 131 8227; Fax: (+ 34) 96 131 8190 mailto:juli at ceam.es http://www.gva.es/ceam GCTE Fire Network - http://www.gva.es/ceam/FireNetwork -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
"juli g. pausas" <juli at ceam.es> writes:> I don't quite understand the difference between the two methods for > performing a chi-squared test on contingency tables: summary(table()) > and chisq.test() > They may different results. E.g.: > > aa <- gl(2, 10) > bb <- as.factor(c(1,2,2,2,1,2,1,2,2,2,1,2,2,2,1,1,1,2,1,1)) > aa <- c(aa, aa) > bb <- c(bb, bb) > table(aa, bb) > summary(table(aa, bb)) > chisq.test(aa, bb) > > Could somebody give me some clues? > Thanks in advanceThe summary method is not doing Yates' correction. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
chisq.test() uses Yates correction Use instead chisq.test(aa, bb,correct=F) and you'll get the same results Oscar 18/12/01 10:41:12, "juli g. pausas" <juli at ceam.es> escribió:>I don't quite understand the difference between the two methods for >performing a chi-squared test on contingency tables: summary(table()) >and chisq.test() >They may different results. E.g.: > >aa <- gl(2, 10) >bb <- as.factor(c(1,2,2,2,1,2,1,2,2,2,1,2,2,2,1,1,1,2,1,1)) >aa <- c(aa, aa) >bb <- c(bb, bb) >table(aa, bb) >summary(table(aa, bb)) >chisq.test(aa, bb) > >Could somebody give me some clues? >Thanks in advance > >Juli > >-- >Juli G. Pausas >Centro de Estudios Ambientales del Mediterraneo (CEAM) >C/ C.R. Darwin 14, Parc Tecnologic, >46980 Paterna, Valencia, SPAIN >Tel: (+ 34) 96 131 8227; Fax: (+ 34) 96 131 8190 >mailto:juli at ceam.es >http://www.gva.es/ceam > >GCTE Fire Network - http://www.gva.es/ceam/FireNetwork > > >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- >r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html >Send "info", "help", or "[un]subscribe" >(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch >_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ > >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear Juli, As the output from chisq.test (and the help for this function) indicates, chisq.test by default applies a Yates continuity correction. Using chisq.test(aa, bb, correct=F) produces the same result as the summary function for table objects. John At 09:41 AM 12/18/2001 +0000, juli g. pausas wrote:>I don't quite understand the difference between the two methods for >performing a chi-squared test on contingency tables: summary(table()) >and chisq.test() >They may different results. E.g.: > >aa <- gl(2, 10) >bb <- as.factor(c(1,2,2,2,1,2,1,2,2,2,1,2,2,2,1,1,1,2,1,1)) >aa <- c(aa, aa) >bb <- c(bb, bb) >table(aa, bb) >summary(table(aa, bb)) >chisq.test(aa, bb) > >Could somebody give me some clues? >Thanks in advance----------------------------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 email: jfox at mcmaster.ca phone: 905-525-9140x23604 web: www.socsci.mcmaster.ca/jfox ----------------------------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>>> "juli g. pausas" <juli at ceam.es> 12/18/01 05:52 AM >>> > I don't quite understand the difference between the > two methods for > performing a chi-squared test on contingency > tables: summary(table()) > and chisq.test() > They may different results. E.g.: > > aa <- gl(2, 10) > bb <- as.factor(c > (1,2,2,2,1,2,1,2,2,2,1,2,2,2,1,1,1,2,1,1)) > aa <- c(aa, aa) > bb <- c(bb, bb) > table(aa, bb) > summary(table(aa, bb)) > chisq.test(aa, bb) > > Could somebody give me some clues? > Thanks in advance > > Juli>From help(chisq.test):correct: a logical indicating whether to apply continuity correction when computing the test statistic. Setting correct=F gives the same answer as summary.table. Sundar -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._