Module 07

Hypothesis Testing

Making decisions from data

Hypothesis Testing Framework

  • 01

    Null & Alternative

    Setting up hypotheses

  • 02

    p-value

    Probability of extreme results

  • 03

    Significance Level

    Decision threshold (α)

  • 04

    Errors

    Type I and Type II mistakes

01

Setting Up Hypotheses

The Null Hypothesis

H₀
"Nothing is happening"
The status quo. No effect. No difference.
Examples:
• The new drug has no effect
• The mean equals 100
• Groups are the same

H₀ (null hypothesis) claims there's no effect, no difference, or no relationship. It represents the skeptical position—assuming nothing interesting is happening until proven otherwise.

The Alternative Hypothesis

Hₐ
"Something is happening"
What you're trying to prove. The effect exists.
Examples:
• The new drug is effective
• The mean ≠ 100
• Groups are different

Hₐ (alternative hypothesis) is what you're trying to prove—that there IS an effect, difference, or relationship. This is usually the research hypothesis you care about.

One-Tailed vs Two-Tailed

Two-Tailed
Hₐ: μ ≠ 100
Effect in either direction
One-Tailed
Hₐ: μ > 100
Effect in one direction only

Two-tailed tests check for effects in EITHER direction (higher or lower). One-tailed tests only check ONE direction. Use two-tailed unless you have strong theoretical reason for one-tailed.

The Testing Logic

1
Assume H₀ is true
2
Calculate probability of observing our data (or more extreme)
3
If probability is very low, reject H₀
4
Conclude Hₐ is more likely

We can't prove H₀ or Hₐ directly. Instead, we assume H₀ is true, then ask: 'How unlikely is our observed data?' If very unlikely under H₀, we reject H₀ in favor of Hₐ.

02

The p-value

Interactive p-Value Simulator

Hypothesis Testing Simulator
0.5
30
H₀: μ = 0    H₁: μ ≠ 0
Sample Mean-
t-statistic-
p-value-
Click "Run Test" to simulate

Run your own hypothesis test simulation! Set a sample size and hypothesized mean (H₀), then click 'Run Simulation' to generate random data and calculate the t-statistic and p-value. Run it multiple times to see how p-values vary across samples. Notice how larger sample sizes tend to produce more consistent results.

What is a p-value?

observedp
p = P(data this extreme | H₀ true)

The p-value is the probability of observing data as extreme (or more extreme) than what we got, IF H₀ is true. A small p-value means our data is unlikely under H₀.

Reading p-values

p < 0.01
Strong evidence against H₀
p < 0.05
Moderate evidence against H₀
p < 0.10
Weak evidence against H₀
p ≥ 0.10
Little to no evidence against H₀

Smaller p-values = stronger evidence against H₀. But p-values are continuous—don't treat 0.049 and 0.051 as fundamentally different. Consider the actual value, not just whether it crosses a threshold.

What p-value is NOT

Common Misinterpretations
✗
"Probability that H₀ is true"
p is about data, not hypotheses
✗
"Probability results are due to chance"
Results are what they are; p measures surprise
✗
"Effect size indicator"
Small p ≠ large effect (could be large n)

p-value is NOT the probability H₀ is true. It's the probability of our data IF H₀ were true. Also, p doesn't measure effect size—a tiny effect can have p < 0.001 with large enough n.

Where p Comes From

1
Calculate test statistic (t, z, χ², F)
2
Find its theoretical distribution under H₀
3
p = area in tail(s) beyond test statistic

We convert our data to a test statistic, then find how much of the theoretical distribution lies beyond that value. This tail area is the p-value—probability of being that extreme or more.

03

Significance Level (α)

The Decision Threshold

α = 0.05
Significance level
→
If p < α: Reject H₀
If p ≥ α: Fail to reject H₀

α (alpha) is the threshold you set BEFORE the test. If p < α, you reject H₀. If p ≥ α, you fail to reject H₀. Common values: 0.05 (5%), 0.01 (1%), 0.10 (10%).

Choosing Alpha

αWhen to UseField
0.10Exploratory researchSocial science
0.05Standard thresholdMost fields
0.01Higher stakesMedicine
0.005New proposed standardPsychology

α = 0.05 is conventional but arbitrary. Some argue it's too lenient (contributing to replication crisis). Consider the stakes: medical decisions might warrant α = 0.01 or lower.

Statistical Significance

