Skip to content
Prev 30974 / 398506 Next

fisher exact vs. simulated chi-square

Dear All,

I have a problem understanding the difference between the outcome of a
fisher exact test and a chi-square test (with simulated p.value).

For some sample data (see below), fisher reports p=.02337. The normal
chi-square test complains about "approximation may be incorrect",
because there is a column with cells with very small values. I
therefore tried the chi-square with simulated p-values, but this still
gives p=.04037. I also simulated the p-value myself, using r2dtable,
getting the same result, p=0.04 (approx).

Why is this substantially higher than what the fisher exact says? Do
the two tests make different assumptions? I noticed that the
discrepancy gets smaller when I increase the number of observations
for column A3. Does this mean that the simulated chi-square is still
sensitive to cells with small counts, even though it does not give me
the warning?


Thanks in advance,
Dirk Janssen

------------------------------------------------------------------
dimnames=list(c("A","B","C"),c("A1","A2","A3")))
A1 A2 A3
A 45 32  1
B 85 40  2
C 27 34  1
Fisher's Exact Test for Count Data

data:  ta
p-value = 0.02337
alternative hypothesis: two.sided
Pearson's Chi-squared test with simulated p-value (based on 1e+05
	replicates)

data:  ta
X-squared = 9.6976, df = NA, p-value = 0.04037
Pearson's Chi-squared test

data:  ta
X-squared = 9.6976, df = 4, p-value = 0.04584

Warning message:
Chi-squared approximation may be incorrect in: chisq.test(ta)


# simulate values by hand, based on r2dtable example
>= meanSqResid(ta))/ 100000
[1] 0.03939

#  is  similar to
function(x) { chisq.test(x)$statistic })
      >= 9.6976)/ 100000
[1] 0.04044
There were 50 or more warnings (use warnings() to see the first 50)