Code covered by the BSD License  

Highlights from
Fisherextest

3.375

3.4 | 9 ratings Rate this file 16 Downloads (last 30 days) File Size: 3.88 KB File ID: #5957

Fisherextest

by Antonio Trujillo-Ortiz

 

30 Sep 2004 (Updated 22 Dec 2005)

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 submission has inspired the following:
HWtest
MATLAB release MATLAB 5.3 (R11)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (17)
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.

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.

08 May 2005 Antonio Fortes

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

23 Aug 2005 Claudia Lerma  
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.

08 Feb 2006 James J. Cai  
29 May 2006 yair weiss

function can be considerably optimized

22 Jun 2006 gideon dror

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

01 Nov 2007 Ji Cling

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

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

12 Sep 2008 Ji Cling

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

(It is not an exagerated figure)
 

30 Nov 2009 Alex Garcia Lancaster

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

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.

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

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.)

16 Jun 2011 Tobias

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

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.

Please login to add a comment or rating.
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.

22 Dec 2005

Input was improved.

Tag Activity for this File
Tag Applied By Date/Time
statistics Antonio Trujillo-Ortiz 22 Oct 2008 07:32:19
probability Antonio Trujillo-Ortiz 22 Oct 2008 07:32:19
crosstabulation Antonio Trujillo-Ortiz 22 Oct 2008 07:32:19
contingency tables Antonio Trujillo-Ortiz 22 Oct 2008 07:32:19
exact Antonio Trujillo-Ortiz 22 Oct 2008 07:32:19
two categorical variables Antonio Trujillo-Ortiz 22 Oct 2008 07:32:19
fishers exact conditional test Nick Mariette 28 Jan 2011 00:37:06
probability Alonsooo Arnald 11 Jan 2012 10:44:43

Contact us at files@mathworks.com