Statistical Inference › Hypothesis Testing: Evaluating Claims

Michael BrenndoerferMay 10, 202513 min read
Machine Learning from ScratchAll chapters
Part 1 of 9Statistics 101
Chapter 10Statistical Inference › Hypothesis Testing: Evaluating Claims
Reading section 4 of 8 · Hypothesis Testing: Evaluating Claims · 13 minSection 4 of 8 · 13 min

Book contents

Section 4 of 8 · 13 min read

Statistical Inference › Hypothesis Testing: Evaluating ClaimsOne section · Sections in this chapter4 / 8 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

While estimation focuses on approximating parameter values, hypothesis testing evaluates specific claims or hypotheses about populations. This framework allows researchers to determine whether observed data provide sufficient evidence to reject a stated hypothesis, controlling error rates in a rigorous manner.

The Hypothesis Testing Framework

Hypothesis testing begins by formulating two competing hypotheses. The null hypothesis (H0H_0) represents a default position, skeptical claim, or status quo that we seek evidence against. The alternative hypothesis (H1H_1 or HaH_a) represents the research hypothesis or claim we wish to establish. For example, when testing whether a new teaching method improves test scores compared to the standard approach, the null hypothesis might state that the methods produce equal average scores, while the alternative claims the new method yields higher scores.

The logic of hypothesis testing follows a proof-by-contradiction structure. We assume the null hypothesis is true, then calculate how likely the observed data (or more extreme data) would be under this assumption. If the data would be highly unlikely under the null hypothesis, we have evidence to reject it in favor of the alternative. If the data are reasonably consistent with the null hypothesis, we fail to reject it, though importantly, this does not prove the null hypothesis true.

Test Statistics and P-values

A test statistic summarizes how far the sample data deviate from what the null hypothesis predicts, measured in standard error units. For testing a population mean, the t-statistic is commonly used:

t=xˉ−μ0s/nt = \frac{\bar{x} - \mu_0}{s / \sqrt{n}}

Where:

This statistic measures how many standard errors the sample mean lies from the hypothesized value. Large absolute values of the test statistic indicate data that would be unusual if the null hypothesis were true.

The p-value quantifies the strength of evidence against the null hypothesis. Formally, the p-value is the probability of observing a test statistic at least as extreme as the one calculated from the sample data, assuming the null hypothesis is true. A small p-value indicates that the observed data would be quite unlikely under the null hypothesis.

Common misinterpretations of p-values plague statistical practice. The p-value is not the probability that the null hypothesis is true (that probability is either 0 or 1, though unknown to us). Nor is one minus the p-value the probability that the alternative hypothesis is true. The p-value also does not measure the size or importance of an effect; even trivial differences can yield tiny p-values with sufficiently large samples. Rather, the p-value simply measures how compatible the data are with the null hypothesis.

Significance Levels and Decision Rules

The significance level α\alpha (alpha) sets a threshold for decision making. Common choices include α=0.05\alpha = 0.05 or α=0.01\alpha = 0.01. If the p-value falls below α\alpha, we reject the null hypothesis and declare the result "statistically significant." If the p-value exceeds α\alpha, we fail to reject the null hypothesis.

The significance level represents the maximum Type I error rate we are willing to tolerate. It should be chosen before conducting the test based on the consequences of different types of errors in the specific context, not after seeing the data. Conventions like α=0.05\alpha = 0.05 are merely defaults; situations with severe consequences for false positives might warrant more stringent levels like α=0.01\alpha = 0.01, while exploratory analyses might use α=0.10\alpha = 0.10.

Type I and Type II Errors

Hypothesis testing involves making decisions under uncertainty, which inevitably leads to the possibility of errors. A Type I error occurs when we reject a true null hypothesis, a "false positive" that claims an effect exists when it does not. The probability of a Type I error equals the significance level α\alpha, which we control directly by our choice of threshold.

A Type II error occurs when we fail to reject a false null hypothesis, a "false negative" that misses a real effect. The probability of a Type II error is denoted β\beta (beta) and depends on the true parameter value, sample size, and significance level. The power of a test, defined as 1−β1 - \beta, represents the probability of correctly rejecting a false null hypothesis. Higher power means the test is more likely to detect true effects when they exist.

These error types reflect a fundamental tradeoff. Making it harder to commit Type I errors (lowering α\alpha) simultaneously makes Type II errors more likely unless we increase sample size. The appropriate balance depends on the relative costs of each error type in context. Medical screening tests for serious diseases might prioritize avoiding Type II errors (missing true cases) even at the cost of more Type I errors (false alarms), while legal systems traditionally emphasize minimizing Type I errors (false convictions) accepting higher Type II error rates (wrongful acquittals).

