How can I report the results obtained from the kruskal wallis test in the boxplots? How to highlight the significance?

21 views (last 30 days)
I performed the kruskal wallis test on 8 samples. At the output I have the p value, SS, MS and I also made the pair wais among the various combinations. How can I report the results obtained from the kruskal wallis test in the boxplots? How to highlight the significance?

Answers (1)

Yash
Yash on 6 Sep 2023
Hi Ilaria,
As I can understand, you are interested in highlighting the results obtained from the kruskal wallis test. To achieve this, I suggest you follow the below steps:
  1. Use the "boxplot" function to to cretate boxplots for your 8 samples. This will give you a visual representation of the data.
  2. To highlight the significance levels on the boxplots, you can use symbols such as asterisks. Determine the significance level threshold (e.g., p < 0.05) and add the corresponding symbols to the boxplots for the groups that are significantly different.
  3. In the figure caption or the accompanying text, report the results of the Kruskal-Wallis test. Include the p-value, SS (Sum of Squares), MS (Mean Squares), and any relevant pairwise comparisons you made.
Kindly have a look at the below example for your reference.
% Perform Kruskal-Wallis test
p = kruskalwallis([sample1, sample2, sample3, sample4, sample5, sample6, sample7, sample8]);
% Generate boxplots
figure;
boxplot([sample1, sample2, sample3, sample4, sample5, sample6, sample7, sample8]);
title('Boxplots of the Samples');
ylabel('Values');
% Add significance indicators
if p < 0.05
% Add asterisk to indicate significance
hold on;
significance_groups = {'Group1', 'Group2', 'Group3', 'Group4'};
significance_positions = [1, 2, 3, 4];
plot(significance_positions, max(ylim) * ones(size(significance_positions)), '*', 'MarkerSize', 10);
text(significance_positions, max(ylim) * ones(size(significance_positions)), significance_groups, 'VerticalAlignment', 'bottom', 'HorizontalAlignment', 'center');
hold off;
end
% Include test results in the figure caption or accompanying text
disp(['Kruskal-Wallis test p-value: ', num2str(p)]);
I hope this helps you address the issue.

Community Treasure Hunt

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

Start Hunting!