fisher test with multiple samples
0
1
Entering edit mode
9.8 years ago
juncheng ▴ 220

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.5k views
ADD COMMENT
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

ADD REPLY
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

ADD REPLY
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.

ADD REPLY
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.

ADD REPLY
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.

ADD REPLY
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?

ADD REPLY
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

ADD REPLY

Login before adding your answer.

Traffic: 2932 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6