Hypothesis testing is a powerful statistical tool used across science, business, and data analytics to decide whether observed results are significant or due to random chance.
This comprehensive guide covers:
- Hypotheses and Errors
- Significance, p-value, and critical value
- Z-test, t-test, Chi-square test, and ANOVA
- When to use which test
- Formulas and Examples
1. Understanding Hypothesis Testing
- Null Hypothesis (H₀): The assumption of no effect or no difference.
- Alternative Hypothesis (H₁): The claim that contradicts H₀.
Steps:
- Set H₀ and H₁
- Choose significance level α (commonly 0.05)
- Calculate test statistic
- Determine critical value or p-value
- Make a decision: Reject or fail to reject H₀
2. Errors in Hypothesis Testing
Outcome | H₀ is True | H₀ is False |
---|---|---|
Reject H₀ | Type I Error (α) | Correct Decision |
Fail to Reject H₀ | Correct Decision | Type II Error (β) |
- Type I Error (α): False positive — rejecting a true H₀
- Type II Error (β): False negative — failing to reject a false H₀
3. p-value vs. Critical Value
- p-value: The probability of getting a result as extreme as the observed one under H₀
- Critical value: The boundary that separates the acceptance and rejection regions
Decision Rules:
- p-value method: Reject H₀ if p-value < α
- Critical value method: Reject H₀ if test statistic exceeds the critical value
4. Statistical Tests with Formulas
Let’s go over the most used hypothesis tests with simple examples:
1. Z-Test
Used when:
- Population standard deviation is known
- Sample size ≥ 30
Example:
A company claims the average weight of their cereal boxes is 500g. A sample of 36 boxes has a mean of 495g, and population standard deviation is 15g. Is this significant?
- H₀: μ = 500
- H₁: μ ≠ 500
- α = 0.05
Test statistic (Z):
Z = (495 – 500) / (15 / √36) = -5 / 2.5 = -2.0
Critical value: ±1.96 for two-tailed test at 5%
Since |Z| = 2.0 > 1.96 → Reject H₀
2. t-Test
Used when:
- Population standard deviation is unknown
- Small sample size (n < 30)
Example:
A teacher wants to test if students’ average score differs from 75. A sample of 10 students has a mean of 72 and sample standard deviation of 5.
- H₀: μ = 75
- H₁: μ ≠ 75
- α = 0.05
- df = 9
t = (72 – 75) / (5 / √10) = -3 / 1.58 = -1.90
From t-table, critical value ≈ ±2.262 (two-tailed, df=9)
Since |t| = 1.90 < 2.262 → Fail to reject H₀
3. Chi-Square Test
Used when:
- Data is categorical
- Testing independence or goodness-of-fit
Example:
Is gender independent of product preference?
Likes | Dislikes | Total | |
---|---|---|---|
Male | 30 | 10 | 40 |
Female | 20 | 20 | 40 |
Total | 50 | 30 | 80 |
Calculate expected counts:
E₁₁ = (40×50)/80 = 25, E₁₂ = (40×30)/80 = 15, etc.
Chi-square = Σ [(O – E)² / E]
If χ² > critical value from χ² table (df = 1, α = 0.05 → 3.84), then reject H₀.
Suppose χ² = 5.0 → 5.0 > 3.84 → Reject H₀
4. ANOVA (Analysis of Variance)
Used when:
- Comparing means of more than two groups
Example:
Three teaching methods are tested with student scores:
- Group A: 85, 90, 88
- Group B: 78, 74, 77
- Group C: 92, 95, 91
H₀: μA = μB = μC
H₁: At least one μ differs
Calculate F-statistic = Between group variance / Within group variance
Suppose F = 6.5
Compare with critical F from F-table (df₁ = 2, df₂ = 6 at α = 0.05 → critical F ≈ 5.14)
Since F = 6.5 > 5.14 → Reject H₀
5. When to Use Which Test?
Test | Data Type | Use Case | Assumptions |
---|---|---|---|
Z-Test | Continuous | Mean vs. known population mean | Known σ, large sample (n ≥ 30) |
t-Test | Continuous | Mean comparison, small sample | Unknown σ, normality |
Chi-Square | Categorical | Test of independence or fit | Expected freq ≥ 5 |
ANOVA | Continuous | Compare 3+ group means | Normality, equal variance |
Final Words
Hypothesis testing empowers you to test assumptions with evidence, not intuition. Whether you’re working with averages or categories, small samples or large ones, selecting the right test and interpreting it using formulas, critical values, and p-values ensures your conclusions are statistically sound.