Hypothesis Testing Fundamentals
Hypothesis Testing Notes
Fundamentals of Hypothesis Testing
Why Statistics Exists
Without variability, there is no need for statistics. If all data points were identical, conclusions would be obvious. In practice, data varies — and statistics helps determine whether observed differences are real or due to chance.
Key insight: We analyze variance to make inferences about means. The spread of data within groups is compared to the overall variability to decide if group differences are meaningful.
Statistical Inference
Statistical inference is the process of drawing a sample from a population of interest, analyzing the sample data, and making conclusions about the population based on those results. This is the foundation of hypothesis testing.
Null and Alternative Hypotheses
Null hypothesis (H0) : The statement of no difference. For example, the experimental treatment and control have equal effectiveness. The difference between them is zero.
Alternative hypothesis (H1 or Ha) : The statement that a difference exists. The experimental treatment differs from the control (often expected to be better).
The goal is to reject H0 in favor of H1 — to find evidence that there is a real difference.
Possible Conclusions and Errors
Truth → Conclusion ↓ | H0 is true (no difference) | H0 is false (difference exists) |
|---|---|---|
Reject H0 (claim difference) | Type I error (false positive) | Correct conclusion (true positive) |
Do not reject H0 (no claim) | Correct conclusion (true negative) | Type II error (false negative) |
Type I error (α) : Probability of rejecting H0 when it is true — claiming a difference that does not exist.
Type II error (β) : Probability of failing to reject H0 when it is false — missing a real difference.
Power (1−β) : Probability of correctly rejecting H0 when a true difference exists — detecting an effect when it is present.
Alpha (α) is the pre-specified threshold for Type I error, commonly set at 0.05 (two-sided). It controls the risk of a false positive.
Power is the chance of concluding the experimental treatment is more effective when it truly is. High power is desirable. Typical values: early phase trials 0.6–0.8, late phase trials 0.8–0.95.
Trade-off Between Alpha and Beta
Without changing sample size, decreasing α (making it harder to claim a difference) increases β (misses real differences), which decreases power. Conversely, increasing α increases power but raises the chance of a false positive. Sample size controls both; larger samples can reduce both α and β.
The P-value
P-value definition: The probability of obtaining a result as extreme as or more extreme than the one observed, assuming the null hypothesis is true.
If p≤α (e.g., p≤0.05), reject H0 — the data are unlikely under H0.
If p>α, do not reject H0 — the data are consistent with H0.
Common misinterpretations — the p-value is not:
The probability that H0 is true.
The probability that the results are due to chance.
The probability that H1 is true (nor 1−p).
The chance that the alternative is true.
Coin Toss Example (Classical Hypothesis Testing)
H0: Coin is regular (heads probability = 0.5).
H1: Coin is two-headed (heads probability = 1).
Experiment: Toss repeatedly, each toss costs 100. Decide when to stop and claim the coin is two-headed.
After 7 heads in a row, the p-value is 0.57=0.008. Since 0.008<0.05, we reject H0 and conclude the coin is two-headed. This does not prove it — we are confident but not certain.
Bayesian Hypothesis Testing
The Bayesian approach starts with a prior belief about the hypotheses, then updates that belief using data to form a posterior belief. The posterior becomes the prior for the next experiment, allowing sequential learning.
Prior: equal chance (0.5) for regular coin and two-headed coin.
After each head, the probability of the two-headed coin increases and the probability of the regular coin decreases.
After 7 heads, the posterior probability is 0.8% for the regular coin and 99.2% for the two-headed coin.
Bayesian probabilities are interpreted directly as the probability that a hypothesis is true, unlike p-values. The numbers are calculated differently and can be close to p-values but have distinct meanings.
Bayesian thinking is intuitive: We update our beliefs as new evidence arrives — the same way humans learn from experience.
Connection Between P-value, Sample Size, and Statistical Significance
As sample size increases, the standard error of the estimated difference decreases (because it contains n in the denominator). This makes the sampling distribution of the difference under H0 tighter. With the same observed treatment effect, a larger sample can yield a lower p-value, turning a non-significant result into a significant one.
Important: Statistical significance does not imply clinical importance. A tiny improvement (e.g., reducing headaches from 50 to 49 per week) can be statistically significant with a huge sample, but may not matter to patients.
Power analysis determines the smallest sample size needed to detect a clinically meaningful effect with sufficient power.
Two guaranteed ways to get a statistically significant result:
Use a very large sample size (every tiny difference becomes significant).
Run many different tests (by chance, 5% will be significant even if no real effect).
Confidence Intervals and Hypothesis Testing
A 95% confidence interval (CI) for a parameter (e.g., treatment difference) is calculated as:
Bayesian interpretation: There is a 95% chance the true value lies within the interval.
Frequentist interpretation: If the study were repeated many times, 95% of such intervals would contain the true value.
Connection to hypothesis testing: If the 95% CI does not cover the null value (e.g., 0 for a difference), the result is statistically significant at the α=0.05 level. If it covers 0, the result is not significant.
Confidence intervals provide more information than p-values: they show the range of plausible effect sizes, helping assess clinical importance.
Superiority, Non-inferiority, and Equivalence Trials
Superiority Trials
Goal: Show the experimental treatment is more effective than the control (e.g., better than placebo).
H0: Experimental equals control (difference = 0).
H1: Experimental is different from control (two-sided, but we hope for positive).
Conclusion: If the entire 95% CI lies to the right of 0, claim superiority.
Non-inferiority Trials
Goal: Show the experimental treatment is not worse than the control by more than a pre-specified margin Δ (non-inferiority margin).
H0: Experimental is worse than control by at least Δ (i.e., difference ≤−Δ).
H1: Experimental is not inferior (difference >−Δ).
Conclusion: If the entire 95% CI lies to the right of −Δ, claim non-inferiority.
The margin Δ is determined by subject-matter experts, not statisticians, and represents the largest acceptable loss of efficacy.
Equivalence Trials
Goal: Show the experimental and control treatments are about the same (e.g., generic vs. brand drug).
H0: The difference lies outside the equivalence margins [−Δ,+Δ] (i.e., they are not equivalent).
H1: The difference lies within [−Δ,+Δ] (they are equivalent).
Conclusion: If the entire 95% CI lies within the interval [−Δ,+Δ], claim equivalence.
Multiple Comparisons
Problem: When many hypothesis tests are performed, the probability of at least one Type I error increases. For k independent tests each at α=0.05, the familywise error rate is 1−(0.95)k, which rises quickly.
When to adjust:
Formal adjustment is required when there are multiple primary endpoints or multiple primary comparisons (e.g., three treatment groups with pairwise tests).
Informal adjustment (e.g., using a stricter threshold like 0.01 or acknowledging the issue in the paper) is acceptable for exploratory secondary analyses and subgroup analyses.
Bonferroni correction (simplest formal method): Divide the desired α by the number of tests. For m tests, reject H0 only if p≤α/m. This is conservative but widely used.
Second guaranteed way to get significance: Keep testing different outcomes, subgroups, or methods — eventually something will appear significant by chance. Careful multiple comparison adjustment prevents this.
Summary Key Points
Statistical inference uses sample data to draw conclusions about a population.
The null hypothesis is set up with the expectation of being rejected in favor of the alternative.
α (Type I error probability) is the chance of concluding a difference exists when it does not.
β (Type II error probability) is the chance of concluding no difference when one exists.
Power (1−β) is the chance of correctly detecting a real difference.
Sample size controls both α and β — investigators can balance errors by choosing an appropriate sample.
p-value is the probability of obtaining data as extreme as observed under H0 — nothing more, nothing less.
Statistical significance does not equal clinical importance — always consider effect size and confidence intervals.
Confidence intervals provide practical context: the range of plausible effect sizes helps interpret results.
Multiple comparisons require formal adjustment for primary analyses; use informal caution for exploratory work.
Bayesian methods are increasingly used and offer an intuitive framework with direct probability statements about hypotheses.

Ask anything
We've read this whole study set, so questions about it get the best answers.