[R] Fisher Test in R

arun smartpink111 at yahoo.com
Fri May 11 19:22:45 CEST 2012



Hi Aayush,

You are getting different results for fisher.test with

> mat2<-matrix(c(5,10,60,30), nrow=2,dimnames=list(c("Dieting","Non-Dieting"),c("Men","Women")))


is because the first test used one-tailed (alternative="greater") while the default without the alternative option is two-tailed.   One-tailed has more power, and should get a lower p-value if we select the correct option.  

For e.g. in the first option you used:

> mat <- matrix(c(10,5,30,60), nrow=2,dimnames=list(c("Dieting","Non-Dieting"),c("Men","Women")))
> fisher.test(mat,alternative="greater")

    Fisher's Exact Test for Count Data

data:  mat 
p-value = 0.01588
alternative hypothesis: true odds ratio is greater than 1 
95 percent confidence interval:
 1.319592      Inf 
sample estimates:
odds ratio 
  3.943534 

> fisher.test(mat,alternative="two.sided")

    Fisher's Exact Test for Count Data

data:  mat 
p-value = 0.02063
alternative hypothesis: true odds ratio is not equal to 1 
95 percent confidence interval:
  1.10917 16.09195 
sample estimates:
odds ratio 
  3.943534 

Here, you selected the correct one-tailed, so the p-value got reduced compared to two-tailed.

But, in the second case, the option is incorrect.  It shoud be alternative="less" to get a pvalue of 0.01588.  


Null hypothesis: There is no association between gender and dietary habits.

Alternative hypothesis: There is an association between gender and dietary habits (two-sided)
There is a positive association between gender and dietary habits (one-sided- greater)
A.K.






----- Original Message -----
From: Aayush Raman <ayushraman at gmail.com>
To: r-help at r-project.org
Cc: 
Sent: Friday, May 11, 2012 12:17 PM
Subject: [R] Fisher Test in R

Suppose we have the following data set:

                Men    Women
Dieting         10      30
Non-dieting     5       60

If I run the Fisher exact test in R then what does alternative = greater (or
less) imply? For example:

mat = matrix(c(10,5,30,60), 2,2)

fisher.test(mat,alternative ="greater")

I get the p-value = 0.01588 and odds ratio = 3.943534. Also, when I flip
the rows of the contingency table like this:

mat = matrix(c(5,10,60,30), 2,2)

fisher.test(mat,alternative ="greater")

then I get the p-value = 0.9967 and odds ratio = 0.2535796. But, when I run
the two contingency table without the alternative argument (i.e.,
fisher.test(mat)) then I get the p-value = 0.02063.

   1. Could you please explain the reason to me?
   2. Also, what is the null hypothesis and alternative hypothesis in the
   above cases?
   3.

   Can I run the fisher test on a contingency table like this:

   mat = matrix(c(5000,10000,69999,39999), 2,2)

Thanks.

PS: I am not a statistician. I am trying to learn statistics so your help
(answers in simple English) would be highly appreciated.

    [[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list