[R] hybrid in fisher.test broken?
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Mon Nov 13 22:59:21 CET 2006
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)
> fisher.test(matrix(10*1:9, nc=3),hybrid=FALSE,workspace=1e6)
Fisher's Exact Test for Count Data
data: matrix(10 * 1:9, nc = 3)
p-value = 0.3145
alternative hypothesis: two.sided
> JD
>
> ----------------------------------------------------------------------
>
>
> R : Copyright 2006, The R Foundation for Statistical Computing
> Version 2.3.1 (2006-06-01)
>
> .
> .
> .
>
> > m = matrix(10*1:9, nc=3)
> > fisher.test(m, hybrid=TRUE)
> Error in fisher.test(m, hybrid = TRUE) : FEXACT error 6.
> LDKEY is too small for this problem.
> Try increasing the size of the workspace.
> In addition: Warning message:
> 'hybrid' is ignored for a 2 x 2 table in: fisher.test(m, hybrid = TRUE)
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list