Day 10. Hypothesis Testing, p-Values & Power
Deciding whether an effect is distinguishable from zero, and designing studies that can tell.
- ●Set up a test, compute a z-statistic and p-value, and state the decision correctly.
- ●Prove that p-values are uniform under the null.
- ●Derive the power formula, the required sample size and the minimum detectable effect.
- ●Explain multiple testing, statistical versus economic significance, and the winner's curse.
Theory
The logic of a test
- State a null hypothesis and an alternative .
- Compute a test statistic whose distribution under is known: .
- The p-value is the probability, if were true, of a statistic at least as extreme as the one observed: .
- Reject at level when , equivalently .
Two kinds of error
| true | false | |
|---|---|---|
| Reject | Type I error (prob. ) | Correct (prob. = power) |
| Do not reject | Correct | Type II error (prob. ) |
Power, sample size and the MDE
If the true effect is , then and
For two arms of size with outcome SD , . Solving for power :
With and 80% power, : the MDE is 2.8 standard errors.
Pitfalls
- Multiple testing: with many tests, some will be "significant" by chance.
- Statistical ≠ economic significance: huge samples make tiny effects significant.
- Winner's curse: in underpowered studies, estimates that clear the significance bar are exaggerated.
Part 1 · Warm-up
Exercise 1 · Hypotheses
A job-training programme's effect on earnings is . Write the null and two-sided alternative for "the programme has an effect".
Show solution
versus .
Exercise 2 · A z-statistic
The estimated effect is 3.2 (thousand dollars) with SE 1.25. Compute .
Show solution
.
Exercise 3 · Decision and p-value
Is the effect significant at 5%? Compute the p-value.
Show solution
, so reject . .
Exercise 4 · What a p-value is not
A report says "p = 0.01, so there is a 1% chance the programme has no effect." Correct it.
Show solution
The p-value is computed assuming is true: if the programme had no effect, results at least this extreme would occur about 1% of the time. It is not ; that requires a prior (Day 13).
Exercise 5 · Trading off errors
What happens to Type I and Type II error rates if you lower from 0.05 to 0.01 with the same data?
Show solution
Type I falls to 1%, but the critical value rises from 1.96 to 2.576, so real effects are rejected less often: Type II error rises and power falls. Only more information (larger , less noise) lowers both.
Part 2 · Proofs
Exercise 6 · p-values are uniform under the null
Let the statistic have continuous CDF under , and define the one-sided p-value . Show under .
Show solution
For : . So under every p-value is equally likely, and by construction.
Exercise 7 · The power formula
Derive .
Show solution
Step 1. Under the alternative, with .
Step 2. With :
Step 3. Add them.
Step 4. For the second term is tiny, giving the approximation in the theory block.
Exercise 8 · Sample size
Derive per arm, and apply it with , , , power 0.8.
Show solution
Derivation
Step 1. Approximate power: .
Step 2. Apply : .
Step 3. Substitute : .
Step 4. Square and solve: .
Application
Step 5. , , so .
Step 6. ; round up.
Answer: 393 per arm.
Exercise 9 · Unequal allocation
With a fixed total and a share treated, . Show is optimal and find the cost of a 70/30 split.
Show solution
Step 1. is smallest when is largest, which happens at (Day 3, Exercise 12).
Step 2. At a 70/30 split, , versus 0.25 at 50/50.
Step 3. Variance ratio: .
Answer: 50/50 is optimal; a 70/30 split needs about 19% more people for the same precision (still worth it if treatment is expensive, Day 26).
Exercise 10 · The winner's curse
The true effect is and . Compute the power, and the expected estimate given that it is significantly positive. Hint: if , then .
Show solution
Step 1. Power: , so power .
Step 2. Given a significant positive result, use the truncated-normal mean with , , :
Step 3. and ; ratio ≈ 1.493.
Step 4. .
Answer: power is only 17%, and the significant estimates average 2.5 times the true effect. Small published studies often overstate effects for this reason.
Part 3 · Applied
Exercise 11 · One-sided or two-sided? A cash-transfer test
A conditional cash transfer's effect on school enrolment gives . The team had planned a two-sided test. Compute the one-sided and two-sided p-values. Which should be reported?
Show solution
Step 1. One-sided: .
Step 2. Two-sided: .
Answer: report the pre-planned two-sided . Switching to one-sided after seeing the sign doubles the false-positive rate; one-sided tests are fine only if pre-registered for a substantive reason (e.g. the transfer cannot plausibly reduce enrolment).
Exercise 12 · An underpowered nutrition trial
A nutrition supplement trial can estimate the effect on child height with SE 1.5 cm. If the true effect is 3 cm, what is the trial's power at the 5% level?
Show solution
Step 1. Standardised effect: .
Step 2. Power .
Answer: about 52%: a coin flip. A null result from this trial would say little about whether the supplement works.
Exercise 13 · Minimum detectable effect
With 500 per arm and , what is the MDE at 5% significance and 80% power?
Show solution
Step 1. .
Step 2. MDE multiplier at 5% and 80% power: .
Step 3. .
Answer: the study can reliably detect effects of about 3.5 units or more.
Exercise 14 · Twenty outcomes
A study tests 20 independent outcomes at 5%, and the programme truly affects none. What is the chance of at least one "significant" result? What threshold does Bonferroni use?
Show solution
Step 1. Each test has a 0.95 chance of not giving a false positive; independent, so all 20 avoid one with probability .
Step 2. At least one false positive: .
Step 3. Bonferroni divides the level by the number of tests: . By Boole's inequality (Day 1), the chance of any false positive is then at most .
Answer: a 64% chance of at least one spurious "effect"; Bonferroni tests each outcome at 0.0025.
Exercise 15 · Statistical versus economic significance
On 5 million tax records, a policy raises earnings by $1.50 a year with . Interpret.
Show solution
Step 1. with .
Step 2. With , , so the SE is tiny and even $1.50 gives a huge .
Answer: the effect is precisely estimated (statistically significant) but negligible in size (economically insignificant). Report the effect and its CI, not just the p-value.
Verify in Python
import numpy as np
from scipy import stats
z = 3.2 / 1.25
print(f"z = {z:.2f}, p = {2 * stats.norm.sf(z):.4f}")
za, zb = stats.norm.ppf(0.975), stats.norm.ppf(0.80)
print("n per arm:", np.ceil(2 * 10**2 * (za + zb)**2 / 2**2))
print("MDE:", round((za + zb) * 20 * np.sqrt(2 / 500), 2))
print("P(>=1 false positive in 20):", round(1 - 0.95**20, 3))
# Winner's curse by simulation
rng = np.random.default_rng(10)
est = rng.normal(1, 1, 1_000_000)
sig = est > za
print(f"power {sig.mean():.3f}; mean significant estimate {est[sig].mean():.2f} (truth 1)")
# p-values are uniform under H0
p = 2 * stats.norm.sf(np.abs(rng.normal(0, 1, 100_000)))
print("share p < 0.05 under H0:", round((p < 0.05).mean(), 3))
Key takeaways
- A p-value measures how surprising the data would be if the null were true.
- Power depends on effect size relative to the SE; the MDE at 80% power is about 2.8 SEs.
- Watch for multiple testing, tiny-but-significant effects and exaggerated significant estimates.
Simulation Lab: Statistical Power Visualiser
Open full screen →The null and alternative sampling distributions, the rejection region, α, β and power.
Blue: where the estimate lands if there is no effect. Orange: where it lands if the effect is τ. Shaded orange = power; shaded blue tails = α; the hatched part of the orange curve inside the critical values = β.