MyBarnard (Scripts) Publisher's description
from Giuseppe Cardillo
There are two fundamentally different exact tests for comparing the equality of two binomial probabilities вЂ“ FisherвЂ™s exact test (Fisher, 1925
There are two fundamentally different exact tests for comparing the equality of two binomial probabilities вЂ“ FisherвЂ™s exact test (Fisher, 1925), and BarnardвЂ™s exact test (Barnard, 1945). FisherвЂ™s exact test (Fisher, 1925) is the more popular of the two. In fact, Fisher was bitterly critical of BarnardвЂ™s proposal for esoteric reasons that we will not go into here. For 2 Г— 2 tables, BarnardвЂ™s test is more powerful than FisherвЂ™s, as Barnard noted in his 1945 paper, much to FisherвЂ™s chagrin (see C.R. Mehta and P. Senchaudhuri: Conditional versus unconditional exact tests for comparing two binomials. www.cytel.com/papers/twobinomials.pdf). Anyway, perhaps due to its computational difficulty the Barnard's is not widely used. This function is completely vectorized and without for...end loops, and so, the computation is very fast. In FEX there is only one other function that computes the Barnard's exact test by Antonio Trujillo-Ortiz.
Using this matrix x=[7 12; 8 3]; switching off the input error checks and display results sections in both functions; the performs are:
L=1000; times=zeros(1,L); for I=1:L, tic; mybarnard(x); times(I)=toc; end, median(times)
ans = 0.0028
L=1000; times=zeros(1,L); for I=1:L, tic; Barnardextest(7,12,8,3); times(I)=toc; end, median(times)
ans = 1.2478
So my function is about 450 times faster.
System Requirements:MATLAB 7.6 (R2008a)
Program Release Status: New Release
Program Install Support: Install and Uninstall