Thanks. I have used factorial(), because I thought that formula looks easier when you change rows, columns. It shows that all equation stay the same.
I have a contingency table which look like that:
matrix(c(0, 7, 2, 13), 2, 2)
So I started to think that those three contingency tables are the same:
matrix(c(2, 13, 0, 7), 2, 2)
matrix(c(7, 0, 13, 2), 2, 2)
matrix(c(13, 2, 7, 0), 2, 2)
There are only rows or/and columns permutations. According to fisher exact test, I think it is no matter. Look at the example paragraph, there is an equation.
Can you explain me why I have different results and I have to correct it by changing alternative argument? Equation's implementation and build in function strange usages is presented below:
fisher.test(matrix(c(0, 7, 2, 13), 2, 2), alternative = "less")
fisher.test(matrix(c(2, 13, 0, 7), 2, 2), alternative = "greater")
fisher.test(matrix(c(7, 0, 13, 2), 2, 2), alternative = "greater")
fisher.test(matrix(c(13, 2, 7, 0), 2, 2), alternative = "less")
(factorial(2)*factorial(20)*factorial(7)*factorial(15))/(factorial(2)*factorial(0)*factorial(13)*factorial(7)*factorial(22))
1 answer
This is kind of off-topic for this site, but anyway...
With alternative="greater" you're asking, "Is there more signal in the upper right and lower left corners than expected?". Consequently, you can transpose the matrix and get the same thing, but if you do any other transformation then you end up testing something different.
alternative="lesser" is then looking for more signal in the upper left and lower right corners. two.sided then requires a greater imbalance, but then in either set of corners.
BTW, the choose() function in R would make your example simpler.
Log in to answer this question.