maths.free › Statistics & Probability › Inference › Confidence interval
Confidence interval
According to frequentist inference, a confidence interval (CI) is a range of values which is likely to contain (in repeated sampling) the true value of an unknown statistical parameter, such as a population mean.
Confidence interval
According to frequentist inference, a confidence interval (CI) is a range of values which is likely to contain (in repeated sampling) the true value of an unknown statistical parameter, such as a population mean. Rather than reporting a single point estimate (e.g. "the average screen time is 3 hours per day"), a confidence interval provides a range, such as 2 to 4 hours, along with a specified confidence level, typically 95%.
A 95% confidence level does not imply a 95% probability that the true parameter lies within a particular calculated interval, which is instead associated with the credible interval in Bayesian inference. The confidence level instead reflects the long-run reliability of the method used to generate the interval. In other words, if the same sampling procedure were repeated 100 times from the same population, approximately 95 of the resulting intervals would be expected to contain the true population mean. The frequentist approach sees the true population mean as a fixed unknown constant, while the confidence interval is calculated using data from a random sample. Because the sample is random, the interval endpoints are random variables.
Definition
Let \(X\) be a random sample from a probability distribution with statistical parameter \((\theta, \varphi)\). Here, \(\theta\) is the quantity to be estimated, while \(\varphi\) includes other parameters (if any) that determine the distribution. A confidence interval for the parameter \(\theta\), with confidence level or coefficient \(\gamma\), is an interval \((u(X), v(X))\) determined by random variables \(u(X)\) and \(v(X)\) with the property: \[P(u(X) < \theta < v(X)) = \gamma \quad \text{for all }(\theta, \varphi).\]
The number \(\gamma\), which is typically large (e.g. 0.95), is sometimes given in the form \(1 - \alpha\) (or as a percentage \(100\cdot(1 - \alpha)%\)), where \(\alpha\) is a small positive number, often 0.05. It means that the interval \((u(X), v(X))\) has a probability \(\gamma\) of covering the value of \(\theta\) in repeated sampling.
Alternatively, some authors simply require that
\[P(u(X) < \theta < v(X)) \ge\ \gamma \quad \text{for all }(\theta, \varphi).\] The confidence level can be described as "at least \(100\gamma%\)". When it is known that the coverage probability can be strictly larger than \(\gamma\) for some parameter values, the confidence interval is called conservative, i.e., it errs on the safe side.
In many applications, confidence intervals that have exactly the required confidence level are hard to construct, but approximate intervals can be computed. The rule for constructing the interval may be accepted if
\[P(u(X) < \theta to an acceptable level of approximation.
Methods of derivation
There are many ways of calculating confidence intervals, and the best method depends on the situation. Two widely applicable methods are bootstrapping and the central limit theorem. The latter method works only if the sample is large, since it entails calculating the sample mean \(\bar{X}\) and sample standard deviation \(S\) and using the asymptotically standard normal quantity
\[\frac{\bar{X} - \mu}{S / \sqrt{n}}\]
where \(\mu\) and \(n\) are the population mean and the sample size, respectively.
Example
Suppose \(X_1, \ldots, X_n\) is an independent sample from a normally distributed population with unknown parameters mean \(\mu\) and variance \(\sigma^2.\) Define the sample mean \(\bar{X}\) and unbiased sample variance \(S^2\) as
\[\begin{align} \bar{X} &= \frac{1}{n} \left(X_1 + \cdots + X_n\right), \\ S^2 &= \frac{1}{n-1}\sum_{i=1}^n \left(X_i - \bar{X}\right)^2. \end{align}\]
Then the value
\[T = \frac{\bar{X} - \mu}{S/\sqrt{n}}\]
has a Student's t distribution with \(n - 1\) degrees of freedom. This value is useful because its distribution does not depend on the values of the unobservable parameters \(\mu\) and \(\sigma^2\); i.e., it is a pivotal quantity.
Suppose we wanted to calculate a 95% confidence interval for \(\mu.\) First, let \(c\) be the 97.5th percentile of the distribution of \(T\). Then there is a 2.5% chance that \(T\) will be less than \(-c\) and a 2.5% chance that it will be larger than \(+c\) (as the t distribution is symmetric about 0). In other words,
\[P_T(-c \leq T \leq c) = 0.95.\]
Condensed — the full section is in Wikipedia.
Interpretation
Various interpretations of a confidence interval can be given (taking the 95% confidence interval as an example in the following).
- The confidence interval can be expressed in terms of a long-run frequency in repeated samples (or in resampling): "Were this procedure to be repeated on numerous samples, the proportion of calculated 95% confidence intervals that encompassed the true value of the population parameter would tend toward 95%."
- The confidence interval can be expressed in terms of probability with respect to a single theoretical (yet to be realized) sample: "There is a 95% probability that the 95% confidence interval calculated from a given future sample will cover the true value of the population parameter." This essentially reframes the "repeated samples" interpretation as a probability rather than a frequency.
- The confidence interval can be expressed in terms of statistical significance, e.g.: "The 95% confidence interval represents values that are not statistically significantly different from the point estimate at the .05 level."
Common misunderstandings
Confidence intervals and levels are frequently misunderstood, and published studies have shown that even professional scientists often misinterpret them.
Contrary to common misconceptions, a 95% confidence level does not mean that:
- for a given realized interval there is a 95% probability that the population parameter lies within the interval;
- 95% of the sample data lie within the confidence interval; or
- there is a 95% probability of the parameter estimate from a repeat of the experiment falling within the confidence interval computed from a given experiment.
For example, suppose a factory produces metal rods, and a random sample of 25 rods gives a 95% confidence interval of 36.8 to 39.0 mm for the population mean length.
- It is incorrect to say that there is a 95% probability that the true population mean lies within this interval: the true mean is fixed, not random. The true mean could be 37 mm, which is within the confidence interval, or 40 mm, which is not; in any case, whether it falls between 36.8 and 39.0 mm is a matter of fact, not probability.
- It is not necessarily true that the lengths of 95% of the sampled rods lie within this interval. In this case, it cannot be true: 95% of 25 is not an integer.
- It is not generally true that there is a 95% probability that the sample mean length (an estimate of the population mean length) in a second sample would fall within this interval. In fact, if the true mean length is far from this specific confidence interval, it could be very unlikely that the next sample mean falls within the interval.
Instead, the 95% confidence level means that if we took 100 such samples, we would expect the true population mean to lie within approximately 95 of the calculated intervals.
Interpreting confidence intervals is especially tricky when multiple groups are involved. Two common misconceptions are: that two groups are significantly different if their CIs "just touch," and that they differ when one group's CI excludes the other's mean. Neither of these is true in general, but even experienced researchers often make these mistakes.
Comparison with prediction intervals
A confidence interval is used to estimate a population parameter, such as the mean. For example, the expected value of a fair six-sided die is 3.5. Based on repeated sampling, after computing many 95% confidence intervals, roughly 95% of them will contain 3.5 (and the width of the confidence interval shrinks with sample size).
A prediction interval, on the other hand, provides a range within which a future individual observation is expected to fall with a certain probability. In the case of a single roll of a fair six-sided die, an exact 95% prediction interval does not exist. However, there are exact 95% prediction intervals for rolling a twenty-sided die. One such interval is \([1, 19]\), since 95% of the time the roll will result in a 19 or less, and the remaining 5% will result in a 20.
The key distinction is that confidence intervals quantify uncertainty in estimating parameters, while prediction intervals quantify uncertainty in forecasting future observations.
Comparison with credible intervals
In many common settings, such as estimating the mean of a normal distribution with known variance, confidence intervals coincide with credible intervals under non-informative priors. In such cases, common misconceptions about confidence intervals (e.g. interpreting them as probability statements about the parameter) may yield practically correct conclusions.
History
Methods for calculating confidence intervals for the binomial proportion appeared from the 1920s. The main ideas of confidence intervals in general were developed in the early 1930s, and the first thorough and general account was given by Jerzy Neyman in 1937.
Neyman described the development of the ideas as follows (reference numbers have been changed):
In medical journals, confidence intervals were promoted in the 1970s but only became widely used in the 1980s. By 1988, medical journals were requiring the reporting of confidence intervals.
Confidence interval for specific distributions
- Confidence interval for binomial distribution
- Confidence interval for exponent of the power law distribution
- Confidence interval for mean of the exponential distribution
- Confidence interval for mean of the Poisson distribution
- Confidence intervals for mean and variance of the normal distribution (also here)
- Confidence interval for the parameters of a simple linear regression
- Confidence interval for the difference of means (based on data from a normal distributions, without assuming equal variances)
- Confidence interval for the difference between two proportions
Workbench
No calculator settles this one, but the pieces of it are computable. Try the problems below, or type your own.
Now you
Symbols used here
Tap any symbol for the full definition, a picture, and what every letter in it means.
Questions people ask
Mean or median, which should I use?
Median when the data have outliers or a long tail (incomes, house prices); mean when the data are roughly symmetric and you want every value to count. Report both if they disagree. The gap is itself information.
What does a p-value actually say?
The probability of seeing data at least this extreme if the null hypothesis were true. It is not the probability that the null hypothesis is true.
Why divide by n − 1 for the sample variance?
The sample mean sits closer to the sample than the true mean does, so squared deviations from it are slightly too small on average; dividing by n − 1 instead of n corrects the bias.
Parts of this page are adapted from Wikipedia (CC BY-SA 4.0). Condensed and re-explained here; errors are ours.
More in Statistics & Probability
Sampling and dataDescribing data with graphsMean, median and modeProbabilityCounting: permutations and combinationsDiscrete random variablesContinuous random variablesThe normal distributionThe central limit theoremConfidence intervalsHypothesis testingComparing two samplesChi-square testsLinear regression and correlation