Confidence intervals

Analytika TeamLast reviewed 7 min read

A single number from a sample (a mean, a difference, a correlation) is a best guess, and it would come out a bit different with a different sample. A confidence interval (CI) shows how different, by giving a range of values that are plausible for the true population figure. Many journals now ask for confidence intervals alongside, or even instead of, p-values.

What a 95% confidence interval means

Suppose you could repeat your study 100 times, each time drawing a new sample and calculating a 95% CI. About 95 of those intervals would contain the true population value and about 5 would miss it. The 95% is a property of the method, its long-run success rate.

Strictly, it’s not correct to say “there’s a 95% probability the true mean is in this particular interval”. In the classical framework, the true value is fixed and this interval either contains it or doesn’t. In practice, “we can be fairly confident the true mean lies between A and B” is an acceptable plain-language reading.

How it’s calculated

Most confidence intervals have the same structure:

estimate ± critical value × standard error

For a mean, that is x̄ ± t* × (s / √n), where t* comes from the t-distribution.

Worked example

Fuel economy for the 32 cars in the mtcars dataset:

  • Mean = 20.09 mpg, SD = 6.03, n = 32
  • Standard error = 6.03 / √32 ≈ 1.07
  • Critical t for 95% with 31 degrees of freedom ≈ 2.04 (close to the 1.96 of the normal distribution, slightly wider because n is small)
  • Margin of error = 2.04 × 1.07 ≈ 2.17
  • 95% CI: 17.92 to 22.26 mpg

R’s t.test(mtcars$mpg) and Analytika’s descriptives give the same interval.

What makes an interval wider or narrower

  • Sample size: the standard error shrinks with √n. Four times the data roughly halves the width.
  • Variability: noisier data (larger SD) give wider intervals.
  • Confidence level: a 99% interval is wider than a 95% one, because you ask for more certainty that it captures the true value.

Confidence intervals for differences

The most useful CIs are often for a difference or an effect, because they show both whether there’s evidence of an effect and how large it might be.

  • Sleeping drugs (paired t-test): drug 2 gave 1.58 more hours of extra sleep, 95% CI [0.70, 2.46]. The interval excludes zero, which matches p = .003, and it says the true advantage is plausibly anywhere from about 40 minutes to 2½ hours.
  • Vitamin C supplements (independent t-test): orange juice beat ascorbic acid by 3.70 units of tooth growth, 95% CI [−0.17, 7.57]. The interval includes zero, which matches p = .060. But it reaches up to 7.57, so a substantial advantage hasn’t been ruled out. That’s much more informative than “not significant”.

The rule linking the two: for a difference, a 95% CI that excludes zero corresponds to p < .05 in a two-sided test (when both come from the same method). For a ratio, such as an odds ratio, the “no effect” value is 1 instead of 0.

Overlapping intervals: a common trap

If two groups each have their own CI and the intervals overlap, that does not mean the difference between them is non-significant. Two 95% CIs can overlap a fair amount while the difference is still significant. To judge a difference, look at the CI for the difference, which is what the t-test gives you.

How to report confidence intervals (APA 7)

  • Use square brackets, with the level stated the first time: 95% CI [17.92, 22.26].
  • Use the same decimals as the estimate.
  • Report CIs for the key effects: mean differences, correlations, regression coefficients, and effect sizes such as Cohen’s d.
Drug 2 produced more extra sleep than drug 1, mean difference = 1.58 hours, 95% CI [0.70, 2.46].

Analytika’s t-tests, ANOVA, correlations and chi-square tests all print a confidence interval for the difference or effect size alongside the p-value, so it’s already there when you write up.

More in Hypothesis testing

Try it with the free tools

Run this on your own data

Upload a dataset and ask your question in plain English. Analytika checks the assumptions, picks the test, runs it, and writes the results up in APA format.

Try it free