Be the first to rate this file! 164 downloads (last 30 days) File Size: 3.11 KB File ID: #19842

MyFisher24

by Giuseppe Cardillo

 

07 May 2008 (Updated 23 Oct 2009)

Code covered by BSD License  

A very compact routine to compute Fisher's exact test on a 2x4 matrix

Download Now | Watch this File

File Information
Description

Fisher's exact test of 2x4 contingency tables permits calculation of precise probabilities in situation where, as a consequence of small cell frequencies, the much more rapid normal approximation and chi-square calculations are liable to be inaccurate. The Fisher's exact test involves the computations of several factorials to obtain the probability of the observed and each of the more extreme tables. Factorials growth quickly, so it's necessary use logarithms of factorials. This computations is very easy in Matlab because x!=gamma(x+1) and log(x!)=gammaln(x+1). This function is now fully vectorized to speed up the computation. Actually, the function also computes the mid-P correction to make the test less conservative.

MATLAB release MATLAB 7.5 (R2007b)
Zip File Content  
Other Files license.txt,
myfisher24.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
10 Dec 2008 Jon

I get error messages for some data.
For instance:
y =
    27 13 9 15
    12 10 3 16
>> myfisher24(y)
??? Attempted to access idxBstart(15); index out of bounds because
numel(idxBstart)=14.
Error in ==> myfisher24 at 116
            Tables(idxBstart(J+1):idxBstop(J+1),2)=J;

I hope this can be fixed?
Jon

12 Dec 2008 Giuseppe Cardillo

Jon was right. I have fixed the bug and uploaded the new version

12 Dec 2008 Jon

Giuseppe thank you for your quick response.
Your routine takes all my data now.
Jon

Please login to add a comment or rating.
Updates
24 Jun 2008

Speeding up using gammaln function and vectorization

12 Nov 2008

Changes in help section

25 Nov 2008

little improvements in tables enumeration

12 Dec 2008

Bug fixed after Jon comment

23 Oct 2009

Actually, the function also computes the mid-P correction to make the test less conservative.

Tag Activity for this File
Tag Applied By Date/Time
statistics Giuseppe Cardillo 22 Oct 2008 10:00:17
probability Giuseppe Cardillo 22 Oct 2008 10:00:17
fishers exact test 2x4 matrix Giuseppe Cardillo 22 Oct 2008 10:00:17
statistics Cristina McIntire 12 Nov 2008 14:31:10
probability Cristina McIntire 12 Nov 2008 14:31:17
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com