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タグ
謝辞
ヒントを得たファイル: Fisher's exact test with n x m contingency table
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!バージョン | 公開済み | リリース ノート | |
---|---|---|---|
1.0.0 |