[R] hybrid in fisher.test broken?

Jonathan Dushoff dushoff at eno.princeton.edu
Mon Nov 13 23:30:44 CET 2006


Thank you very much for this useful response.  

I did a search for fexact both inside R and on R-project.org before
posting: can somebody tell me where I could have found this information?

In particular, I am still not clear on whether the Cochran criteria are
being tested.

Thanks,

JD

----------------------------------------------------------------------

Jonathan Dushoff <dushoff at eno.princeton.edu> writes:

> The hybrid feature in fisher.test looks to me like an excellent way to
> analyze my two-way tables.   The only problem is that it does not seem
> to be implemented.  Am I right about this?
> 
> An example is pasted below.  I note that I get the warning message only
> when I shouldn't: for a 2x2 table hybrid seems to be ignored without
> warning.  In no case does fisher.test seem to be checking Cochran
> criteria as promised.
> 
> Any help will be appreciated.


Well, something seems to have been mangled in connection with these
changes: 

------------------------------------------------------------------------
r36358 | ripley | 2005-11-15 17:50:12 +0100 (Tue, 15 Nov 2005) | 2
lines

add simulation option to fisher.test

------------------------------------------------------------------------
r36266 | ripley | 2005-11-10 22:19:34 +0100 (Thu, 10 Nov 2005) | 2
lines

move 2x2 case in fisher.test to similar code as that used for or != 1

------------------------------------------------------------------------

so that the warning 

        else if (hybrid) {
            warning("'hybrid' is ignored for a 2 x 2 table")

now appears inside

    if (nr != 2 || nc != 2) {

which is clearly wrong.

However, the call to "fexact" that follows does have parameters set
for the hybrid algorithm, so it's just the warning that is spurious.
Notice that the hybrid algorithm may save a bit of time on probability
calculations, but still needs to generate a large number of tables, so
you really do need a larger workspace:

> fisher.test(matrix(10*1:9, nc=3),hybrid=TRUE,workspace=1e6)

        Fisher's Exact Test for Count Data

data:  matrix(10 * 1:9, nc = 3) 
p-value = 0.3149
alternative hypothesis: two.sided 

Warning message:
'hybrid' is ignored for a 2 x 2 table in: fisher.test(matrix(10 * 1:9,
nc = 3), hybrid = TRUE, workspace = 1e+06) 

whereas (notice the slightly different p value)

.
.
.



More information about the R-help mailing list