3.11111

3.1 | 10 ratings Rate this file 21 Downloads (last 30 days) File Size: 3.88 KB File ID: #5957

Fisherextest

by

 

30 Sep 2004 (Updated )

Fisher's Exact Probability Test.

| Watch this File

File Information
Description

This file performs the Fisher exact probability test for a table of frequency data cross-classified according to two categorical variables, each of which has two levels or subcategories (2x2). It is a non-parametric statistical test used to determine if there are nonrandom associations between the two categorical variables. Fisher's exact test is used to calculate an exact P-value with small number of expected frequencies, for which the Chi-square test is not appropriate (in case the total number of observations is less than 20 or the number of frequency cells are less than 5). This test is based upon the hypergeometric probability. The test was proposed in the 1934 edition of the famous Ronald Aylmer Fisher's book 'Statistical Methods for Research Workers'.

It needs to input the four frequency cells.

The output consists of the negative, positive and both P-values. [decide to use Left, Right or 2-Tail before collecting (or looking at) the data].

If user does not put any output arguments, file returns a P-value table.

Acknowledgements

This file inspired H Wtest.

MATLAB release MATLAB 5.3 (R11)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (18)
17 Sep 2012 Chris

Again, there seems to be a problem with one sided tests:

Fisher's exact test P-values for cells:
a = 10, b = 1, c = 1, d = 10
----------------------------------------------
P-value
----------------------------------------------
Left tail Right tail 2-tail
(negative) (positive) (both)
----------------------------------------------
0.0001729437 0.9999985824 0.0003458873
----------------------------------------------
>> Fisherextest(1,10,10,1)

Fisher's exact test P-values for cells:
a = 1, b = 10, c = 10, d = 1
----------------------------------------------
P-value
----------------------------------------------
Left tail Right tail 2-tail
(negative) (positive) (both)
----------------------------------------------
0.0001729437 0.9999985824 0.0003458873
----------------------------------------------

13 Jan 2012 Andrew Z

I think this function (or rather the help section at the beginning of the function) switches Ppos and Pneg. They are switched around.

16 Jun 2011 Tobias

I second Trevor Agus' 1st comment. What's up with the 1-sided tests?!

14 Feb 2011 Trevor Agus

Sorry, I've spotted a school-boy error in that second test -- the proportionSignicant were closer to p = 0.05 when I corrected it. I'd still be interested to be corrected on my first post. (And apologies for having a conversation with myself on the comments board.)

14 Feb 2011 Trevor Agus

I've just tested this program with some random numbers, on the assumption that it should give significant (p<.05) results just on 1/20 of the trials. I get significant results on 1/3 of trials. Unless someone corrects me, I'm going to assume that this code does not do what it claims to do.

Here's my test code, in one ugly line:
counter=0; N=10000; for ii=1:N; [ppos,pneg,either]=Fisherextest(ceil(rand*20),ceil(rand*20),ceil(rand*20),ceil(rand*20)); if either<=.05; counter=counter+1; end; end; proportionSignificant=counter/N

14 Feb 2011 Trevor Agus

Am I misunderstanding something, or is there a serious bug in the 1-tailed tests? The following two lines give the same outputs:
[ppos,pneg]=Fisherextest(1,10,10,1)
[ppos,pneg]=Fisherextest(10,1,1,10)
In fact, ppos seems to be always greater or equal to pneg, whereas it should be possible to have significant 1-sided results on both sides.

30 Nov 2009 Alex Garcia Lancaster

do you have it for 4x2 contingency tables? that would be great!

12 Sep 2008 Ji Cling

Michael, dispite your regular visits the 10 000 self dowloads continue.

(It is not an exagerated figure)

01 Nov 2007 Michael Hamman

My Dear Ji Cling,

Regularly I visit this FEX site in which excellent contributions for the fast solution of diverse types of problems in several disciplines have been given. The accusation that you are causing is very delicate. I do not know you. Neither the authors. We known them only by the references given in their author page. Only what I believe is in the quality of ethics of each one of them and ours. We are serious people dedicated to our work in the most diverse specialties. To be certain what you say. Then not alone this author does cheating but also all the others. Even you, that in principle, I think you are not signing with your true name. Finally, or really the community are honestly dawnloaded the m-files or finally someone are doing a very bad play. This because there exists a lack of control on this.

Best Wishes.

Mike

01 Nov 2007 Ji Cling

Shame on you.
Self downloading 1000ths of times to get to the top of the rank.

22 Jun 2006 gideon dror

Very usefull function.
Coding is not "Matlab elegant" - but performs very well.

29 May 2006 yair weiss

function can be considerably optimized

08 Feb 2006 James J. Cai  
12 Dec 2005 Dorian Arnold

Works very well for simple statistics. Great for grant writers using prelim data or students doing coursework dealing with small sample sizes.

23 Aug 2005 Claudia Lerma  
08 May 2005 Antonio Fortes

Works very well even for large (>1000) sample sizes.

04 Jan 2005 Stan Letovsky

The authors have modified their code to address correctness and implementation issues, so my previous review is obsolete and should be ignored.

20 Dec 2004 Stan Letovsky

I tested this program and found it to be buggy, returning probs > 1 for various inputs, particularly but not exclusively when one of the cell counts was 0. Also comparing results to an interactive version of Fisher on the web there were significant discrepancies. The implementation also should return values, not print out a table. The statistical toolbox needs a reliable implementation of this test.

Updates
05 Oct 2004

It was added an appropriate format to cite this file.

02 Nov 2004

Output was improved.

12 Nov 2004

Due that Matlab could not work for factorials greater than 170. We use the function sum([log(x+1)......]), in order to avoid further calculation problems.

15 Nov 2004

Help text was improved.

22 Nov 2004

Text was improved.

28 Dec 2004

File was updated to work for very large cells value.

03 Jan 2005

File was improved.

03 Jan 2005

P-value results were improved.

05 Jan 2005

It was implemented output arguments.

22 Dec 2005

Text was improved.

Contact us