So basically I have medical data where the data is collected from two different treatment groups and various variables are measured for individuals in the two groups. Data was measured before, during, and after treatment.

While doing the EDA, I noticed that the Blood hemoglobin levels change significantly before the treatment and after the treatment in one treatment group and do not change much in another treatment group.

So I want to test statistically that treatment one has more effect on Blood hemoglobin levels than treatment two.

Blood Hemoglobin Level before treatment:

Blood Hemoglobin Level before treatment

Blood Hemoglobin Level after treatment:

enter image description here

I am aware that had it been only one group, the before-after effects can be tested using a paired t-test. Similarly, if there were two independent groups and only one variable, I would use the independent t-test. But my problem is somewhat a combination of these two.

So, I am really stuck as to how to form the hypothesis and which statistical test to use for the same. Any help would be highly appreciated!

  • 2
    $\begingroup$ The easiest approach is to use the differences for each group (before minus after) as the data and then you can use a simple Student's t-test or the like. Please note that it is not helpful to try to test a hypothesis using the same data that was used to form the hypothesis. Such a procedure has a very high false positive error rate. $\endgroup$ Commented Apr 24, 2022 at 4:08
  • $\begingroup$ See also stats.stackexchange.com/questions/3466/… $\endgroup$ Commented Apr 25, 2022 at 12:32
  • $\begingroup$ You mention that you have additional data/measurements for each participant. Are these covariates that you want to adjust for when you compare the treatment groups? $\endgroup$
    – dipetkov
    Commented Apr 25, 2022 at 18:09

1 Answer 1


As in @MichaelLew's suggestion, the two samples of differences (After - Before) for each group might be similar to the fictitious data sampled in R below. (In the plots of your question, it seems differences might be roughly normal, but with a larger sample SD for the second sample)

d.1 = rnorm(500, 0, 1.5)
summary(d.1);  sd(d.1)
summary(d.1);  sd(d.1)
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
-5.21285 -1.10637 -0.05737 -0.04802  0.93023  5.64779 
[1] 1.527096  # sample SD

d.2 = rnorm(550, 3, 2.5)
summary(d.2);  sd(d.2)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 -3.966   1.394   2.906   3.119   4.953  10.682 
[1] 2.488868

boxplot(list(d.1,d.2), horizontal=T, 

enter image description here

Because the two samples of differences may not have the same variances, a Welch 2-sample t test seems appropriate. The P-value for a 2-sided test is nearly $0,$ so the difference between the two samples is significant at any reasonable level.

t.test(d.1, d.2)

        Welch Two Sample t-test

data:  d.1 and d.2
t = -25.096, df = 923.59, p-value < 2.2e-16
alternative hypothesis: 
 true difference in means is not equal to 0
95 percent confidence interval:
 -3.414837 -2.919489
sample estimates:
   mean of x   mean of y 
 -0.04802171  3.11914101 

If you doubt that your real data are nearly normal, then you could use a nonparametric Wilcoxon rank sum test---instead of a Welch t test.

However, the if the two samples are of different shapes (including different variations, as for my fictitious data), the Wilcoxon test should not be regarded as a test of different medians, but as a test of stochastic domination. Again the difference between the locations of the two samples is highly significant.

wilcox.test(d.1, d.2)

        Wilcoxon rank sum test 
        with continuity correction

data:  d.1 and d.2
W = 37731, p-value < 2.2e-16
alternative hypothesis: 
 true location shift is not equal to 0

Roughly speaking, d.2 tends to have larger values than d.1. This can be shown by comparing the empirical CDFs (ECDFs) of the two samples: points for d.2 (brown) tend to be to the right (and thus below) points for d.1.

plot(ecdf(d.2), main="ECDF Plots", col="brown")
 lines(ecdf(d.1), col="blue")   

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.