A confidence interval estimates a population parameter with lower and upper bounds. Its confidence level describes long-run coverage of the procedure under its assumptions. It expresses uncertainty in the estimate; it is not the percentage of individual data values inside the interval.

A confidence interval can be compared with a null value when it corresponds to the same statistical model and confidence level as the intended two-sided test. Including that null value means the corresponding test does not reject it at that level. This does not prove that the effect is zero, and a confidence interval alone does not establish causation.

For a more practical understanding, we’ll use the 95% confidence interval which means that if we were to repeat our sampling process 100 times, approximately 95 of those confidence intervals would be expected to contain the true population parameter. This level of confidence is chosen by the researcher and impacts the width of the confidence interval: higher confidence levels lead to wider intervals.

Components of Confidence Intervals

Confidence interval formula

In constructing confidence intervals, several statistical components are involved:

  • Sample Mean (X̄): The average value of the sampled data.
  • Margin of Error: The range above and below the sample mean which captures the true population mean with a certain level of confidence.
  • Standard Deviation (σ) and Standard Error (σ/√n): Standard deviation measures the dispersion of data points. Standard error adjusts this for the size of the sample, providing a measure of the accuracy of the sample mean.

How to Calculate a Confidence Interval

To calculate confidence intervals, the formula incorporates the sample mean, the critical value from the z-distribution or t-distribution, and the standard error of the mean. The formula for constructing a confidence interval is:

\(CI=\bar{X}\pm(c^*\times SE)\)

Where:

  • CI is the confidence interval
  • \( \bar{X} \) is the sample mean
  • c* is the appropriate critical value: z* for a known-sigma normal interval or t* for an estimated-sigma t interval
  • SE is the standard error of the sample mean. For known σ it is calculated as \( SE = \frac{\sigma}{\sqrt{n}}\) where:
    • σ is the standard deviation
    • n is the sample size.

The z-value required for your calculations varies based on the selected confidence level. Below is a table that outlines the z-values corresponding to commonly used confidence levels:

Confidence Levelz-value
90%1.645
95%1.96
99%2.58
This table provides the critical z-values necessary to construct confidence intervals at different levels of certainty (90%, 95% and 99%).

Confidence Interval Calculation Example

Example 1

Suppose 50 independently sampled test scores have a sample mean of 78 and the population standard deviation is known to be σ = 12. Under a suitable normal model for the sample mean, a two-sided 95% z interval uses z* ≈ 1.96.

  • Standard Error: \( SE = \frac{12}{\sqrt{50}} \approx 1.70 \)
  • Confidence Interval: \( CI = 78 \pm (1.96 \times 1.70) = 78 \pm 3.33 \)
  • Therefore, the confidence interval is 74.67 to 81.33.

This means we are 95% confident that the average test score of all students lies between 74.67 and 81.33.

Example 2

A more thorough example on how to calculate the confidence interval is to use a complete data sample.

Sample from population - confidence interval example

Assume a dataset that includes the heights of 40 adult males measured in centimeters. The dataset represents a sample from a larger population and is given as follows:

178, 172, 181, 169, 180, 174, 177, 185, 176, 180,
175, 173, 174, 178, 182, 175, 177, 186, 173, 172,
180, 170, 174, 169, 178, 176, 180, 175, 179, 177,
171, 174, 180, 173, 172, 177, 176, 180, 179, 173.

Calculate the 95% confidence interval for the average height of adult males in this population.

