⚖️ Confidence intervals and hypothesis tests

A sample gives one number. Inference says how far off it might be, and whether a claim survives it.

⭐ The one idea

A sample gives you one number. Inference says how far off it might be (a confidence interval) or whether a claim about the population survives the evidence (a hypothesis test). Both are built from the same piece: the standard error.

📏 Confidence intervals (week 10)

Anatomy of an intervalx̄ = 132point estimate127.5136.5E = 4.5CI = point estimate ± E, and E =critical value × standard error.
Every confidence interval has the same shape: point estimate ± margin of error. E = critical value × standard error.
20 samples, 20 intervals19 of them catch the true μthe gold line is the true μIn real life you never see thatline — which is why one redinterval is impossible to spotfrom the inside.
“95% confident” means: if we repeated the sampling forever, 95% of the intervals built this way would contain the true μ. Any single interval either does or does not — we just do not know which.

🔢 Mean, σ known (z)

x̄ ± z* · σ/√n

Rare in real life — you almost never know σ.

🔢 Mean, σ unknown (t)

x̄ ± t* · s/√n    df = n − 1

The normal case. t* comes from the t-table (or Desmos tdist).

🔢 Proportion (z)

p̂ ± z* · √( p̂(1−p̂) / n )

Needs np̂ ≥ 5 and n(1−p̂) ≥ 5 (some books: 10).

⭐ z* to memorize

90% → 1.645   95% → 1.96   99% → 2.576

t has fatter tails than zz (normal)t, df = 10t, df = 2Use t when σ is unknown, whichis nearly always. More df makest look like z.
The t-distribution has fatter tails than z because s is only an estimate of σ. Small samples → fatter tails → bigger t* → wider interval.

🧪 Worked: mean systolic BP on a unit

40 patients, x̄ = 132 mmHg, s = 14. 95% CI?

  1. df = 39 → t* = 2.023 (Desmos: tdist(39).inversecdf(0.975))
  2. SE = 14/√40 = 2.214
  3. E = 2.023 × 2.214 = 4.48
  4. CI = 132 ± 4.48 = (127.5, 136.5) mmHg

Say it right: “We are 95% confident the mean systolic BP of all patients on this unit is between 127.5 and 136.5 mmHg.” Not “95% of patients are in this range” and not “there is a 95% chance μ is in here.”

🧪 Worked: proportion of nurses reporting burnout

120 of 200 nurses surveyed → p̂ = 0.60. 95% CI?

  1. SE = √(0.6 × 0.4 / 200) = 0.0346
  2. E = 1.96 × 0.0346 = 0.068
  3. CI = 0.60 ± 0.068 = (0.532, 0.668) → 53% to 67%

⭐ What makes an interval wider?

  • Higher confidence level → wider (99% is wider than 90%)
  • Smaller sample → wider
  • More variability (bigger s) → wider

To halve the margin of error you need the sample.

🔢 Sample size for a mean

n = ( z*σ / E )²

Want BP within ±2 mmHg at 95%, σ ≈ 15: n = (1.96·15/2)² = 216.09 → 217. Always round UP.

🔢 Sample size for a proportion

n = p̂(1−p̂) (z*/E)²

No estimate for p̂? Use 0.5 (the worst case). Within ±4% at 95%: n = 0.25(1.96/0.04)² = 600.25 → 601.

⚖️ Hypothesis testing (weeks 11–13)

The five steps1State H₀ and HₐThe claim, then what yoususpect instead.2Pick αUsually 0.05.3Compute the statisticz or t from your sample.4Find the p-valueThe area out in the tail ortails.5Decidep ≤ α means reject H₀.
Five steps, every time. The p-value is the probability of seeing a sample this extreme if H₀ were true.

📌 H₀ and Hₐ

H₀ (null): the status quo, always has =. μ = 30 min.

Hₐ (alternative): what you suspect: (two-tailed), > or < (one-tailed). The words “more than”, “increased”, “less than”, “different from” tell you which.

🎯 α (significance level)

How much Type I risk you accept. Usually 0.05; 0.01 when a false alarm is costly (approving a drug).

📊 Test statistic

t = (x̄ − μ₀) / (s/√n)z = (p̂ − p₀) / √(p₀(1−p₀)/n)

How many standard errors the sample sits from the claim.

✅ The decision

p-value ≤ α → reject H₀ (“statistically significant”).

p-value > α → fail to reject H₀. Never say “accept H₀” or “H₀ is true”.

