# Mean difference (95% CI) between paired samples

I have some results from a study pre- and post-intervention. It's for an underpowered feasibility study, hence I am not performing formal hypothesis testing but I'd like to calculate mean difference (with 95% CI) as per CONSORT 2010 guidelines.

My question is, what is the best approach for this? I am struggling for a couple of reasons:

1. I don't believe my data is normally distributed (it is blood test results and survey scores)
2. My data is paired, i.e., it's the same group of participants pre- and post.

And example of data is as follows:

Pre-intervention Post-intervention
37.14 33.21
34.69 31.25
65.52 43.73
40.56 38.26
41.32 41.72
39.34 38.14
43.95 41.07
44.26 39.49
35.28 28.50
37.12 32.40
37.82 35.87
34.71 33.79
34.08 30.49
33.08 36.29
36.89 33.18
41.38 37.70
39.29 33.86
41.62 39.21
39.36 35.43
• applying the t-test to the difference of two columns gives what you are looking for. In alternative you can consider applying Mann-Whitney to the two samples. These procedures in R also provide the associated confidence interval. Apr 18 at 11:13

Here is an R solution applying the $$t$$-test for paired data.

x = scan()
1: 37.14    33.21
3: 34.69    31.25
5: 65.52    43.73
7: 40.56    38.26
9: 41.32    41.72
11: 39.34   38.14
13: 43.95   41.07
15: 44.26   39.49
17: 35.28   28.50
19: 37.12   32.40
21: 37.82   35.87
23: 34.71   33.79
25: 34.08   30.49
27: 33.08   36.29
29: 36.89   33.18
31: 41.38   37.70
33: 39.29   33.86
35: 41.62   39.21
37: 39.36   35.43

xmat <- matrix(x, ncol=2, byrow = TRUE)
t.test(xmat[,1], xmat[,2], paired = TRUE)

Paired t-test

data:  xmat[, 1] and xmat[, 2]
t = 3.4757, df = 18, p-value = 0.002698
alternative hypothesis: true mean difference is not equal to 0
95 percent confidence interval:
1.536795 6.233732
sample estimates:
mean difference
3.885263


And here is another solution based on the Wilcoxon signed-rank test for two paired samples, aka the Mann-Whitney test:

wilcox.test(xmat[,1], xmat[,2], paired = TRUE, conf.int = TRUE,correct = TRUE, )

Wilcoxon signed rank test with continuity correction

data:  xmat[, 1] and xmat[, 2]
V = 181, p-value = 0.0005795
alternative hypothesis: true location shift is not equal to 0
95 percent confidence interval:
2.179984 4.350064
sample estimates:
(pseudo)median
3.314607

Warning messages:
1: In wilcox.test.default(xmat[, 1], xmat[, 2], paired = TRUE, conf.int = TRUE,  :
cannot compute exact p-value with ties
2: In wilcox.test.default(xmat[, 1], xmat[, 2], paired = TRUE, conf.int = TRUE,  :
cannot compute exact confidence interval with ties


The two warning messages you see, as they say it, are due to the presence of ties for which the exact sampling distribution doesn't hold and we have to resort to asymptotic results.

Comment. The two confidence intervals are quite different although I'm not sure if this difference is relevant from a clinical point of view. Nevertheless, presumably this difference may be to the presence of a slight departure from normality shown by QQ-plot applied to the difference between the two variables.

qqnorm(xmat[,1]-xmat[,2])
qqline(xmat[,1]-xmat[,2])


• I really appreciate your help with this one, especially the code for R which I am new to. I've opted for the Mann-Whitney test just given the data not following a normal distribution.
– Josh
Apr 21 at 13:28