SOLUTION
  1. First we need to calculate the sample mean.
  • Formula: \( \bar{X} = \frac{\text{Sum of all heights}}{n} \)
  • Sum of all heights = 178 + 172 + … + 179 + 173 = 7,050
  • The sample mean \( \bar{X} = 7,050 / 40 = 176.25 \)
  1. Then we’ll calculate the sample standard deviation (s). We need to subtract the mean from each data point, squaring the result, summing all these squares, and then taking the square root of the sum divided by n−1.
  • Formula: \( s = \sqrt{\frac{\sum (X_i – \bar{X})^2}{n-1}} \)
  • \( s = \sqrt{\frac{(178 – 176.25)^2 + (172 – 176.25)^2 + \cdots + (179 – 176.25)^2 + (173 – 176.25)^2}{39}} \)
  • s ≈ 4.023967.
  1. Using the standard deviation calculated above and the sample size of 40, we’ll calculate the Standard Error (SE).
  • Formula: \( \widehat{SE} = \frac{s}{\sqrt{n}}\)
  • \( \widehat{SE} = \frac{4.023967}{\sqrt{40}} \approx 0.636245 \)
  1. Because the population standard deviation is unknown and was estimated from these 40 observations, use a t interval with 39 degrees of freedom. Assuming independent observations and an adequately normal sampling distribution, the 95% critical value is approximately 2.023.
  • \(CI = 176.25 \pm 2.023\times0.636245 \approx 176.25\pm1.287124.\)
RESULT:

Using the rounded t critical value, the 95% confidence interval for the population mean height is approximately 174.96 cm to 177.54 cm. This interval estimates the population mean; it does not describe where 95% of individual heights lie.

Calculator note: Our confidence interval calculator computes z intervals when population σ is known. It does not compute the t interval in this sample-estimated-s example.

Types of Confidence Intervals

Confidence Interval for a Mean

A confidence interval for a mean is a statistical tool used to estimate the range within which the true average of a population is likely to be found, based on sample data. This type of interval is crucial for understanding where the population mean might actually lie, considering the natural variations in any sample.

Formula with unknown population σ: \(CI=\bar{x}\pm t_{1-\alpha/2,n-1}\,s/\sqrt{n}\). For known σ, replace t* and s with z* and σ.

  • \( \bar{x} \): Sample mean
  • \(t^*\): critical t-value for the chosen confidence level, with n−1 degrees of freedom
  • \( s \): Sample standard deviation
  • \( n \): Sample size

Purpose: Estimates the range likely to contain the population mean.

Confidence Interval for the Difference Between Means

A confidence interval for the difference between means is designed to estimate the range within which the difference between the means of two populations is likely to fall. This is particularly useful in comparative studies, such as clinical trials or business A/B testing, where the impact of different conditions on a mean is analyzed.

Equal-variance pooled t formula: \(CI=(\bar{x}_1-\bar{x}_2)\pm t^*s_p\sqrt{1/n_1+1/n_2}\), with n₁+n₂−2 degrees of freedom. This form assumes independent samples, a shared population variance and an appropriate normal approximation. When equal variances are not justified, use a Welch interval with its own standard error and degrees of freedom.

  • \( \bar{x}_1, \bar{x}_2 \): Means of sample 1 and sample 2, respectively
  • \( t \): T-critical value for the confidence level and n1​+n2​−2 degrees of freedom
  • \( s_p^2 \)​: Pooled variance
  • \( n_1, n_2 \): Sizes of sample 1 and sample 2

Purpose: Estimates the range likely to contain the true difference between two population means.

Confidence Interval for a Proportion

A confidence interval for a proportion provides an estimated range of values within which the true proportion of a population characteristic is expected to lie. This type of interval is valuable for surveys and polls, where a proportion, such as the percentage of voters favoring a particular candidate, needs to be estimated from sample data.

Formula: \( CI = p \pm z \times \sqrt{\frac{p(1-p)}{n}} \)

  • \( p \): Sample proportion
  • \( z \): Z-value for the chosen confidence level
  • \( n \): Sample size

Purpose: Estimates the range likely to contain a population proportion.

Confidence Interval for the Difference in Proportions

A confidence interval for the difference in proportions is used to estimate the range within which the difference between two population proportions is expected to be found. This method is essential in fields like epidemiology and market research, where understanding the difference in proportions between two groups can guide significant decisions.

Formula: \( CI = (p_1 – p_2) \pm z \times \sqrt{\frac{p_1(1-p_1)}{n_1} + \frac{p_2(1-p_2)}{n_2}} \)

  • \( p1, p2 \): Proportions of sample 1 and sample 2, respectively
  • \( z \): Z-value for the chosen confidence level
  • \( n1, n2 \): Sizes of sample 1 and sample 2

Purpose: Estimates the range likely to contain the true difference between two population proportions.