Box plots for Kruskal-Wallis
8 views (last 30 days)
Show older comments
Sylwia Kaduk
on 7 Feb 2020
Commented: Sylwia Kaduk
on 10 Feb 2020
Hello,
I'm plotting Kruskal-Wallis results for my paper. I'm not sure how to interpret folded edges on the plot (shown with an arrow on the picture) and how to add mean lines to the plots. Thanks for help
0 Comments
Accepted Answer
fred ssemwogerere
on 9 Feb 2020
Hello, when the end point of a notch is lower than the 25th quartile of your data, that folding effect will occur. This effect is common to small datasets or small group size (when between groups of data).
% To calculate the end points of the lower and upper notch
lowerNotch=median(data)-1.57*iqr(data)/sqrt(numel(data)); % iqr is interquartile range
upperNotch=median(data)+1.57*iqr(data)/sqrt(numel(data));
% For a small value of "n" the notch will tend to extend beyond either the 75th percentile or 25th percentile (the upper and lower ends of the box respectively.
% If you compute the 25th percentile of your data and compare it to the end point of the lower notch, you will
% find this to be true. However, that won't be the case with the upper notch based on your plot.
4 Comments
fred ssemwogerere
on 10 Feb 2020
Hello, you do not need to call the boxplot function. You can add the mean values on the same boxplot generated by the statistical test. With the boxplot from your statistical test, just get the handle for the current axes.
handl=get(gca);
hold on;
% Compute the mean value for each data group.
% Am assuming your different data groups are arranged in different columns of one matrix called: "gpdata".
avg=mean(gpdata); % a row vector output showing means for different data groups
% get the "XTick" of the current axes, and plot the mean values to correspond to their respective XTickLabel
scatter(handl.XTick,avg,[],'filled');
hold off
% This should be able to show the mean values as circular filled blue (default) markers on the same box plot generated from the statistical test
More Answers (0)
See Also
Categories
Find more on Hypothesis Tests in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!