Use fisher.test(). Yates' correction compensates for a tendency for Chi-square to be overestimated in a 2x2 table, but Yates' can overcompensate, reducing Chi-square too much. It's main advantage was when computers were expensive and Fisher's Exact was hard to compute by hand. You can see from the following that Fisher's Exact estimates the p-value as .717, a bit less than .7477.
> M <- matrix(c(8, 12, 4, 10), 2, 2) > fisher.test(M) Fisher's Exact Test for Count Data data: M p-value = 0.717 alternative hypothesis: true odds ratio is not equal to 1 95 percent confidence interval: 0.3160571 9.7976232 sample estimates: odds ratio 1.641969 An alternative would be to let chisq.test() use simulations to estimate the p-value: > chisq.test(M, simulate.p.value=TRUE) Pearson's Chi-squared test with simulated p-value (based on 2000 replicates) data: M X-squared = 0.471, df = NA, p-value = 0.7141 Which agrees pretty well with fisher.test(). The X-squared value of 0.471 is the uncorrected value so you can see that the Yates' correction reduced it substantially (to .1035). ------------------------------------- David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -----Original Message----- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jomy Jose Sent: Tuesday, February 21, 2017 4:48 AM To: r-help@r-project.org Subject: [R] Yates correction I tried to do chi square test for the following observed frequencies --------------------------------------------------------------------------------------------- A B A 8 4 B 12 10 R gave the following output: ------------------------------------------------------------------------------------------- Pearson's Chi-squared test with Yates' continuity correction data: M X-squared = 0.10349, df = 1, p-value = 0.7477 Warning message: In chisq.test(M) : Chi-squared approximation may be incorrect --------------------------------------------------------------------------------------------------------------- Whether this result can be relied or we have to use Fishers exact test ? Jose [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.