Example: Decision Matrix for Hypothesis Testing

The following matrix shows the four possible outcomes in hypothesis testing, illustrating how Type I and Type II errors relate to the true state of the world and our test decision.

Out[3]:
Visualization
Matrix showing four outcomes in hypothesis testing with Type I and Type II errors.
Decision matrix showing the four possible outcomes in hypothesis testing. The rows represent the true state of reality (whether the null hypothesis is actually true or false), while the columns represent our test decision (whether we reject or fail to reject the null hypothesis). Correct decisions are shown in green (correctly failing to reject a true null hypothesis and correctly rejecting a false null hypothesis, which reflects statistical power). Errors are shown in red: Type I error (α) occurs when we incorrectly reject a true null hypothesis (false positive), while Type II error (β) occurs when we incorrectly fail to reject a false null hypothesis (false negative).
Hypothesis testing decision matrix presented as a native table for comparison with the illustration above.
RealityFail to Reject H0H_0Reject H0H_0
H0H_0 is trueCorrect decision — Probability: 1−α1-\alphaType I error — False positive; probability: α\alpha
H0H_0 is falseType II error — False negative; probability: β\betaCorrect decision — True positive; power: 1−β1-\beta

Example: Visualizing Hypothesis Testing Concepts

The following visualizations demonstrate the relationship between sampling distributions under the null and alternative hypotheses, showing how significance levels, test statistics, and power relate to each other.

The first plot shows the sampling distribution assuming the null hypothesis is true. When we conduct a hypothesis test, we calculate a test statistic from our sample data and compare it to the critical value (the vertical dashed line). If our test statistic falls in the rejection region (shaded in red), we reject the null hypothesis. The size of this rejection region corresponds to our chosen significance level α, which represents the probability of Type I error.rejecting a true null hypothesis.

The second plot is more complex and helps explain hypothesis testing. It shows two overlapping probability distributions representing two different states of reality:

  • Blue curve (Null hypothesis H0H_0): This represents the distribution of test statistics we would observe if the null hypothesis were true (no effect exists).
  • Green curve (Alternative hypothesis H1H_1): This represents the distribution of test statistics we would observe if the alternative hypothesis were true (an effect does exist).

The vertical dashed line represents our decision boundary.the critical value. Everything to the right of this line is the rejection region where we decide to reject H0H_0.

Understanding the shaded regions:

  • Red shaded area (under blue curve, right of critical value): This is Type I error probability (α = 0.05). It shows how often we would incorrectly reject a true null hypothesis. This area represents false positives.
  • Green shaded area (under green curve, right of critical value): This is statistical power (1 - β). It shows how often we would correctly reject the null hypothesis when the alternative is true. This represents true positives.successfully detecting a real effect.
  • Unshaded portion of green curve (left of critical value): This is Type II error probability (β). It shows how often we would fail to reject the null hypothesis when the alternative is true. This represents false negatives.missing a real effect.

The key insight is the tradeoff: if we move the critical value to the left (making it easier to reject H0H_0), we increase power but also increase Type I error. If we move it to the right (making it harder to reject H0H_0), we decrease Type I error but also decrease power (increase Type II error). The only way to improve both simultaneously is to increase the sample size, which makes both distributions narrower and more separated.

Out[4]:
Visualization
Plot showing sampling distribution under null hypothesis with rejection region.
Sampling distribution under the null hypothesis (H₀) with the rejection region shaded in red. The vertical dashed line marks the critical value corresponding to significance level α = 0.05. Test statistics that fall in the red shaded region lead to rejection of the null hypothesis. The area of this rejection region equals the Type I error probability (α = 0.05).
Plot comparing sampling distributions under null and alternative hypotheses showing error types.
Comparison of sampling distributions under the null hypothesis H₀ (blue curve) and alternative hypothesis H₁ (green curve). The red shaded area represents Type I error probability (α): the chance of rejecting H₀ when it is actually true. The green shaded area represents statistical power (1 - β): the probability of correctly rejecting H₀ when H₁ is true. The unshaded portion of the green distribution to the left of the critical value represents Type II error probability (β): the chance of failing to reject H₀ when H₁ is actually true. This visualization shows the fundamental tradeoff in hypothesis testing.moving the critical value affects both error rates simultaneously.