Question: fisher test with multiple samples
1
gravatar for juncheng
6.6 years ago by
juncheng200
köln
juncheng200 wrote:

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.

 

 

statistic • 3.9k views
ADD COMMENTlink modified 6.5 years ago by Biostar ♦♦ 20 • written 6.6 years ago by juncheng200
4

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 REPLYlink written 6.6 years ago by russhh5.5k
3

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 REPLYlink modified 6.6 years ago • written 6.6 years ago by David W4.8k

@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 REPLYlink modified 6.6 years ago • written 6.6 years ago by juncheng200
1

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 REPLYlink written 6.6 years ago by russhh5.5k

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

ADD REPLYlink written 6.6 years ago by David W4.8k

@russ_hyde, 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 REPLYlink modified 6.6 years ago • written 6.6 years ago by juncheng200

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 REPLYlink written 6.6 years ago by russhh5.5k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 974 users visited in the last hour
_