p < α
"Statistically Significant"
Reject H₀
Evidence supports Hₐ
p ≥ α
"Not Significant"
Fail to reject H₀
Insufficient evidence

If p < α, we say the result is 'statistically significant'—unlikely to occur by chance if H₀ is true. But 'significant' doesn't mean 'important' or 'large effect'—just unlikely under H₀.

Proper Conclusions

✓ Correct Language
"We reject H₀"
"We fail to reject H₀"
"The data provide sufficient evidence to..."
✗ Incorrect Language
"We accept H₀" (can't prove null)
"We prove Hₐ" (can't prove anything)
"H₀ is true" (we only assess evidence)

Never say 'accept H₀' or 'prove' anything. We can only reject H₀ or fail to reject it. Failing to reject doesn't mean H₀ is true—we just don't have enough evidence against it.

04

Type I & Type II Errors

Two Types of Mistakes

H₀ TrueH₀ False
Reject H₀Type I Error
False Positive
P = α
Correct!
True Positive
P = 1-β (Power)
Fail to RejectCorrect!
True Negative
P = 1-α
Type II Error
False Negative
P = β

Type I: Rejecting H₀ when it's actually true (false alarm). Type II: Failing to reject H₀ when it's actually false (missed detection). Both are mistakes with real consequences.

False Positive (Type I)

Type I Error (α)
"False Alarm" - Seeing something that isn't there
Reality: Drug has no effect
Conclusion: "Drug works!" (Wrong!)

Consequence: Patients get ineffective treatment
Probability: α (e.g., 5%)

Type I error is a 'false positive'—claiming an effect exists when it doesn't. Setting α = 0.05 means you accept a 5% chance of making this error when H₀ is true.

False Negative (Type II)

Type II Error (β)
"Missed Detection" - Missing something real
Reality: Drug actually works
Conclusion: "No effect found" (Wrong!)

Consequence: Effective drug not approved
Probability: β (often 10-20%)

Type II error is a 'false negative'—failing to detect a real effect. This happens when sample size is too small or effect is subtle. β = P(Type II), and Power = 1 - β.

The Error Tradeoff

Type I (α)Type II (β)Strictness of α →
Reducing one error type increases the other (with fixed n)

Type I and Type II errors trade off: lowering α (stricter) reduces false positives but increases false negatives. The only way to reduce BOTH is to increase sample size.

★

Real-World Examples

Apply your knowledge to practical scenarios

01

The New Drug Dilemma

A pharmaceutical company tests a new heart medication. They set α = 0.05 and conduct the trial. The result: p = 0.048. The FDA must decide whether to approve the drug.

Q What does p = 0.048 actually mean? +
A IF the drug truly has no effect (H₀ true), there's a 4.8% probability of observing results this extreme or more extreme by chance alone.
Q Can the company claim the drug is 'proven effective'? +
A No! p = 0.048 means we reject H₀, but it doesn't 'prove' effectiveness. There's still a 4.8% chance this is a false positive. And p-value says nothing about effect SIZE.
Q The company then runs 20 similar trials for different drugs (all actually ineffective). How many would show p < 0.05 by chance? +
A About 1 out of 20 (5%). This is exactly the Type I error rate! Multiple testing without correction leads to false positives.
Q How should the FDA evaluate this result? +
A Consider effect size (is the benefit clinically meaningful?), replication (have other studies confirmed it?), mechanism (biological plausibility), and confidence intervals. p-value alone isn't enough.
Key Insights
  • p < 0.05 is not 'proof'—it's evidence against H₀ assuming a 5% false positive tolerance
  • Multiple testing inflates false positive rate dramatically
  • FDA requires replication and clinical significance, not just statistical significance
02

Type I and Type II Errors in Court

The criminal justice system parallels hypothesis testing. H₀: Defendant is innocent. Hₐ: Defendant is guilty. 'Beyond reasonable doubt' is like setting α very low.

Q What is a Type I error in this context? +
A Convicting an innocent person (false positive). Rejecting H₀ (innocence) when it's actually true.
Q What is a Type II error in this context? +
A Acquitting a guilty person (false negative). Failing to reject H₀ (innocence) when the person is actually guilty.
Q Why does the system prefer 'better to let 10 guilty go free than convict 1 innocent'? +
A This reflects setting α very low—we'd rather increase Type II errors (guilty go free) than Type I errors (innocent convicted). Society values protecting the innocent.
Q How would increasing the evidence requirement affect both error types? +
A Stricter evidence (lower α) → fewer false convictions (Type I ↓) but more guilty people acquitted (Type II ↑). You can't reduce both without 'more data' (better investigation).
Key Insights
  • Type I and Type II errors have real-world consequences
  • Society implicitly sets α based on which error is more costly
  • The only way to reduce BOTH errors is better evidence (larger sample/better data)
03

COVID Test Interpretation

A COVID rapid test has 95% sensitivity (true positive rate) and 99% specificity (true negative rate). In a population where 1% actually have COVID, you test positive. What's the probability you actually have COVID?

Q Intuitively, do you think a positive test means you probably have COVID? +
A Most people assume yes—but the answer might surprise you. This involves conditional probability and base rates.
Q In a population of 10,000 with 1% prevalence, how many positive tests would we expect? +
A True positives: 100 × 0.95 = 95. False positives: 9,900 × 0.01 = 99. Total positives: 194. Only 95/194 ≈ 49% of positive tests are true positives!
Q Why is your probability of having COVID only ~49% despite a 'highly accurate' test? +
A Base rate fallacy! When the condition is rare (1%), even rare false positives (1%) outnumber true positives. The test accuracy sounds high, but context (prevalence) matters enormously.
Q How does this relate to p-values and hypothesis testing? +
A p-value is P(data | H₀ true), not P(H₀ true | data). Similarly, sensitivity is P(positive | have COVID), not P(have COVID | positive). These are NOT the same!
Key Insights
  • P(A|B) ≠ P(B|A) — the direction of conditioning matters enormously
  • Base rates (prevalence) dramatically affect interpretation
  • p-value tells you about the data assuming H₀, NOT about H₀ given the data
?

Hypothesis Testing Quiz

Test your understanding • Passing score: 70%

0 of 10 answered
Q1 multiple-choice

What does the null hypothesis (H₀) typically represent?

Explanation: H₀ represents the null position: no effect, no difference, nothing special happening. It's the skeptical baseline that we try to disprove with evidence.
Q2 multiple-choice

A p-value of 0.03 means:

Explanation: p-value = P(data this extreme | H₀ true). It's NOT the probability that H₀ is true. It tells us how 'surprising' our data is under the assumption that H₀ is true.
Q3 multiple-choice

If α = 0.05 and p = 0.06, what is the correct conclusion?

Explanation: Since p (0.06) > α (0.05), we fail to reject H₀. We don't have sufficient evidence at the 5% level. Note: we never 'accept' H₀—we only fail to reject it.
Q4 multiple-choice

A Type I error occurs when:

Explanation: Type I error = false positive = rejecting H₀ when it's actually true. We conclude there's an effect when there isn't. The probability of this error equals α.
Q5 multiple-choice

A medical test finds p < 0.001. The researcher concludes 'the treatment effect is very large.' Is this correct?

Explanation: p-value does NOT indicate effect size. A tiny effect can have p < 0.001 with a large enough sample. You need effect size measures (Cohen's d, etc.) to assess magnitude.
Q6 multiple-choice

Why is 'accepting H₀' considered incorrect language?

Explanation: Absence of evidence isn't evidence of absence. Failing to reject H₀ means we lack sufficient evidence to reject it—not that it's proven true. The effect might exist but be too small to detect.
Q7 multiple-choice

A study with α = 0.05 is replicated 100 times. If H₀ is true in all cases, how many would show 'significant' results by chance?

Explanation: If H₀ is true, we'd expect 5% of tests to falsely reject it (Type I error rate = α = 0.05). So 5 out of 100 tests would show 'significant' results purely by chance.
Q8 multiple-choice

A researcher sets α = 0.01 instead of α = 0.05. What happens to Type I and Type II error rates?

Explanation: Lowering α (stricter) reduces Type I errors (fewer false positives) but increases Type II errors (more false negatives). It's a tradeoff—you can only reduce both by increasing sample size.
Q9 multiple-choice

What is the significance level (α)?

Explanation: α is the significance level—the threshold you set BEFORE the test. If p < α, you reject H₀. Common choices are 0.05, 0.01, and 0.10. It's your tolerance for Type I error.
Q10 multiple-choice

In a one-tailed test with Hₐ: μ > 100, you observe x̄ = 95. What happens?

Explanation: In a one-tailed test predicting μ > 100, finding x̄ = 95 (less than 100) provides no evidence for Hₐ. You cannot reject H₀ regardless of the p-value—the result is in the wrong tail.

Quiz Results

0 %

← Confidence Intervals Next: Effect Sizes & Power →