Hypothesis testing and p-values

core 12 mininferencehypothesis-testingp-values

Builds on:CLT and sampling distributions

The idea

Hypothesis testing is proof by statistical contradiction. Assume the boring world — the null hypothesis H0H_0 (no effect, no difference) — and ask how surprising your data would be in that world. Surprising enough, and you reject the boring world in favor of the alternative H1H_1.

The measure of surprise is the p-value:

p=P(test statistic at least as extreme as observed∣H0)p = P(\text{test statistic at least as extreme as observed} \mid H_0)

Every word carries weight. Given H0H_0: the calculation lives entirely in the null world; it says nothing directly about whether H0H_0 is true. At least as extreme: it is a tail probability, not the probability of your exact data. The standard recipe:

  1. State H0H_0 and H1H_1, and pick α\alpha (the false positive rate you will tolerate — 0.05 by convention, not by law) before looking.

  2. Compute a test statistic whose distribution under H0H_0 is known — usually via the CLT. For two proportions:

    z=p^B−p^Ap^(1−p^)(1/nA+1/nB).z = \frac{\hat{p}_B - \hat{p}_A} {\sqrt{\hat{p}(1-\hat{p})(1/n_A + 1/n_B)}}.
  3. Convert to a p-value; reject H0H_0 if p<αp < \alpha.

The error vocabulary: Type I (α\alpha) — reject a true null; Type II (β\beta) — miss a real effect; power =1−β= 1 - \beta — the probability of catching a real effect of a given size.

The traps — this is what interviews actually test:

Worked example

A/B test on conversion. Control: 500/5,000 = 10%. Treatment: 550/5,000 = 11%.

Pooled rate: p^=500+55010000=0.105\hat{p} = \frac{500 + 550}{10000} = 0.105.

SE0=0.105×0.895×(15000+15000)≈0.00613\text{SE}_0 = \sqrt{0.105 \times 0.895 \times \left(\tfrac{1}{5000} + \tfrac{1}{5000}\right)} \approx 0.00613

z=0.11−0.100.00613≈1.63⇒p≈2 (1−Φ(1.63))≈0.10z = \frac{0.11 - 0.10}{0.00613} \approx 1.63 \quad\Rightarrow\quad p \approx 2\,(1 - \Phi(1.63)) \approx 0.10

Two-sided p≈0.10>0.05p \approx 0.10 > 0.05: fail to reject. The right conclusion is not "the treatment does nothing" — the 95% CI for the lift is roughly (−0.2,+2.2)(-0.2, +2.2) percentage points, which contains both zero and a lift that would be a clear business win. The experiment was underpowered for a 1-point effect (it had roughly 37% power); it needed about 15,000 users per arm to detect that lift reliably at 80% power. The honest verdict: inconclusive, and the fix is sample size, not narrative.

Cheat sheet

ErrorMeaningRateReduce by
Type Ireject true nullα\alphalower α\alpha
Type IImiss real effectβ\betamore nn, bigger effect, less variance, higher α\alpha

Trap table:

ClaimVerdict
"p = 0.03 → 3% chance the null is true"wrong — needs a prior; pp conditions on H0H_0
"p = 0.06 → no effect"wrong — possibly just underpowered; check the CI
"significant → matters"wrong — check effect size vs practical threshold
"we saw p < 0.05 after checking daily"invalid — peeking inflates α\alpha several-fold
"alpha = 0.05 → only 5% of our wins are false"wrong — that is FDR, which depends on prior and power