Right-tailed: Hₐ says μ > 3002.33
One-tailed p-value = area beyond the test statistic on the side Hₐ points to.
Two-tailed: Hₐ says μ ≠ 30−2.330+2.33
Two-tailed p-value = both tails, so it is double the one-tailed area.

🧪 Worked: ER wait time (t-test for a mean)

The ER claims mean door-to-provider time is 30 min. A sample of 36 visits: x̄ = 33.5 min, s = 9. Is the wait longer than claimed? α = 0.05.

  1. H₀: μ = 30   Hₐ: μ > 30 (right-tailed)
  2. t = (33.5 − 30)/(9/√36) = 3.5/1.5 = 2.33, df = 35
  3. p-value = P(t > 2.33) = 0.0128 (Desmos: tdist(35).cdf(2.33, ∞))
  4. 0.0128 < 0.05 → reject H₀.

Conclusion in words: There is enough evidence at the 5% level that the mean wait is longer than 30 minutes. (Two-tailed “different from 30” would give p = 0.0255 — still rejected.)

🧪 Worked: readmission rate (z-test for a proportion)

National readmission rate is claimed to be 20%. Your hospital: 62 of 250 discharges readmitted (p̂ = 0.248). Is your rate different? α = 0.05.

  1. H₀: p = 0.20   Hₐ: p ≠ 0.20 (two-tailed)
  2. SE = √(0.2 × 0.8 / 250) = 0.0253use p₀ from H₀, not p̂
  3. z = (0.248 − 0.20)/0.0253 = 1.90
  4. p-value = 2 × P(Z > 1.90) = 0.0578
  5. 0.0578 > 0.05 → fail to reject H₀.

Conclusion: Not enough evidence that the hospital’s rate differs from 20%. Note the sample rate looked higher; the test says that gap could easily be chance with n = 250.

💡 Critical-value method

Same test, other route: compare the statistic to a cut-off. Right-tailed α = 0.05, df 35 → t* = 1.69. Since 2.33 > 1.69, reject. Two-tailed α = 0.05 uses ±2.03. p-value and critical value always agree.

🔗 CI ↔ test

A 95% CI that excludes the claimed value = a two-tailed test at α = 0.05 that rejects it. The BP CI (127.5, 136.5) excludes 120 → the unit’s mean BP differs from 120.

⚠️ Type I and Type II errors

The four possible outcomesH₀ true, we do not reject✅ CorrectH₀ true, we REJECT❌ Type I error (α) — falsealarmH₀ false, we do not reject❌ Type II error (β) — a missH₀ false, we REJECT✅ Correct — this is POWER (1 −β)α is the false-alarm rate youagree to accept, usually 0.05.
α = P(Type I) = rejecting a true H₀. β = P(Type II) = failing to reject a false H₀. Power = 1 − β. Lowering α raises β unless you grow the sample.
Nursing versionProbabilityHow to shrink it
Type IConcluding a new protocol works when it doesn’t (false alarm); treating a healthy patientαlower α
Type IIMissing a protocol that really works; sending a sick patient homeβbigger n, bigger true effect, higher α

🧮 In Desmos

1tdist(39).inversecdf(0.975)= 2.0227   t* for 95%, df 39
2normaldist().inversecdf(0.975)= 1.96
3132 ± 2.023 · 14 / sqrt(40)Desmos shows both ends
4tdist(35).cdf(2.333, ∞)= 0.0128 one-tailed p
52 · tdist(35).cdf(2.333, ∞)= 0.0255 two-tailed p
62 · normaldist().cdf(1.897, ∞)= 0.0578
7ttest(L, 30)full one-sample t-test from raw data L
⌨️ The ± sign is on the Desmos keyboard (or type pm). For a left-tailed p-value use cdf(−∞, t); for two-tailed, double the smaller tail.

✅ Quick self-check

❓ A 99% CI for mean HbA1c is (7.1, 7.9). Would a 90% CI from the same data be wider or narrower?
Narrower. Less confidence → smaller z* → smaller margin of error.
❓ A study tests whether a new dressing reduces infection rate below 8%. Write H₀ and Hₐ.
H₀: p = 0.08. Hₐ: p < 0.08. Left-tailed.
❓ p-value = 0.03, α = 0.01. Decision?
Fail to reject H₀ (0.03 > 0.01). At α = 0.05 you would reject — which is why α is set before looking at the data.
❓ A drug is approved because a trial found it works, but it actually does nothing. Which error?
Type I — H₀ (“no effect”) was true and got rejected.
MAT 300 · built from your own course files (the statistics study guide, the Desmos guide, the formula sheet and the final-exam study questions) with nursing examples. Not a substitute for the textbook — check any number against your own notes before an exam.