12  Week 5: Confidence Intervals for a Proportion

12.1 Where We Are in the Analytics Decision Cycle

It’s worth pausing to reconnect everything we’ve done since Week 1 back to the analytics decision cycle from Chapter 2: > Frame the decision → obtain appropriate data → summarize the evidence → quantify uncertainty → build a model → recommend an action → communicate the result

Week 1 covered the first three steps directly: framing a business question as a decision, getting the right data, and summarizing it with tables, graphs, and descriptive statistics. Since then, we haven’t touched a real dataset much at all. Instead, Weeks 2 through 4 built the machinery that makes the fourth step, quantify uncertainty, possible in the first place:

  • Weeks 2 and 3 gave us the vocabulary of probability and named distributions (binomial, uniform, normal), the language for describing how individual outcomes behave.
  • Week 4 took that vocabulary one level up: instead of describing an individual observation, we described how a statistic like \(\bar{x}\) or \(\hat{p}\) behaves across repeated samples, its sampling distribution, its standard error, and (via the Central Limit Theorem or the normal approximation) its shape.

None of that work, on its own, handed a manager a usable answer. This week, we finally put it to use. A confidence interval takes a single point estimate computed from real data, like the \(\hat{p}=0.15\) conversion rate we observed in Chapter 10, and turns it into a range that honestly reflects how much sampling variability that estimate carries. This is the first moment in the course where “quantify uncertainty” produces something you could actually put in front of a decision-maker.

12.2 From Point Estimate to Interval Estimate

A point estimate is a single number, computed from a sample, used to estimate an unknown population parameter: \(\bar{x}\) estimates \(\mu\), \(\hat{p}\) estimates \(p\). A point estimate is easy to compute and easy to understand, but it has a serious limitation: it’s just one number, and we already know from Week 4 that a different sample would have produced a different point estimate. Reporting \(\hat{p}=0.15\) alone hides exactly the information a decision-maker most needs: how much would this estimate likely move if we resampled?

An interval estimate, specifically a confidence interval, addresses this by reporting a range of plausible values for the parameter, along with a stated level of confidence. Most confidence intervals takes the same basic shape: \[ \text{point estimate} \;\pm\; \text{margin of error} \] where the margin of error quantifies how far the point estimate might reasonably be from the true parameter. A wider margin of error means less precision; a narrower one means more.

12.3 Confidence Intervals for a Proportion

We’ll build our first confidence interval around the sample proportion \(\hat{p}\), since Chapter 10 already gave us everything we need: \(\hat{p}\)’s sampling distribution is approximately normal (when \(n\hat{p} \ge 15\) and \(n(1-\hat{p}) \ge 15\)), centered at \(p\), with standard error \(\sqrt{p(1-p)/n}\).

There’s one wrinkle: that standard error formula uses the true \(p\), which is exactly what we’re trying to estimate. In practice, we substitute \(\hat{p}\) in its place, giving an estimated standard error: \[ \text{SE}_{\hat{p}} = \sqrt{\frac{\hat{p}(1-\hat{p})}{n}} \]

The margin of error is this standard error multiplied by a critical value, denoted \(z_{\alpha/2}\), chosen so that the middle \((1-\alpha)\) proportion of a standard normal distribution falls between \(-z_{\alpha/2}\) and \(z_{\alpha/2}\). The full confidence interval for \(p\) is \[ \hat{p} \;\pm\; z_{\alpha/2}\sqrt{\frac{\hat{p}(1-\hat{p})}{n}} \]

NoteCommon critical values
Confidence level \(\alpha\) \(z_{\alpha/2}\)
90% 0.10 1.645
95% 0.05 1.960
99% 0.01 2.576

These values come from the standard normal distribution: for a 95% interval, for example, \(z_{0.025} = 1.96\) is the value such that 2.5% of the standard normal distribution lies above it and 2.5% lies below \(-1.96\), leaving 95% in the middle. In R, qnorm(0.975) returns this value directly.

ExampleExample 5.1: A confidence interval for the conversion rate

Returning to the website conversion example from Chapter 10: a marketing analyst samples \(n=200\) visitors and finds that 30 converted, so \(\hat{p} = 30/200 = 0.15\). Rather than assuming the true rate as we did in that section, we’ll now estimate it.

First, check the conditions: \(n\hat{p} = 200(0.15) = 30 \ge 15\) and \(n(1-\hat{p}) = 200(0.85) = 170 \ge 15\). Both hold, so the normal approximation is reasonable.

The estimated standard error is \[ \text{SE}_{\hat{p}} = \sqrt{\frac{0.15(0.85)}{200}} \approx 0.0252 \] For a 95% confidence interval, the margin of error is \[ 1.96 \times 0.0252 \approx 0.0494 \] The 95% confidence interval for the true conversion rate is \[ 0.15 \pm 0.0494, \quad \text{or} \quad (0.101, \, 0.199) \] We would report this as: “We are 95% confident that the true website conversion rate is between 10.1% and 19.9%.”

12.4 Computing Confidence Intervals in R and Excel

