1

I'm having trouble using the hyper-geometric test on a 2x2 contingency table. I have listed the null hypothesis below. enter image description here

Assuming the null hypothesis is: $$P = \frac{A}{A+B} = \frac{C}{C+D}$$ From here, how do I proceed with the hyper -geometric test? I'm aware of the equation for this test: $$P(X = k) = \frac{{a\choose x}{{N-a}\choose{n-x}}}{N \choose n}$$ where $a$ represents the number of successes.

However, how do I apply this to the contingency table.

Ultimately, I'm trying to write an algorithm that will read in data and do these calculations, hence, if there is an easier/more generalized form of this equation, I'll be interested to know.

Christian
  • 1,872
  • 4
  • 21
  • 28
  • Your equation for $P(U=C)$ doesn't seem to be consistent with your equation for $P(U\geq C)$ In particular it looks like that last power would need to be $C+D-C$ rather than $C+D-D$. 2. If you're doing a hypergeometric test, wouldn't your probabilities follow a hypergeometric rather than a binomial?
  • – Glen_b Sep 02 '17 at 07:59
  • You are absolutely right. These were equations my professor wrote and I was having trouble understanding why it made sense. I brought up the same issue with the powers on the post as well (Notice the 2nd to last paragraph). Secondly, after I posted the question, I kept researching and I realized that the equation is wrong altogether. – Christian Sep 02 '17 at 08:22
  • However, I think he had it right when he said the right test to use is a hypergeometric test. My reasons are the following: in an image clustered with bacteria, and I'm counting the ones with gene expression, I do not recount any. Hence, I'm selecting successes without replacement and the probability of success is changing. Would you agree? @Glen_b – Christian Sep 02 '17 at 08:25
  • It's not sufficiently clear here what the sampling situation is but I don't think the margins are inherently fixed. So it then comes down to whether you choose to condition because the margins are (almost) ancillary -- I believe Scortchi covered the issues relating to this already (better than I would have). If you want to ask something about that issue, put it in your question. – Glen_b Sep 02 '17 at 09:32
  • I'm a bit lost on your previous comment. if possible, can you please clarify? – Christian Sep 02 '17 at 09:51
  • I can't answer your question for sure because the situation isn't sufficiently clear here, but I believe the issues in relation to conditioning on margins were covered by Scortchi previously. 2. If you want to ask about this, put it in your question.
  • – Glen_b Sep 02 '17 at 09:55