I have a cell array of p-values that have to be adjusted for multiple comparisons. How can I do that in Matlab? I can't find a built-in function.
In R I would do:
data.pValue_adjusted = p.adjust(data.pValue, method='bonferroni')
Is there a similiar function for Matlab? Ideally one that performs different adjustment methods (Bonferroni, Benjamini-Hochberg, FDR ...)?
The simplest way to adjust your P values is to use the conservative Bonferroni correction method which multiplies the raw P values by the number of tests m (i.e. length of the vector P_values).
Classicists believe that if multiple measures are tested in a given study, the p-value should be adjusted upward to reduce the chance of incorrectly declaring a statistical significance [4–7].
To perform a Bonferroni correction, divide the critical P value (α) by the number of comparisons being made. For example, if 10 hypotheses are being tested, the new critical P value would be α/10. The statistical power of the study is then calculated based on this modified P value.
One standard approach to correct for multiple comparisons is simply to divide the target false positive rate (typically . 05) by the number of comparisons. Thus, if I'm conducting 5 tests, I would require each test to be significant at . 05/5, or p < .
If you have Bioinformatics Toolbox, you can use MAFDR function to calculate p-values adjusted by False Discovery Rate.
For people without the Bioinformatics Toolbox, the FDR (False Discovery Rate) method is also very nicely described here, it also provides a link with an fdr script.
A MATLAB/Octave implementation of R's p.adjust
function is available here. It can perform p-value adjustment for multiple comparisons with the following methods, equivalent to their R counterparts:
Disclaimer: I'm the author of this package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With