30 Confidence Intervals and Estimation
Estimation is the process of using sample data to infer the value of an unknown population parameter. The confidence interval, in the form used throughout this chapter, was formalised by Jerzy Neyman (Jerzy Neyman, 1937). A point estimate (such as a sample mean) gives a single best guess, but it will almost never exactly equal the true population value. A confidence interval improves on this by providing a range of plausible values, together with a stated level of confidence — combining the point estimate with the uncertainty quantified by the standard error from the previous chapter.
30.1 Point Estimates vs Interval Estimates
- Point Estimate: A single value, such as the sample mean \(\bar{x}\) or sample proportion \(\hat{p}\), used as the best guess for the population parameter.
- Interval Estimate (Confidence Interval): A range of values, calculated from the sample, that is likely to contain the true population parameter at a stated confidence level (commonly 90%, 95%, or 99%).
- Confidence Level: The long-run proportion of intervals, constructed the same way from repeated samples, that would contain the true population parameter. A 95% confidence level means that if the same sampling procedure were repeated many times, about 95% of the resulting intervals would contain the true parameter — it is not the probability that this particular interval contains the true value.
30.2 Confidence Interval for a Mean
When the Population Standard Deviation Is Known
\[ \bar{x} \pm Z_{\alpha/2} \cdot \frac{\sigma}{\sqrt{n}} \]
When the Population Standard Deviation Is Unknown (the common case)
The sample standard deviation \(s\) is used instead of \(\sigma\), and the \(t\)-distribution replaces the \(Z\)-distribution to account for the extra uncertainty: \[ \bar{x} \pm t_{\alpha/2,\, n-1} \cdot \frac{s}{\sqrt{n}} \] where \(t_{\alpha/2,\, n-1}\) is the critical value from the \(t\)-distribution with \(n-1\) degrees of freedom.
Confidence Interval for a Proportion
\[ \hat{p} \pm Z_{\alpha/2} \sqrt{\frac{\hat{p}(1-\hat{p})}{n}} \]
30.2.1 Worked Example
A sample of 25 customers has a mean satisfaction score of 78 with a sample standard deviation of 12. Construct a 95% confidence interval for the true mean satisfaction score.
Since the population standard deviation is unknown and \(n = 25\) is small, the \(t\)-distribution is used with \(df = n - 1 = 24\). The critical value \(t_{0.025,\,24} \approx 2.064\).
\[ 78 \pm 2.064 \times \frac{12}{\sqrt{25}} = 78 \pm 2.064 \times 2.4 = 78 \pm 4.95 \]
\[ \text{95% CI} = (73.05,\ 82.95) \]
The analyst can be 95% confident that the true mean satisfaction score across all customers lies between 73.05 and 82.95.
30.3 Interpreting Confidence Intervals
- A narrower interval indicates a more precise estimate, achieved by increasing the sample size or reducing variability.
- A higher confidence level (e.g. 99% instead of 95%) produces a wider interval, since more certainty requires a larger margin of safety.
- A confidence interval that does not include a hypothesised value (e.g. a target score of 80) is informative for decision-making, and is directly connected to the hypothesis-testing framework covered in the next part of the book.
30.4 Confidence Intervals in R and Python
Transition to Inferential Statistics and Hypothesis Testing
Confidence intervals estimate what a population parameter probably is. The remaining chapters of this module take the next step — formal hypothesis testing — to decide whether an observed difference or relationship in the data is statistically significant, starting with the framework for choosing the right test.
Summary
| Concept | Description |
|---|---|
| Foundations | |
| Point Estimate | A single best-guess value for a population parameter, such as the sample mean |
| Interval Estimate (Confidence Interval) | A range of values, calculated from a sample, likely to contain the true population parameter |
| Confidence Level | The long-run proportion of similarly constructed intervals that would contain the true parameter |
| CI Formulas | |
| CI for a Mean (sigma known) | x-bar plus or minus Z times sigma over the square root of n |
| CI for a Mean (sigma unknown) | x-bar plus or minus the t critical value times s over the square root of n, using n-1 degrees of freedom |
| CI for a Proportion | p-hat plus or minus Z times the square root of p-hat times (1 minus p-hat) over n |
| Margin of Error | The plus-or-minus amount added to and subtracted from the point estimate to form the interval |
| Interpretation | |
| Width vs Precision | A narrower interval reflects a more precise estimate, from a larger sample or less variability |
| Width vs Confidence Level | A higher confidence level produces a wider interval, trading precision for certainty |
| In R and Python | |
| R t.test() | Built-in R function that returns a confidence interval alongside a one-sample t-test |
| Python scipy.stats.t.interval() | SciPy function that computes a confidence interval directly from a distribution's parameters |