[R] strange fisher.test result
Thomas Lumley
tlumley at u.washington.edu
Tue Apr 3 16:39:27 CEST 2007
On Mon, 2 Apr 2007, ted.harding at nessie.mcc.ac.uk 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
http://faculty.washington.edu/tlumley/b514/exacttest.R
with .Rd files at
http://faculty.washington.edu/tlumley/b514/man/
[credits: this is all based on ideas from Scott Emerson]
-thomas
Thomas Lumley Assoc. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
More information about the R-help
mailing list