Friday, 7 August 2015

Fisher's exact test in R

I always have trouble remembering how to do the Fisher's exact test in R.

So here it is!

To test whether 393/1832 is significantly different from 2/36:

> fisher.test(matrix(c(393,2,1832-393,36-2),nrow=2))
    Fisher's Exact Test for Count Data

data:  matrix(c(393, 2, 1832 - 393, 36 - 2), nrow = 2)
p-value = 0.02115
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
  1.180687 40.036943
sample estimates:
odds ratio
  4.640479

The P-value is 0.02115.

No comments:

Post a Comment