- 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 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Hornett
el 25 de Sept. de 2024
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 comentarios
Ver también
Categorías
Más información sobre ANOVA en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!