Multiple comparison test: hsd

조회 수: 19 (최근 30일)
Aniruddha Das
Aniruddha Das 2023년 2월 14일
답변: Hornett 2024년 9월 25일
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,

답변 (1개)

Hornett
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
  1. Perform One-Way ANOVA: Use the anova1 function to perform one-way ANOVA.
  2. Post-Hoc Test: Use the multcompare function to perform multiple comparisons.
% 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!

카테고리

Help CenterFile Exchange에서 ANOVA에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by