1. Home
  2. Explore
  3. Statistics
  4. Hypothesis Testing Fundamentals

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

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 (H0H_0H0​) : The statement of no difference. For example, the experimental treatment and control have equal effectiveness. The difference between them is zero.

  • Alternative hypothesis (H1H_1H1​ or HaH_aHa​) : The statement that a difference exists. The experimental treatment differs from the control (often expected to be better).

The goal is to reject H0H_0H0​ in favor of H1H_1H1​ — to find evidence that there is a real difference.

Possible Conclusions and Errors

Truth → Conclusion ↓

H0H_0H0​ is true (no difference)

H0H_0H0​ is false (difference exists)

Reject H0H_0H0​ (claim difference)

Type I error (false positive)

Correct conclusion (true positive)

Do not reject H0H_0H0​ (no claim)

Correct conclusion (true negative)

Type II error (false negative)

  • Type I error (α\alphaα) : Probability of rejecting H0H_0H0​ when it is true — claiming a difference that does not exist.

  • Type II error (β\betaβ) : Probability of failing to reject H0H_0H0​ when it is false — missing a real difference.

  • Power (1−β1 - \beta1−β) : Probability of correctly rejecting H0H_0H0​ when a true difference exists — detecting an effect when it is present.

Alpha (α\alphaα) is the pre-specified threshold for Type I error, commonly set at 0.050.050.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.60.60.6–0.80.80.8, late phase trials 0.80.80.8–0.950.950.95.

Trade-off Between Alpha and Beta

Without changing sample size, decreasing α\alphaα (making it harder to claim a difference) increases β\betaβ (misses real differences), which decreases power. Conversely, increasing α\alphaα increases power but raises the chance of a false positive. Sample size controls both; larger samples can reduce both α\alphaα and β\betaβ.

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≤αp \leq \alphap≤α (e.g., p≤0.05p \leq 0.05p≤0.05), reject H0H_0H0​ — the data are unlikely under H0H_0H0​.

  • If p>αp > \alphap>α, do not reject H0H_0H0​ — the data are consistent with H0H_0H0​.

Common misinterpretations — the ppp-value is not:

  • The probability that H0H_0H0​ is true.

  • The probability that the results are due to chance.

  • The probability that H1H_1H1​ is true (nor 1−p1-p1−p).

  • The chance that the alternative is true.

Coin Toss Example (Classical Hypothesis Testing)

  • H0H_0H0​: Coin is regular (heads probability = 0.50.50.5).

  • H1H_1H1​: Coin is two-headed (heads probability = 111).

  • Experiment: Toss repeatedly, each toss costs 100. Decide when to stop and claim the coin is two-headed.

After 777 heads in a row, the ppp-value is 0.57=0.0080.5^7 = 0.0080.57=0.008. Since 0.008<0.050.008 < 0.050.008<0.05, we reject H0H_0H0​ 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.50.50.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 777 heads, the posterior probability is 0.8%0.8\%0.8% for the regular coin and 99.2%99.2\%99.2% for the two-headed coin.

Bayesian probabilities are interpreted directly as the probability that a hypothesis is true, unlike ppp-values. The numbers are calculated differently and can be close to ppp-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\sqrt{n}n​ in the denominator). This makes the sampling distribution of the difference under H0H_0H0​ tighter. With the same observed treatment effect, a larger sample can yield a lower ppp-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:

  1. Use a very large sample size (every tiny difference becomes significant).

  2. 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:

point estimate±margin of error\text{point estimate} \pm \text{margin of error}point estimate±margin of error
  • 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., 000 for a difference), the result is statistically significant at the α=0.05\alpha = 0.05α=0.05 level. If it covers 000, the result is not significant.

Confidence intervals provide more information than ppp-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).

  • H0H_0H0​: Experimental equals control (difference = 000).

  • H1H_1H1​: Experimental is different from control (two-sided, but we hope for positive).

  • Conclusion: If the entire 95% CI lies to the right of 000, claim superiority.

Non-inferiority Trials

  • Goal: Show the experimental treatment is not worse than the control by more than a pre-specified margin Δ\DeltaΔ (non-inferiority margin).

  • H0H_0H0​: Experimental is worse than control by at least Δ\DeltaΔ (i.e., difference ≤−Δ\leq -\Delta≤−Δ).

  • H1H_1H1​: Experimental is not inferior (difference >−Δ> -\Delta>−Δ).

  • Conclusion: If the entire 95% CI lies to the right of −Δ-\Delta−Δ, claim non-inferiority.

  • The margin Δ\DeltaΔ 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).

  • H0H_0H0​: The difference lies outside the equivalence margins [−Δ,+Δ][-\Delta, +\Delta][−Δ,+Δ] (i.e., they are not equivalent).

  • H1H_1H1​: The difference lies within [−Δ,+Δ][-\Delta, +\Delta][−Δ,+Δ] (they are equivalent).

  • Conclusion: If the entire 95% CI lies within the interval [−Δ,+Δ][-\Delta, +\Delta][−Δ,+Δ], claim equivalence.

Multiple Comparisons

Problem: When many hypothesis tests are performed, the probability of at least one Type I error increases. For kkk independent tests each at α=0.05\alpha = 0.05α=0.05, the familywise error rate is 1−(0.95)k1 - (0.95)^k1−(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.010.010.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 α\alphaα by the number of tests. For mmm tests, reject H0H_0H0​ only if p≤α/mp \leq \alpha/mp≤α/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.

  • α\alphaα (Type I error probability) is the chance of concluding a difference exists when it does not.

  • β\betaβ (Type II error probability) is the chance of concluding no difference when one exists.

  • Power (1−β1-\beta1−β) is the chance of correctly detecting a real difference.

  • Sample size controls both α\alphaα and β\betaβ — investigators can balance errors by choosing an appropriate sample.

  • ppp-value is the probability of obtaining data as extreme as observed under H0H_0H0​ — 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.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent