Confidence Interval for the Difference Between Means


confidence interval (C.I.) for a difference between means is a range of values that is likely to contain the true difference between two population means with a certain level of confidence.

This tutorial explains the following:

  • The motivation for creating this confidence interval.
  • The formula to create this confidence interval.
  • An example of how to calculate this confidence interval.
  • How to interpret this confidence interval.

C.I. for the Difference Between Means: Motivation

Often researchers are interested in estimating the difference between two population means. To estimate this difference, they’ll go out and gather a random sample from each population and calculate the mean for each sample. Then, they can compare the difference between the two means.

However, they can’t know for sure if the difference in the sample means matches the true difference in the population means which is why they may create a confidence interval for the difference between the two means. This provides a range of values that is likely to contain the true difference between the population means.

For example, suppose we want to estimate the difference in mean weight between two different species of turtles. Since there are thousands of turtles in each population, it would be too time-consuming and costly to go around and weigh each individual turtle.

Instead, we might take a simple random sample of 15 turtles from each population and use the mean weight in each sample to estimate the true difference in mean weight between the two populations:

Confidence interval for a difference between two population means

The problem is that our samples are random, so the difference in mean weights between the two samples is not guaranteed to exactly match the difference in mean weights between the two populations. So, to capture this uncertainty we can create a confidence interval that contains a range of values that are likely to contain the true difference in mean weight between the two populations.

C.I. for the Difference Between Means: Formula

We use the following formula to calculate a confidence interval for a difference between two means:

Confidence interval = (x1x2) +/- t*√((sp2/n1) + (sp2/n2))

where:

  • x1x2: sample 1 mean, sample 2 mean
  • t: the t-critical value based on the confidence level and (n1+n2-2) degrees of freedom
  • sp2: pooled variance
  • n1, n2: sample 1 size, sample 2 size

where:

C.I. for the Difference Between Means: Example

Suppose we want to estimate the difference in mean weight between two different species of turtles, so we go out and gather a random sample of 15 turtles from each population. Here is the summary data for each sample:

Sample 1:

  • x1 = 310
  • s1 = 18.5
  • n1 = 15

Sample 2:

  • x2 = 300
  • s2 = 16.4
  • n2 = 15

Here is how to find various confidence intervals for the true difference in population mean weights:

90% Confidence Interval:

(310-300) +/- 1.70*√((305.61/15) + (305.61/15)) =  [-0.8589, 20.8589]

95% Confidence Interval:

(310-300) +/- 2.05*√((305.61/15) + (305.61/15)) =  [-3.0757, 23.0757]

99% Confidence Interval:

(310-300) +/- 2.76*√((305.61/15) + (305.61/15)) =   [-7.6389, 27.6389]

Note: You can also find these confidence intervals by using the Statology Confidence Interval for the Difference Between Means Calculator.

You’ll notice that the higher the confidence level, the wider the confidence interval. This should make sense because wider intervals are more likely to contain the true population mean, thus we’re more “confident” that the interval contains the true population mean.

C.I. for the Difference Between Means: Interpretation

The way we would interpret a confidence interval is as follows:

There is a 95% chance that the confidence interval of [-3.0757, 23.0757] contains the true difference in mean weight between the two turtle populations.

Since this interval contains the value “0” it means that it’s possible that there is no difference in the mean weight between the turtles in these two populations. In other words, we cannot say with 95% confidence that there is a difference in mean weight between the turtles in these two populations.

3 Replies to “Confidence Interval for the Difference Between Means”

  1. Hello Zach,

    I wonder if you could lend me a hand with this. I’m trying to compare two groups and determine the CI95% of the difference between two means.

    Group A
    
Treatment resulted in an increase of bone density of the hip of 2,6% (CI95% 2,2 to 3,0)

    Group B
    Treatment resulted in a decrease of bone density of the hip of 0,6% (so -0,6%) (CI95% -1 to -0,2)

    The authors calculate the difference between the 2 groups of 3,2% (CI95% 2,6 to 3,8 with p value less than 0,0001)

    I get where they calculated the difference of 3,2% (2,6 + -0,6 = 3,2%) but how to calculate the CI of the difference ? And does the p-value just confirm that it’s statistically significant ?

    I would like to calculate more of these differences from data found in the appendix of the study, where I have the effect of the treatment on bone density of the femur and vertebrae and their CI95% ; I just need help calculating the CI95% of the difference between the 2 groups.

    Thank you.

  2. “There is a 95% chance that the confidence interval of [-3.0757, 23.0757] contains the true difference in mean weight between the two turtle populations.”
    No, this is not true. The 95%CI means that if the assumptions of the statistical analysis are correct then if yu repeat the study an infinite number of times then 95% of your CI will include the true value. You do not know whether your CI is one of those 95%. It either does or it doesn’t (look at Amrhein and Greenland 2022 https://doi.org/10.1177/02683962221105904 for a fuller explanation)

Leave a Reply

Your email address will not be published. Required fields are marked *