Hypothesis Testing: A Clear Guide
Hypothesis testing is a statistical method to decide if there's evidence against a default assumption (the "null hypothesis") based on sample data. It's like a court trial: the null is "innocent until proven guilty," and we look for sufficient evidence to reject it.
I'll explain each concept step-by-step with examples, using a coin flip test (Is a coin fair? Null: probability of heads ( p = 0.5 )) and a drug trial (Does a new drug reduce blood pressure? Null: mean reduction ( \mu = 0 ) mmHg).
1. Null Hypothesis (H₀) vs. Alternative Hypothesis (Hₐ)
- Null (H₀): The default assumption of no effect, no difference, or status quo. It's what we try to disprove.
- Alternative (Hₐ or H₁): The claim of interest, e.g., there is an effect. Can be one-sided (e.g., ( p > 0.5 )) or two-sided (e.g., ( p \neq 0.5 )).
- We never prove H₀ true; we only reject it or fail to reject it.
Coin Example: Flip coin 100 times, get 60 heads.
- H₀: ( p = 0.5 ) (fair coin).
- Hₐ: ( p \neq 0.5 ) (biased).
Drug Example:
- H₀: ( \mu = 0 ) (no effect).
- Hₐ: ( \mu > 0 ) (reduces pressure).
2. Test Statistic
- A single number summarizing how far your sample data deviates from H₀, standardized for comparison.
- Common ones: z-statistic (normal data), t-statistic (small samples), chi-squared (categorical), F-stat (ANOVA).
- Formula: Often ( t = \frac{\hat{\theta} - \theta_0}{SE} ), where ( \hat{\theta} ) is sample estimate, ( \theta_0 ) is H₀ value, SE is standard error.
Coin Example:
- Sample proportion ( \hat{p} = 60/100 = 0.6 ).
- Test statistic: ( z = \frac{0.6 - 0.5}{\sqrt{0.5 \times 0.5 / 100}} = \frac{0.1}{0.05} = 2 ) (2 standard errors from H₀).
Drug Example: Sample mean reduction ( \bar{x} = 5 ) mmHg, SE = 2 → ( t = (5-0)/2 = 2.5 ).
Under H₀, test stats follow known distributions (e.g., standard normal).
3. P-Values vs. Confidence Intervals (CIs)
- P-value: Probability of observing data as extreme or more extreme than yours, assuming H₀ is true. Small p (e.g., < 0.05) → strong evidence against H₀ → reject it.
- At α = 0.05 significance level: Reject if p ≤ α.
- Confidence Interval (e.g., 95% CI): Range around sample estimate likely containing true parameter (95% confidence).
- If CI excludes H₀ value → reject H₀ at 5% level.
- P-value ≈ α when CI boundary = H₀ value.
- Key Differences:
| Aspect | P-Value | Confidence Interval |
|---|
| Interpretation | Prob(data | H₀ true) | Range for true parameter |
| Focus | Evidence against H₀ | Plausibility of values |
| Effect size | Doesn't show magnitude | Shows range + precision |
| Example (coin) | p = 0.045 (reject H₀) | 95% CI: [0.51, 0.69] (excludes 0.5) |
Coin Example: z=2 → p=0.045 (two-tailed). Reject H₀ at α=0.05.
Drug Example: 95% CI for μ: [1.2, 8.8] mmHg (excludes 0) → evidence of effect.
4. Type I and Type II Errors
Errors occur because decisions are based on samples (not full population).
| H₀ True (No Effect) | H₀ False (Effect Exists) |
|---|
| Reject H₀ | Type I (α, False Positive) | Correct (Power) |
| Fail to Reject | Correct | Type II (β, False Negative) |
- Type I (α): False alarm. Prob controlled by significance level (e.g., α=0.05 = 5% risk).
- Type II (β): Miss real effect. Depends on sample size, effect size, α.
Coin Example: α=0.05 means 5% chance of wrongly calling fair coin biased.
Drug Example: Type II = approving ineffective drug; Type I = rejecting good drug.
Trade-off: Lower α reduces Type I but increases Type II (unless bigger sample).
5. Power (1 - β)
- Probability of correctly rejecting H₀ when it's false.
- Formula: Power = 1 - β. Higher is better (e.g., aim for 80-90%).
- Increases with: larger sample size, larger true effect, higher α, less variability.
- Power calculation: Used pre-study to plan sample size.
Drug Example: If true μ=4 mmHg, n=50, power=0.85 → 85% chance of detecting effect.
6. Multiple Testing
- Testing many hypotheses (e.g., 20 genes) inflates Type I error: Expected false positives = 20 × 0.05 = 1.
- Solutions:
- Bonferroni: Divide α by #tests (e.g., α=0.05/20=0.0025).
- FDR (False Discovery Rate): Controls proportion of false positives (e.g., Benjamini-Hochberg).
- Example: Genome-wide study (1M tests). Raw p<0.05 → ~50K false positives. Bonferroni: p<5e-8.
7. Common Misinterpretations (and Fixes)
- "P-value = Prob(H₀ true)" ❌ No! It's Prob(data | H₀). H₀ could still be true (e.g., p=0.04 doesn't mean 4% chance innocent).
- Fix: Think "evidence against H₀."
- "Low p proves Hₐ true" ❌ Just rejects H₀; could be other alternatives.
- "P-value measures effect size" ❌ Small p can come from tiny effect + huge sample.
- Fix: Report effect size + CI (e.g., Cohen's d).
- "95% CI means 95% prob parameter inside" ❌ Frequentist: 95% of such CIs contain truth over repeated samples. This CI is fixed.
- "Fail to reject = accept H₀" ❌ No evidence against ≠ evidence of no effect. Could be underpowered.
- Ignoring power/multiple testing → Inflated errors.
- P-hacking: Cherry-picking data/tests for low p. Fix: Pre-register analysis.
Summary Example (Drug Trial):
- Data: n=100, mean=5 mmHg, SE=1.5 → t=3.33, p=0.001, 95% CI=[2.1,7.9].
- Decision: Reject H₀ (p<0.05, CI excludes 0).
- Power (true μ=4): 95%. Errors: α=0.05 (Type I risk), β=0.05.
- If 10 drugs tested: Use Bonferroni (p<0.005).
Hypothesis testing is powerful but probabilistic—combine with effect sizes, replication, and domain knowledge for robust conclusions! Questions?