A permutation test (aka randomization test) for MATLAB, testing for a difference in means between two samples. It supports one- and two-tailed tests, and returns a p-value, the observed difference, and the effect size (Hedges g). The result can optionally be visualized using a histogram. It is also possible to perform exact tests, during which all possible permutations are considered.
Laurens R Krol (2021). Permutation Test (https://github.com/lrkrol/permutationTest), GitHub. Retrieved .
Really useful, thanks. What is the effect size here? There are a dozen definitions and one used here is similar to Cohen's d, but not the same. I can't find the match in the Wikipedia article about Effect size.
P.S. If you want to make this function work smoothly for newer MATLAB versions at the expense of back-compatibility, I'm happy to make a simple Pull Request to replace inputParser with arguments blocks. Up to you.
Fails in 2019b due to deprecated call to 'hist' on line 160. Correcting to 'histogram' resolves it.
Dear Miguel, this sounds like a comma might have accidentally been deleted on your end. Please re-download the exact file provided here and run it again. If you continue to have issues, it would be better if you could open a new issue on GitHub: https://github.com/lrkrol/permutationTest/issues
If I try to run the exact same example that you provided:
sample1 = randn(1,5000);
sample2 = randn(1,5000) + .1;
permutationTest(sample1, sample2, 10000, 'plotresult', 1);
The code gives the "Error: File: permutationTest.m Line: 81 Column: 80
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct
matrices, use brackets instead of parentheses". I am a beginner in MATLAB coding. Is there anyway to workaround this?
Thanks for this code, very easy to use and understand.
Works really well! Thanks for the upload :)
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!