R – Using Pearson’s Chi-Square (N-1) in R Programming

chi-squared-testr

I have two categorical variables and was looking into doing a chi-square test. I then noticed I had some low frequencies in my contingency table and thought Fisher's Exact Test may be useful. I've now come full circle after doing some reading and want to use Pearson's Chi Squared with n-1 correction. Is there a way in R to run chisq.test with the n-1 correction (discussed here: Given the power of computers these days, is there ever a reason to do a chi-squared test rather than Fisher's exact test?)?

If not, how would I apply the correction to the output of Pearson's chi-squared?

Presuming a sample size of 80:

(80-1)/80 = 0.9875

Do I simply multiply the Chi-Squared statistic by 0.9875 and then use this value to derive the p value?

2.9687 * 0.9875 = 2.931591

1-pchisq(2.931591,4)

p = 0.569338

Best Answer

According to this page the N-1 correction is very simple; just multiply $\chi^2$ by (N-1)/N. You could then use the pchisq function in R to get the right p value (the exact code would be, I believe, something like

newchisq = ((N-1)/N) * oldchisq
newp <- 1 - pchisq(newchisq, df)