6. Inference with Mathematical Models

b. Confidence Intervals

Yurk

Where We’ve Been

Yesterday (6a): the normal model gave us a math shortcut for hypothesis tests on a proportion.

  • Check conditions → the sampling distribution of \(\hat{p}\) is roughly normal
  • Standardize \(\hat{p}\) to a \(Z\)-score → read the p-value as a tail area

Today: the same normal model gives us a math shortcut for confidence intervals.

Recall: The Bootstrap CI

Back in 4 we built a 95% CI by:

  1. Resampling the original sample many times (with replacement)
  2. Computing \(\hat{p}\) for each resample → bootstrap distribution
  3. Reading off the 2.5th and 97.5th percentiles

Because the bootstrap distribution was approximately normal and centered at \(\hat{p}\), those 2.5th and 97.5th percentiles fall close to \(\hat{p} \pm 1.96 \cdot SE\) — and that’s the formula we’ll use today.

CI Formula via the Normal Model

If the sampling distribution of \(\hat{p}\) is approximately normal, the confidence interval is:

\[\hat{p} \;\pm\; z^* \cdot SE\]

where:

  • \(\hat{p}\) — the observed proportion
  • \(z^*\) — critical value (multiplier) for the chosen confidence level
  • \(SE = \sqrt{\dfrac{\hat{p}\,(1-\hat{p})}{n}}\)

Conditions: CI for One Proportion

Before using the normal model for a CI, check:

  1. Independence — observations are independent (random sample, sample < 10% of population)

  2. Success-failure — using \(\hat{p}\) this time:

    • \(n \cdot \hat{p} \geq 10\) (observed successes)
    • \(n \cdot (1 - \hat{p}) \geq 10\) (observed failures)
    • At least 10 successes AND 10 failures observed

Key difference from H-test: a CI plugs in \(\hat{p}\); an H-test plugs in \(p_0\). A CI has no null value to assume.

Critical Values: z*

Confidence level \(z^*\)
90% 1.645
95% 1.960
99% 2.576

These come straight from the standard normal:

  • 95% confident → capture the middle 95% of the standard normal → 2.5% left in each tail → \(z^*\) is the value with 2.5% above it, 1.96.

The Model-Based Inference calculator in Jamovi’s Randomize module gives you \(z^*\) for any confidence level (90%, 92%, 99%, …) — not just the three above. It also computes the CI and p-value directly.

Margin of Error = Dart Radius

Back in 4a: each \(\hat{p}\) is a dart, \(p\) is the bullseye. The CI is a circle around our dart, sized to catch the bullseye some fraction of the time.

The margin of error is the radius of that circle:

\[\text{margin of error} \;=\; z^* \cdot SE\]

So the CI is just \(\hat{p} \;\pm\;\) margin of error.

Whatever makes the radius bigger makes the CI wider — next slide names what controls it.

What Drives the CI Width?

\[\hat{p} \;\pm\; \underbrace{z^* \cdot SE}_{\text{margin of error}} \;=\; \hat{p} \;\pm\; z^* \cdot \sqrt{\frac{\hat{p}(1-\hat{p})}{n}}\]

Three things change the margin of error — all visible in the formula:

Change Effect Why
Confidence level goes up wider \(z^*\) gets bigger
Sample size goes up narrower \(SE\) gets smaller
\(\hat{p}\) closer to 0.5 wider \(\hat{p}(1-\hat{p})\) gets bigger

Topic 4b discovered these patterns by experiment with the bootstrap. Now you can read them straight off the formula.

Recall: Payday Loan Study

From 6a: in a national random sample of \(n = 826\) payday loan borrowers, 424 (51.3%) said they support additional regulation.

Yesterday’s H-test: \(H_0: p = 0.5\) vs \(H_A: p > 0.5\) → p-value = 0.222 → failed to reject \(H_0\).

Today’s question: what range of values for \(p\) is plausible given our data? Build a 95% confidence interval.

