fisher test with multiple samples
0
1
Entering edit mode
8.4 years ago
juncheng ▴ 210

I want to apply fisher's exact test (fisher.test() function in R) to a table typically like this:

A    5    20
B    33   11
C    17   6


The p-value is 5.219e-05.

My question is , it is obvious row 'A' made the significant. However, how can I tell from the test automatically which row caused the significant value?

Thanks.

statistics • 5.0k views
4
Entering edit mode

There is no obvious way to extract that kind of information from a Fisher test, perhaps you might want to look into a Poisson regression model using your A/B/C factors as predictors

3
Entering edit mode

Binomial (logistic) regression, I think? The "counts" here are a contingency table so the model is something like

glm(cbind(m[,2], rowSums(m)) ~ LETTERS[1:3], family="binomial")

if 'm' is the matrix above. There are also likelihood ratio tests for contingency tables, something called G-tests, but not in base R

0
Entering edit mode

@David W, G-test seams also can't tell which row made significant.

The result:

Call:
glm(formula = cbind(m[, 2], rowSums(m)) ~ LETTERS[1:3], family = "binomial")

Deviance Residuals:
[1]  0  0  0

Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept)    -0.2231     0.3000  -0.744  0.45699
LETTERS[1:3]B  -1.1632     0.4513  -2.578  0.00995 **
LETTERS[1:3]C  -1.1206     0.5479  -2.045  0.04081 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1


It actually says B,C are significant. It seams 'significant' here always based on the first row.

1
Entering edit mode

You have to tell R which coeficients you want to contrast against each other - this will be determined by the design of your experiment. The result you've just shown is a bit meaningless at the moment, you should maybe have done anova(glm(...)) first - to check whether accounting for the rows improves the fit.

0
Entering edit mode

russ has set you on the right path with contrasts. I should add that I might not have been perfectly clear. This code above is not a G-test, which is a little different and related to chi squared.

0
Entering edit mode

@ russhh, Thanks. I don't really understand the model. Could you give a example how to call the model with glm, and how to tell which row made significant?

0
Entering edit mode

I might have confused you, the data isn't showing what I thought it was: I thought you had 6 different treatment pairs with the columns representing the levels of one treatment and the rows representing the levels of another treatment and the body being counts.

Stick with the binomial model if the columns represent your experimental outcomes