I'm trying to plot a box-and-whisker plot for differences between samples obtained from two different (and presumably independent) groups (the sample numbers may differ between the groups). Because the difference between the means is not enough for the box-and-whisker plot, and thus I was wondering whether I could generate a list of the difference value between all the possible pairs and use it for the box-and-whisker plot.
1 Answer
It might be better to make two boxplots side by side and compare them. In some cases, one can use 'notched' boxplots.
The notches indicate nonparametric confidence intervals calibrated to facilitate deciding whether the populations for two samples differ. Nonoverlapping notches (as in the example below) suggest a significant difference.
Here is an illustration for two simulated nonnormal samples:
set.seed(2020)
x1 = rgamma(100, 5, .2)
x2 = rgamma(130, 5, .25)
x = c(x1, x2)
g = as.factor(c(rep(1,100), rep(2,130)))
boxplot(x ~ g, col="skyblue2", pch=19, notch=T)
summary(x1)
Min. 1st Qu. Median Mean 3rd Qu. Max.
7.958 16.748 23.910 25.882 30.697 81.840
summary(x2)
Min. 1st Qu. Median Mean 3rd Qu. Max.
3.96 13.23 18.45 19.14 23.03 45.96
Notes: (1) If notches extend beyond the box part of their plots, they can be a little difficult to interpret. When this happens, R provides a warning message that suggests omitting the notches. (I would not show a boxplot with 'messy' notches in a report meant for a nonstatistical audience.)
(2) A Welch 2-sample t test on the ranks of the combined samples, shows a highly significant difference. (Of course the ranks are not normal, but they have no outliers.)
t.test(rank(x) ~ g)
Welch Two Sample t-test
data: rank(x) by g
t = 4.396, df = 207.53, p-value = 1.76e-05
alternative hypothesis:
true difference in means is not equal to 0
...
-
$\begingroup$ Hi BruceET, Thanks for your kind and detailed answer. The difficulty I have here is that I've already plotted a box-and-whisker plots where two experiments were done on a same set of individuals. I calculated the percentage change in two different conditions and plotted it as a box-and-whisker plot. $\endgroup$– Anmo KimCommented Apr 5, 2020 at 3:20
-
$\begingroup$ Now, I'm trying to do the same analysis for another data set, which is this time obtained from two independent groups. So, if possible, I'd like to compute the "percentage change" between two unpaired groups, but I have no idea whether or not such pairings (pairings between all possible combinations from two groups) is statistically plausible. I would really appreciate any comment on this. Thanks!! $\endgroup$– Anmo KimCommented Apr 5, 2020 at 3:24
-
$\begingroup$ In your paired experiment, it may make sense to talk about the percentage change for each individual instead of the magnitude of the change. // With two independent groups (which could even be of different sizes) I don't see a way to talk about the change for any one individual when each individual experienced only one of the two conditions. As you say in your Question, you can make one comparison of overall group means---either in terms of percentage or size of difference. You can only plot the data you have. $\endgroup$– BruceETCommented Apr 5, 2020 at 6:30
-
$\begingroup$ I see. It became much clearer to me. Thanks for the answer! $\endgroup$– Anmo KimCommented Apr 6, 2020 at 15:13