fisher.test function error

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

fisher.test function error

Eshi Vaz
Dear All,

When trying to computer a fisher’s exact test using the fisher.test function from the gmodels() package, R-Studio gave me an error:

 Bug in FEXACT: gave negative key.

I used a workspace of 2e+07. I would really appreciate your help as I do not know how to resolve the issue, especially because I am a novice at R-Programming.

Thank you so much,

Eshi.
        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: fisher.test function error

David Winsemius

> On Mar 30, 2017, at 2:51 AM, Eshi Vaz <[hidden email]> wrote:
>
> Dear All,
>
> When trying to computer a fisher’s exact test using the fisher.test function from the gmodels() package, R-Studio gave me an error:

Seems unlikely that Rstudio would generate an error message about R code. It's just  a shell around the R interpreter.

> Bug in FEXACT: gave negative key.

I do not see the word "key" in any of the error messages from stats::fisher.test. Error message do not generally use the word "bug" either. You should post the exact error message copied from the console display,

>
> I used a workspace of 2e+07. I would really appreciate your help as I do not know how to resolve the issue, especially because I am a novice at R-Programming.

What is needed is the exact code used and some sort of effort at delivering a reproducible example. The function fisher.test is most likely not from the gmodels package but rather from the stats-package. You should be able to see this by typing this at the console:

fisher.test  
# when I do this  I see `<environment: namespace:stats>` as the last line
# ... and there is no fisher.test in the gmodels Index page


Please read the Posting Guide and see if you can respond with a reproducible example. Postings to Rhelp should be in plain text, since postings in HTML are likely to be corrupted.

Best;
David.

>
> Thank you so much,
>
> Eshi.
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.

David Winsemius
Alameda, CA, USA

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: fisher.test function error

Stefan Evert-3
In reply to this post by Eshi Vaz

> On 30 Mar 2017, at 11:51, Eshi Vaz <[hidden email]> wrote:
>
> When trying to computer a fisher’s exact test using the fisher.test function from the gmodels() package,  <----

The problem seems to be with a different fisher.test() function from the gmodels package, not with stats::fisher.test.

The usual recommendation is to contact the package authors for help.

Best regards,
Stefan
______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: fisher.test function error

Peter Dalgaard-2

> On 31 Mar 2017, at 14:04 , Stefan Evert <[hidden email]> wrote:
>
>
>> On 30 Mar 2017, at 11:51, Eshi Vaz <[hidden email]> wrote:
>>
>> When trying to computer a fisher’s exact test using the fisher.test function from the gmodels() package,  <----
>
> The problem seems to be with a different fisher.test() function from the gmodels package, not with stats::fisher.test.

That's what I thought, but there is no fisher.test variant in gmodels. There is CrossTable, which calls fisher.test in its print method, but as far as I can tell, that is the usual one from stats.

At any rate, it would be useful to know what the table looks like. If has a huge number of rows or columns then

(a) it could be the result of a coding blunder
(b) be quite meaninglesss to attack with a fisher exact test


-pd

>
> The usual recommendation is to contact the package authors for help.
>
> Best regards,
> Stefan
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.

--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: [hidden email]  Priv: [hidden email]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: fisher.test function error

Marc Schwartz-3
In reply to this post by Stefan Evert-3

> On Mar 31, 2017, at 7:04 AM, Stefan Evert <[hidden email]> wrote:
>
>
>> On 30 Mar 2017, at 11:51, Eshi Vaz <[hidden email]> wrote:
>>
>> When trying to computer a fisher’s exact test using the fisher.test function from the gmodels() package,  <----
>
> The problem seems to be with a different fisher.test() function from the gmodels package, not with stats::fisher.test.
>
> The usual recommendation is to contact the package authors for help.
>
> Best regards,
> Stefan


There is no fisher.test() function in the gmodels package.

The error message is being generated from compiled code in stats::fisher.test().

A Google search for the error message indicates that there are reports going back at least as far as 2002, suggesting that the underlying issue is an integer overflow:

  https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=1662

with at least one example resolved back in 2005:

  https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=6986

The former report has recent reports from 2014/2015 suggesting that the original 2002 issue is still present, at least in specific situations:

d4 <- matrix(c(0, 0, 0, 0, 0,  0, 3, 0, 1, 0,  0, 0, 0, 0, 0,
               1, 0, 0, 0, 0,  1, 0, 0, 2, 0,  0, 0, 1, 0, 0,
               0, 1, 0, 1, 0,  4, 0, 2, 0, 0,  0, 1, 0, 0, 0,  0, 0, 0, 0, 0,
               0, 1, 0, 0, 2,  0, 0, 0, 2, 2,  0, 1, 0, 0, 0,
               0, 0, 1, 1, 0,  0, 0, 0, 0, 0,  0, 1, 0, 0, 0,
               1, 0, 0, 0, 2,  0, 0, 0, 3, 0,  0, 0, 0, 0, 1,  0, 0, 0, 0, 0,
               2, 0, 0, 0, 0,  0, 0, 0, 0, 0,  0, 0, 1, 0, 1,
               0, 0, 0, 0, 2,  0, 0, 0, 0, 8,  0, 0, 0, 3, 0,
               0, 0, 0, 0, 0,  0, 0, 0, 0, 0,  0, 0, 0, 0, 0,  0, 0, 0, 0, 1,
               0, 0, 1, 0, 0,  0, 0, 0, 0, 0,  2, 0, 0, 1, 0,
               0, 2, 0, 0, 0,  0, 2, 0, 0, 1,  3, 0, 0, 0, 0,
               0, 0, 0, 0, 0,  0, 0, 0, 0, 1,  0, 0, 1, 0, 0,  4, 0, 0, 0, 0),
             nr=50)

> fisher.test(d4)
Error in fisher.test(d4) : FEXACT error 30.
Stack length exceeded in f3xact.
This problem should not occur.


tab <- structure(list(V1 = c(1, 0, 0, 0, 0, 0),
                      V2 = c(323, 4, 1, 0, 0, 22),
                      V3 = c(3, 0, 0, 0, 0, 1),
                      V4 = c(2, 0, 1, 0, 1, 3),
                      V5 = c(1, 0, 0, 0, 0, 4),
                      V6 = c(1, 0, 0, 0, 0, 0),
                      V7 = c(0, 0, 0, 1, 0, 1),
                      V8 = c(96, 0, 0, 0, 0, 2)),
                      .Names = c("V1", "V2", "V3", "V4", "V5", "V6", "V7", "V8"),
                      class = "data.frame", row.names = c(NA, -6L))

> fisher.test(tab)
Error in fisher.test(tab) : Bug in FEXACT: gave negative key


Note that in the second example, the data frame is coerced to a matrix inside fisher.test().

The above two examples were run using R version 3.3.3 on macOS 10.12.4 in a CLI console.

Regards,

Marc Schwartz

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.