- Perform One-Way ANOVA: Use the anova1 function to perform one-way ANOVA.
- Post-Hoc Test: Use the multcompare function to perform multiple comparisons.
Multiple comparison test: hsd
조회 수: 19 (최근 30일)
이전 댓글 표시
Hello folks,
Question: whenever I am running a multiple comparison test (hsd) in more than two groups after performing an one-way ANOVA, the output always fixing one group as control dataset (marked in blue) and then plotting other groups (in red) and showing if it is sgnificant or not.
Is there any way where I can compare all groups to each other in a posthoc manner?
Thanks,
댓글 수: 0
답변 (1개)
Hornett
2024년 9월 25일
Hi Aniruddha,
In MATLAB, you can use the multcompare function to perform multiple comparisons of all group pairs after an ANOVA. This function will compare all groups to each other rather than fixing one group as a control.
Here’s how you can do it:
Step-by-Step Guide
% Example data
group1 = [23, 25, 27, 22, 24];
group2 = [32, 34, 31, 33, 35];
group3 = [45, 44, 46, 47, 43];
% Combine data into a single vector
data = [group1, group2, group3];
% Create a grouping variable
group = [ones(size(group1)), 2*ones(size(group2)), 3*ones(size(group3))];
% Perform one-way ANOVA
[p, tbl, stats] = anova1(data, group);
% Perform multiple comparisons using Tukey's HSD
figure;
[c, m, h, gnames] = multcompare(stats, 'CType', 'hsd');
% Display the results
disp('Multiple Comparisons Results:');
disp(c);
Hope it helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 ANOVA에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!