Segment 33: Contingency Table Protocols and Exact Fisher Test - 4/19/2013

Problem 1

How many distinct m by n contingency tables are there that have exactly N total events?
This is the same as trying to put N indistinguishable balls into K distinguishable bins. Thus, we have a combinatoric function to calculate this, which is C(N+K-1, K-1) to give us our total. So our answer is: C(N+mn - 1, mn-1)

Problem 2

For every distinct 2 by 2 contingency table containing exactly 14 elements, compute its chi-square statistic, and also its Wald statistic. Display your results as a scatter plot of one statistic versus the other.
Here is my codehere

Currently I'm running into a problem of how to handle zeroes. The graph looks ok if I allow at least one person per bin, but I'm not sure how to go about handling zeroes.

To Think About 1. Suppose you want to find out of living under power lines causes cancer. Describe in detail how you would do this (1) as a case/control study, (2) as a longitudinal study, (3) as a snapshot study. Can you think of a way to do it as a study with all the marginals fixed (protocol 4)? 2. For an m by n contingency table, can you think of a systematic way to code "the loop over all possible contingency tables with the same marginals" in slide 8?