Last version of MULTICOMPARE script

4 ビュー (過去 30 日間)
María
María 2014 年 8 月 5 日
回答済み: Aditya 2025 年 7 月 22 日
Hi, I'm using an old version of multcompare script where I can't obtain the p-value, Could somebody send me the last version of this script?, or explain me which statistic test I have to use to obtain the p-values for multiple comparison test with Bonferroni adjustment. Thanks in advance.
My email adress- mariapzabalza@gmail.com

回答 (1 件)

Aditya
Aditya 2025 年 7 月 22 日
Hi Maria,
If you're using an older version of the multcompare script that doesn't provide p-values, you can still perform multiple comparison tests with Bonferroni adjustment by manually conducting pairwise comparisons between your groups and adjusting the resulting p-values. The typical approach is to use a two-sample t-test (ttest2) for each pair of groups if your data are approximately normally distributed; otherwise, you can use a nonparametric test like the Wilcoxon rank-sum test (ranksum). After calculating the p-values for all possible group pairs, you apply the Bonferroni correction by multiplying each p-value by the total number of comparisons. Here’s how you can do this in MATLAB:
groups = unique(G); % G: vector of group labels
k = numel(groups); % number of groups
m = k*(k-1)/2; % total number of pairwise comparisons
pvals = [];
pairs = [];
for i = 1:k-1
for j = i+1:k
x1 = X(G==groups(i)); % X: data vector
x2 = X(G==groups(j));
[~, p] = ttest2(x1, x2); % or use ranksum(x1, x2) if nonparametric
pvals(end+1,1) = min(1, p*m); % Bonferroni-adjusted p-value
pairs(end+1,:) = [groups(i) groups(j)];
end
end
result = table(pairs(:,1), pairs(:,2), pvals, 'VariableNames', {'Group1','Group2','Bonf_p'});
disp(result)
This code will output a table showing each pair of groups and their Bonferroni-adjusted p-values, allowing you to identify which group differences are statistically significant after correction.

カテゴリ

Help Center および File ExchangeAnalysis of Variance and Covariance についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by