The function 'fishertest' provided by MATLAB only supports contingency table of size 2 × 2, and although there have been many other scholarly published functions on File_Exchange to compute larger matrices, the results are somewhat problematic.
This function is based on Monte Carlo simulation, it support contingency tables larger than 2 * 2.
% Input variable: x
% x is the contingency table. You can use function 'crosstab' to generate the contingency table.
% num : the number of Monte Carlo simulations to be performed, default is 100000.
% Output variable: p
% p:p-values
% Source of subfunction 'rcont2': https://people.math.sc.edu/Burkardt/m_src/asa144/asa144.html
% for example
% x = [ 11 11
% 0 6
% 11 17];
% p = fisher_test_R_C(x)
% p = 0.0977;
% Because of the randomness in the algorithm, the result may be different each time.
% You can increase the value of 'num' to make the result more robust.
Reference:
- James Boyett,Algorithm AS 144: Random R x C Tables with Given Row and Column Totals,Applied Statistics,Volume 28, Number 3, 1979, pages 329-332.
https://people.math.sc.edu/Burkardt/m_src/asa144/asa144.html
引用格式
qqffssxx (2024). Fisher's exact test with R×C contingency table (https://www.mathworks.com/matlabcentral/fileexchange/126355-fisher-s-exact-test-with-rxc-contingency-table), MATLAB Central File Exchange. 检索时间: .
MATLAB 版本兼容性
创建方式
R2022b
与 R2010a 及更高版本兼容
平台兼容性
Windows macOS Linux标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!版本 | 已发布 | 发行说明 | |
---|---|---|---|
1.0.0 |