Thursday, December 17, 2015

Median of Differences versus Difference in Medians

Both mean and median are used as location parameters to measure the central tendency of the data. If there is an intervention (such as drug treatment in a clinical trial), the mean and the median for the change from baseline can be used as the point estimate for measuring the magnitude of the effect by the intervention. The statistical test will then be performed to see if the point estimate of the effect is statistically significant or not. 

One mistake people can make is to calculate the difference in medians while the correct way should be to calculate the median of differences. The example below is a typical data presentation for a pre-post study design. The change from baseline will be calculated for each subject. The mean and median will be calculated for change from baseline values across all subjects. One temptation is to calculate the difference in medians as the median for postbaseline - the median for baseline. However, the median of differences and the difference of medians can be very different especially when data is skewed. 

Subject
Baseline
Post
Baseline
Change From Baseline
1
50.6
38
-12.6
2
39.2
18.6
-20.6
3
35.2
23.2
-12
4
17
19
2
5
11.2
6.6
-4.6
6
14.2
16.4
2.2
7
24.2
14.4
-9.8
8
37.4
37.6
0.2
9
35.2
24.4
-10.8





Mean
29.36
22.02
-7.33
Median
35.2
19
-9.8

The median of differences is calculated as the 50th percentile of all individual differences (change from baseline). The Median of differences (the last column) is -9.8. However, the difference in medians = Median of Postbaseline Measures – Median of Baseline Measures = 19 – 35.2 = 16.2

The median of differences (-9.8) and the difference in medians (-16.2) are quite different especially for skewed data.

The median of differences is the correct number to be used and is the number that corresponding to the signed rank test.

It would be ok if we do this for mean. The mean of differences is equal to the difference in means, i.e., -7.33 = 22.02 (mean for postbaseline) – 29.36 (mean for baseline). However, if we need to perform a statistical test such as the paired t-test, the numbers in the last column for change from baseline should be the basis. 

Suppose we have "change from baseline" for two treatment groups, we would need to calculate the median for each treatment group in the same way as above. For treatment comparison, we may use the non-parametric Wilcoxon rank-sum test and calculate the magnitude of the difference in medians using the Hodges-Lehmann estimator.  Hodges Lehmann's estimation of location shift can be calculated in SAS using Proc NPAR1WAY.


1 comment:

Anonymous said...

Hi Dr Beng

This is exactly the difference between regular independent two-sample test and dependent pair test.

In the regular independent test, you compare two independent random samples, while in pair test there is a connection between the samples.
In your example, you use the same subjects in both samples.

Examples:

comparing mean:
Independent test: Two sample T test
Dependent test: Paired T Test

comparing median or overall distribution
Independent test: Mann Whitney U test
Dependent test: Wilcoxon Signed-Rank test