ExampleExample 5.2: The conversion rate interval in R and Excel
p_hat <- 30 / 200
n <- 200
se <- sqrt(p_hat * (1 - p_hat) / n)
z_star <- qnorm(0.975)

lower <- p_hat - z_star * se
upper <- p_hat + z_star * se

c(lower, upper)
[1] 0.1005133 0.1994867

R also has a built-in function, prop.test(), that computes this interval directly (using a slightly different, more conservative method by default, so don’t be surprised if the numbers differ very slightly from the by-hand calculation above):

prop.test(x = 30, n = 200, correct = FALSE)$conf.int
[1] 0.1071359 0.2060558
attr(,"conf.level")
[1] 0.95

In Excel, the same by-hand calculation looks like:

=0.15 - NORM.S.INV(0.975) * SQRT(0.15*(1-0.15)/200)   ' lower bound
=0.15 + NORM.S.INV(0.975) * SQRT(0.15*(1-0.15)/200)   ' upper bound

NORM.S.INV() is Excel’s function for the standard normal quantile, the same role qnorm() plays in R.

12.5 Interpreting a Confidence Interval Correctly

A 95% confidence interval does not mean “there’s a 95% probability that the true \(p\) is in this particular interval.” Once an interval like \((0.101, 0.199)\) is calculated, \(p\) either is or isn’t in it; there’s no probability left to talk about for that one interval.

What “95% confidence” actually means is a statement about the procedure: if we repeated this sampling process many times, each time drawing a new sample of 200 visitors and constructing a new 95% confidence interval, approximately 95% of those intervals would contain the true value of \(p\). Any single interval either succeeded in capturing \(p\) or it didn’t; the 95% describes how often the method works over the long run, not our certainty about this one result.

NoteA useful way to phrase it for a business audience

Instead of saying “there’s a 95% chance \(p\) is in this interval,” say: “we used a method that produces a correct range 95% of the time, and this is the range it gave us for this sample.” It’s less snappy, but it’s accurate, and it keeps the door open to the honest follow-up question: what happens the other 5% of the time?

12.6 Recap

Keyword Definition
Point estimate A single statistic (e.g., \(\hat{p}\)) used to estimate a population parameter.
Interval estimate (confidence interval) A range of plausible values for a parameter, built as point estimate plus or minus a margin of error.
Margin of error The critical value multiplied by the standard error; determines the width of a confidence interval.
Critical value (\(z_{\alpha/2}\)) The standard normal value such that the middle \((1-\alpha)\) of the distribution falls between \(-z_{\alpha/2}\) and \(z_{\alpha/2}\).
Confidence interval for \(p\) \(\hat{p} \pm z_{\alpha/2}\sqrt{\hat{p}(1-\hat{p})/n}\).
Confidence level interpretation The percentage of the time the interval-construction procedure captures the true parameter, across repeated sampling; not the probability the parameter is in any one specific interval.

12.7 Check Your Understanding

NoteProblems
  1. A quality team samples 250 units from a production run and finds 18 defective. Compute \(\hat{p}\), check the normal-approximation conditions, and construct a 95% confidence interval for the true defect rate.

  2. A survey of 400 employees finds that 260 support a proposed policy change. Construct a 90% confidence interval for the true proportion of employees who support the change.

  3. Explain what’s wrong with this statement: “There is a 95% probability that the true conversion rate is between 10.1% and 19.9%.”

  4. Without doing any calculation, explain whether a 99% confidence interval for the same sample would be wider or narrower than a 95% confidence interval, and why.

  1. \(\hat{p} = 18/250 = 0.072\). \(n\hat{p} = 250(0.072) = 18 \ge 15\); \(n(1-\hat{p}) = 250(0.928) = 232 \ge 15\). Both conditions hold. \(\text{SE} = \sqrt{0.072(0.928)/250} \approx 0.0164\). Margin of error \(= 1.96 \times 0.0164 \approx 0.0322\). The 95% confidence interval is \(0.072 \pm 0.0322\), or \((0.040, 0.104)\).

  2. \(\hat{p} = 260/400 = 0.65\). For 90% confidence, \(z_{0.05} = 1.645\). \(\text{SE} = \sqrt{0.65(0.35)/400} \approx 0.0238\). Margin of error \(= 1.645 \times 0.0238 \approx 0.0392\). The 90% confidence interval is \(0.65 \pm 0.0392\), or \((0.611, 0.689)\).

  3. This statement treats the confidence level as a probability statement about one specific, already-calculated interval, but \(p\) is a fixed (though unknown) number, and the interval \((0.101, 0.199)\) either contains it or it doesn’t. The correct interpretation is that the procedure used to construct the interval captures the true value in about 95% of samples over the long run, not that there’s a 95% chance the true value falls in this particular interval.

  4. A 99% confidence interval would be wider. A higher confidence level requires a larger critical value (\(z_{0.005} = 2.576\) versus \(z_{0.025} = 1.96\)), which increases the margin of error. To be more confident that the interval captures the true parameter, the interval has to cover a wider range of plausible values.