[R] help on fisher.test(stats)?
Stefan Grosse
singularitaet at gmx.net
Mon Jul 9 09:53:41 CEST 2007
-------- Original Message --------
Subject: [R] help on fisher.test(stats)?
From: zhijie zhang <epistat at gmail.com>
To: R-help at stat.math.ethz.ch
Date: 09.07.2007 09:03
> Dear friends,
> My dataset have many zeros, so i must use fisher exact test .
> Unfortunately, the fisher.test(stats) function fail to do it.
> Anybody knows how to do the fisher exact test with many zeros in the
> dataset?
> My dataset is:
> a<-matrix(c(0,1,0,0,0,0,1,0,1,0,0,0,0,1,0,1,1,0,2,1,5,1,1,6,4,4,1,17,2,8,5,7,1,1,24,3,6,1,1,3,2,16,7,4,0,2,4,0,17,0,1,0,0,0,1,2),nrow=8,byrow=TRUE)
> data.frame(a)
> b<-a[,-7]
> as.matrix(b)
> c<-as.matrix(b)
>
>
>> c
>>
> [,1] [,2] [,3] [,4] [,5] [,6]
> [1,] 0 1 0 0 0 0
> [2,] 0 1 0 0 0 0
> [3,] 0 1 1 0 2 1
> [4,] 1 1 6 4 4 1
> [5,] 2 8 5 7 1 1
> [6,] 3 6 1 1 3 2
> [7,] 7 4 0 2 4 0
> [8,] 0 1 0 0 0 1
>
>> fisher.test(c,workspace=200000000000000000)
>>
> ŽíÎóÓÚfisher.test(c, workspace = 2e+17) :
> ÍâœÓº¯Êýµ÷ÓÃÊ±²»ÄÜÓÐNA(arg10)
> ŽËÍâ: Warning message:
> Ç¿ÖÆžÄ±ä¹ý³ÌÖÐ²úÉúÁËNA
>
> Any suggestion or help are greatly appreciated.
>
Your workspace is by far to large. I have done it with
> fisher.test(c,workspace=40000000)
Fisher's Exact Test for Count Data
data: c
p-value = 0.01548
alternative hypothesis: two.sided
(btw. it took half an hour...)
Simulation would also be an alternative approach:
> fisher.test(c,simulate=T)
Fisher's Exact Test for Count Data with simulated p-value (based
on 2000 replicates)
data: c
p-value = 0.01349
alternative hypothesis: two.sided
As you see the p-value is not that different, you could use more
replications:
> fisher.test(c,simulate=T,B=1000000)
Fisher's Exact Test for Count Data with simulated p-value (based
on 1e+06 replicates)
data: c
p-value = 0.01514
alternative hypothesis: two.sided
and it is still much faster...
Stefan
-=-=-
... The most incomprehensible thing about the world is that it is
comprehensible. (A. Einstein)
More information about the R-help
mailing list