Re: [R] strange fisher.test result

From: Thomas Lumley <>
Date: Tue 03 Apr 2007 - 14:39:27 GMT

On Mon, 2 Apr 2007, wrote:
>> From the above, the marginal totals for his 2x2 table
> a b = 16 8
> c d 15 24
> are (rows then columns) 24,39,31,32
> These fixed marginals mean that the whole table is determined
> by the value of a. The following function P.FX() computes the
> probabilities of all possible tables, conditional on the
> marginal totals (it is much more transparent than the code
> for the same purpose in fisher.test()):

As this example has shown, 2x2 tables are a nice opportunity for illustrating how the ordering of the sample space affects inference (because you can actually see the whole sample space).

I used something like this as a term project in an introductory R class, where we wrote code to compute the probabilities for all outcomes conditional on one margin, and used this to get (conservative) exact versions of all the popular tests in 2x2 tables. It's interesting to do things like compare the rejection regions and power under various alternatives for the exact versions of the likelihood ratio test and Fisher's test. We didn't get as far as confidence intervals, but the code is at with .Rd files at

[credits: this is all based on ideas from Scott Emerson]


Thomas Lumley			Assoc. Professor, Biostatistics	University of Washington, Seattle

______________________________________________ mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Wed Apr 04 00:58:03 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 03 Apr 2007 - 16:30:52 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.