95% CI for Payday

Same data as 6a: \(n = 826\), \(\hat{p} = 0.513\).

Conditions:

  • Random sample → ✓ independence
  • Observed successes: 424 ≥ 10 ✓    Observed failures: 402 ≥ 10 ✓

Standard error (uses \(\hat{p}\)): \[SE = \sqrt{\dfrac{0.513 \times 0.487}{826}} = 0.0174\]

95% CI: \[0.513 \;\pm\; 1.96 \times 0.0174 \;=\; (0.479,\; 0.547)\]

Payday — Interpret the CI

95% CI: \((0.479,\; 0.547)\)

We are 95% confident that the true proportion of payday borrowers who support the regulation is between 47.9% and 54.7%.

Notice: the interval includes 0.5 — the null value from yesterday’s hypothesis test. That’s consistent with our H-test result (we failed to reject \(H_0: p = 0.5\)). Topic 7 will tighten this “consistent with” into a precise equivalence.

Build CIs at Different Levels

A campus survey of \(n = 400\) randomly sampled university students asks whether they’ve used a generative-AI tool for a class assignment. 272 say yes (\(\hat{p} = 0.68\)). Conditions are met (272 ≥ 10 successes, 128 ≥ 10 failures).

  1. Compute SE, then build the 95% CI. \(SE = \sqrt{\dfrac{0.68 \times 0.32}{400}} \approx 0.0233\).   95% CI: \(0.68 \pm 1.96 \times 0.0233 \approx\) \((0.634,\; 0.726)\).

  2. Interpret the 95% CI in plain English. We are 95% confident that the true proportion of university students who have used a generative-AI tool for a class assignment is between 63.4% and 72.6%.

  3. Now build the 99% CI. (use \(z^* = 2.576\)) \(0.68 \pm 2.576 \times 0.0233 \approx\) \((0.620,\; 0.740)\) — wider, as the formula predicts.

  4. Without computing, will the 90% CI be wider or narrower than the 95%? Why? Narrower. \(z^*\) drops from 1.96 to 1.645, so the margin of error shrinks. Less confidence required → smaller circle around our dart.

When Does the Normal Model Work?

Blue bars = simulated sampling distribution. Red curve = normal approximation.

Left (\(n=100\), \(p=0.5\)): success-failure passes (\(np = 50\), \(n(1-p) = 50\)) — great fit.

Right (\(n=30\), \(p=0.05\)): success-failure fails (\(np = 1.5 < 10\)) — true distribution is right-skewed, normal model misses it. That’s why we check the conditions.

Simulation or Normal Model?

For each scenario, you want a 95% CI for \(p\). Which approach should you use — simulation or the normal model?

  1. Random sample of \(n = 1{,}200\) likely voters; \(\hat{p} = 0.52\). Normal model. Observed successes \(\approx 624\) and failures \(\approx 576\) — both far above 10. Conditions met, so use the formula.

  2. Pilot trial of \(n = 25\) patients on a new pain medication; 5 report substantial relief (\(\hat{p} = 0.20\)). Simulation. Only 5 observed successes — fails success-failure. Use the bootstrap percentile CI from Topic 4.

  3. Quality-control sample of \(n = 200\) widgets; 3 are defective (\(\hat{p} = 0.015\)). Simulation. Only 3 observed successes — fails success-failure (rare events even at moderate \(n\)). Use the bootstrap percentile CI from Topic 4.

Summary

CI from the normal model: \(\;\hat{p} \pm z^* \cdot SE\), with \(SE = \sqrt{\hat{p}(1-\hat{p})/n}\).

Conditions to check:

  • Independence
  • \(n\hat{p} \geq 10\) and \(n(1-\hat{p}) \geq 10\) — at least 10 successes and 10 failures observed

When both conditions hold: simulation and the normal model give similar answers, and the formula is faster. Success-failure fails (independence OK): fall back on the bootstrap. Independence fails: both methods break down — the data themselves need a closer look.

References