MATLAB: Box plots for Kruskal-Wallis

box plot kruskal wallisMATLAB

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
kruskal wallis.PNG

Best Answer

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.