[R] Fisher's Test 5x4 table

paul brett brettpaul16 at gmail.com
Fri Aug 28 14:38:04 CEST 2015


Hi Gerrit,
             I spotted that, it was a mistake on my own part, it should
read 1.trap.2.barrier. I have corrected it on the file attached.

So I have done these so far:
 > fisher.test(Trapz, workspace = 200000, hybrid = FALSE, control = list(),
or = 1, alternative = "two.sided", conf.int = TRUE, conf.level =
0.95,simulate.p.value = FALSE, B = 2000)
Error in fisher.test(Trapz, workspace = 2e+05, hybrid = FALSE, control =
list(),  :
  FEXACT error 501.
The hash table key cannot be computed because the largest key
is larger than the largest representable int.
The algorithm cannot proceed.
Reduce the workspace size or use another algorithm.

> fisher.test(Trapz, workspace = 2000, hybrid = FALSE, control = list(), or
= 1, alternative = "two.sided", conf.int = TRUE, conf.level =
0.95,simulate.p.value = FALSE, B = 2000)
Error in fisher.test(Trapz, workspace = 2000, hybrid = FALSE, control =
list(),  :
  FEXACT error 40.
Out of workspace.
> fisher.test(Trapz, workspace = 1e8, hybrid = FALSE, control = list(), or
= 1, alternative = "two.sided", conf.int = TRUE, conf.level =
0.95,simulate.p.value = FALSE, B = 2000)
Error in fisher.test(Trapz, workspace = 1e+08, hybrid = FALSE, control =
list(),  :
  FEXACT error 501.
The hash table key cannot be computed because the largest key
is larger than the largest representable int.
The algorithm cannot proceed.
Reduce the workspace size or use another algorithm.
> fisher.test(Trapz, workspace = 2000000000, hybrid = FALSE, control =
list(), or = 1, alternative = "two.sided", conf.int = TRUE, conf.level =
0.95,simulate.p.value = FALSE, B = 2000)
Error: cannot allocate vector of size 7.5 Gb
In addition: Warning messages:
1: In fisher.test(Trapz, workspace = 2e+09, hybrid = FALSE, control =
list(),  :
  Reached total allocation of 6027Mb: see help(memory.size)
2: In fisher.test(Trapz, workspace = 2e+09, hybrid = FALSE, control =
list(),  :
  Reached total allocation of 6027Mb: see help(memory.size)
3: In fisher.test(Trapz, workspace = 2e+09, hybrid = FALSE, control =
list(),  :
  Reached total allocation of 6027Mb: see help(memory.size)
4: In fisher.test(Trapz, workspace = 2e+09, hybrid = FALSE, control =
list(),  :
  Reached total allocation of 6027Mb: see help(memory.size)

fisher.test(Trapz, workspace = 1e8, hybrid = FALSE, control = list(), or =
1, alternative = "two.sided", conf.int = TRUE, conf.level =
0.95,simulate.p.value = TRUE, B = 1e5)
Error: unexpected '>' in ">"

 So the issue could be perhaps that R cannot compute my sample as the
workspace needed is too big? Is there a way around this? I think I have
everything set out correctly.
Is my only other alternative is to do a 2x2 fisher test for each of the
variables?

I attach on the pdf the Minitab result for the Chi squared test as proof (I
know that getting very low p values are highly unlikely but sometimes it
happens). Seeing is believing i suppose!

Regards,
             Paul



On Fri, Aug 28, 2015 at 8:56 AM, Gerrit Eichner <
Gerrit.Eichner at math.uni-giessen.de> wrote:

> Dear Paul,
>
> quoting the email-footer: "PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html and provide commented,
> minimal, self-contained, reproducible code."
>
> So, what exactly did you try and what was the actual problem/error message?
>
> Besides that, have you noted that two of you data rows have the same name?
>
>
> Have you read the online help page of fisher.test():
>
>  ?fisher.test
>
>
> Have you tried anything like the following?
>
> W <- as.matrix( read.table( "w.txt", head = T)[-1])
>
> fisher.test( W, workspace = 1e8)
>    # For workspace look at the help page, but it presumably
>    # won't work because of your sample size.
>
>
> set.seed( 20150828) # for reproducibility
> fisher.test( W, simulate.p.value = TRUE, B = 1e5)
>    # For B look at the help page.
>
>
> Finally: Did Minitab really report "p > 0.001"? ;-)
>
>  Hth  --  Gerrit
>
>
> Dear all,
>>            I am trying to do a fishers test on a 5x4 table on R
>> statistics. I have already done a chi squared test using Minitab on this
>> data set, getting a result of (1, N = 165.953, DF 12, p>0.001), yet using
>> these results (even though they are excellent) may not be suitable for
>> publication. I have tried numerous other statistical packages in the hope
>> of doing this test, yet each one has just the 2x2 table.
>>            I am struggling to edit the template fishers test on R to fit
>> my table (as according to the R book it is possible, yet i cannot get it
>> to
>> work). The template given on the R documentation and R book is for a 2x2
>> fisher test. What do i need to change to get this to work? I have attached
>> the data with the email so one can see what i am on about. Or do i have to
>> write my own new code to compute this.
>>
>>             Yours Sincerely,
>>                                     Paul Brett
>>
>>
-------------- next part --------------
Traps	Insecta	Diplopoda	Arachnia	Malocostan
5.trap.4.barrier	345	77	200	154
1.trap.4.barrier	170	54	61	58
1.trap.2.barrier	232	19	30	5
1.trap.no.barrier	59	5	6	5
5.trap.no.barrier	105	11	26	37
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Chi squared test in Minitab.pdf
Type: application/pdf
Size: 144073 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20150828/8b303833/attachment.pdf>


More information about the R-help mailing list