[R] fisher.test - FEXACT error 7

Frank E Harrell Jr f.harrell at vanderbilt.edu
Mon Mar 23 13:24:40 CET 2009

Bernardo Rangel Tura wrote:
> On Fri, 2009-03-20 at 18:29 +0000, Helena Mouriño wrote:
>> Dear all,
>> Im having an awkward problem in R.  When I write the command
>> Fisher.test(school.data,workspace=2e+07), where school.data is the matrix
>> corresponding to the data set,
>> I get the error  message:
>> FEXACT error 7.
>> LDSTP is too small for this problem.
>> Try increasing the size of the workspace.
>> Increasing the workspace: 
>> Fisher.test(school.data,workspace=1e+10),
>> I get a different message, but it still doesnt work:
>> NAs in foreign function call (arg 10)
>> In addition: Warning message:
>> In fisher.test(dados, workspace = 1e+10, alternative = "two.sided") :
>>   NAs introduced by coercion
> Hi Helena,
> In this case you can try 3 solutions:
> 1- chisq.test(school.data), but pay attention if expected value of any
> cell is < 5 

Note that this requirement was never really checked by Pearson (as 
pointed out by Cochran) and is overly cautious.  Generally the 
Pearson-Cochran chi-square test works well much more frequently than 
previously thought, and usually better than Fisher's exact test.  See 
the reference below. -Frank

   author =               {Campbell, Ian},
   title =                {Chi-squared and {Fisher-Irwin} tests of 
two-by-two tab
les with small sample recommendations},
   journal =      Stat in Med,
   year =                 2007,
   volume =               26,
   pages =                {3661-3675},
   annote =               {2x2 table;chi-squared test;Fisher-Irwin 
test;exact tests;small sample recommendations;latest edition of 
Armitage's book recommends that continuity adjustments never be used for 
contingency table chi-square tests;E. Pearson modification of Pearson 
chi-square test, differing from the original by a factor of 
(N-1)/N;Cochran noted that the number 5 in "expected frequency less than 
5" was arbitrary;findings of published studies may be summarized as 
follows, for comparative trials:``1. Yate's chi-squared test has type I 
error rates less than the nominal, often less than half the nominal; 2. 
The Fisher-Irwin test has type I error rates less than the nominal; 3. K 
Pearson's version of the chi-squared test has type I error rates closer 
to the nominal than Yate's chi-squared test and the Fisher-Irwin test, 
but in some situations gives type I errors appreciably larger than the 
nominal value; 4. The 'N-1' chi-squared test, behaves like K. Pearson's 
'N' version, but the tendency for higher than nominal values is reduced; 
5. The two-sided Fisher-Irwin test using Irwin's rule is less 
conservative than the method doubling the one-sided probability; 6. The 
mid-P Fisher-Irwin test by doubling the one-sided probability performs 
better than standard versions of the Fisher-Irwin test, and the mid-P 
method by Irwin's rule performs better still in having actual type I 
errors closer to nominal levels."; strong support for the 'N-1' test 
provided expected frequencies exceed 1;flaw in Fisher test which was 
based on Fisher's premise that marginal totals carry no useful 
information;demonstration of their useful information in very small 
sample sizes;Yate's continuity adjustment of N/2 is a large over 
correction and is inappropriate;counter arguments exist to the use of 
randomization tests in randomized trials;calculations of worst 
cases;overall recommendation: use the 'N-1' chi-square test when all 
expected frequencies are at least 1, otherwise use the Fisher-Irwin test 
using Irwin's rule for two-sided tests, taking tables from either tail 
as likely, or less, as that observed; see letter to the editor by 
Antonio Andres and author's reply in 27:1791-1796; 2008.}

> 2- Fisher.test(school.data,workspace=2e+07,hybrid=TRUE) from Help
> For larger than  2 by 2 tables and 'hybrid = TRUE', asymptotic
>      chi-squared probabilities are only used if the 'Cochran
>      conditions' are satisfied, that is if no cell has count zero, and
>      more than 80% of the cells have counts at least 5.
> 3- Use "large tables" approach from Sir David Cox:
> Law, G. R. and Cox, D. R. and Machonochie, N. E. S. and Simpson, J. and
> Roman, E. and Carpenter, L. M. (2001) Large tables. Biostatistics
> 2(2):pp. 163-171.

Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University

More information about the R-help mailing list