Here are your complete, easy notes on Hypothesis Testing for Non-Parametric Tests:
📊 Non-Parametric Hypothesis Testing - Complete Notes
1. What Are Non-Parametric Tests?
Non-parametric tests are statistical tests that do NOT assume a specific distribution (like normality) for the data. They work on ranks instead of actual values.
When to Use Non-Parametric Tests?
| Use When... | Example |
|---|
| Data is NOT normally distributed | Skewed income data |
| Small sample size (n < 30) | Pilot studies |
| Data is ordinal (ranked categories) | Likert scale (1-5) |
| Outliers are present | Extreme values in dataset |
| Comparing medians, not means | Non-symmetric distributions |
Parametric vs Non-Parametric - Quick Comparison
| Parametric Test | Non-Parametric Equivalent | Use Case |
|---|
| One-sample t-test | Wilcoxon Signed-Rank | 1 group vs. known value |
| Paired t-test | Wilcoxon Signed-Rank | 2 matched/paired groups |
| Independent t-test | Mann-Whitney U Test | 2 independent groups |
| One-way ANOVA | Kruskal-Wallis Test | 3+ independent groups |
| Repeated Measures ANOVA | Friedman Test | 3+ matched/repeated groups |
| Pearson Correlation | Spearman's Rank Correlation | Association between 2 variables |
| Chi-square (expected) | Chi-square (non-param version) | Categorical data |
2. Sign Test
The simplest non-parametric test. Tests whether the median of a population equals a specific value.
How It Works
- Replace each value with + (above median) or - (below median)
- Count number of positives and negatives
- Use binomial distribution to test
Hypotheses
- H₀: Median = M₀ (no difference)
- H₁: Median ≠ M₀ (two-tailed) OR Median > M₀ / Median < M₀ (one-tailed)
Example
A company claims median salary = ₹50,000. Sample of 10 employees: 45, 55, 62, 48, 70, 53, 41, 60, 49, 58
Step 1: Compare each to M₀ = 50,000
| Value | Sign |
|---|
| 45,000 | - |
| 55,000 | + |
| 62,000 | + |
| 48,000 | - |
| 70,000 | + |
| 53,000 | + |
| 41,000 | - |
| 60,000 | + |
| 49,000 | - |
| 58,000 | + |
Step 2: Count: Positives (S⁺) = 6, Negatives (S⁻) = 4, n = 10
Step 3: Test statistic = min(6, 4) = 4
Step 4: At α = 0.05, n = 10 → Critical value = 1 (from Sign Test table)
Step 5: Since 4 > 1, Fail to Reject H₀. No evidence median ≠ 50,000.
3. Wilcoxon Signed-Rank Test
More powerful than the Sign Test. Used for one sample or paired samples. It considers both the direction AND magnitude of differences.
When to Use
- Testing one sample against a known median
- Comparing two related/paired groups (before-after data)
Hypotheses (Paired)
- H₀: Median difference = 0
- H₁: Median difference ≠ 0
Steps
- Calculate the difference (d = X₁ - X₂) for each pair
- Drop zero differences
- Rank the absolute values of differences (smallest = rank 1)
- Assign the sign (+/-) back to each rank
- Calculate W⁺ (sum of positive ranks) and W⁻ (sum of negative ranks)
- Test statistic W = min(W⁺, W⁻)
- Compare W to critical value from Wilcoxon table
Example
Before and after blood pressure readings for 8 patients:
| Patient | Before | After | d = B-A | |d| | Rank | Signed Rank |
|---|---|---|---|---|---|---|
| 1 | 120 | 115 | +5 | 5 | 4 | +4 |
| 2 | 135 | 130 | +5 | 5 | 4 | +4 |
| 3 | 125 | 128 | -3 | 3 | 2 | -2 |
| 4 | 140 | 132 | +8 | 8 | 6 | +6 |
| 5 | 118 | 125 | -7 | 7 | 5 | -5 |
| 6 | 130 | 120 | +10 | 10 | 7 | +7 |
| 7 | 122 | 120 | +2 | 2 | 1 | +1 |
| 8 | 145 | 133 | +12 | 12 | 8 | +8 |
Note: Ties (ranks 4 and 4 for patients 1 and 2) are averaged.
W⁺ = 4 + 4 + 6 + 7 + 1 + 8 = 30
W⁻ = 2 + 5 = 7
W = min(30, 7) = 7
At α = 0.05, n = 8 → Critical value = 4
Since 7 > 4, Fail to Reject H₀. Blood pressure did not significantly change.
4. Mann-Whitney U Test
Non-parametric equivalent of the independent samples t-test. Compares two independent groups.
Hypotheses
- H₀: The two populations have identical distributions (same median)
- H₁: The distributions differ (medians differ)
Steps
- Combine all values from both groups and rank them (1 = smallest)
- Sum the ranks for each group: R₁ and R₂
- Calculate U statistics:
- U₁ = n₁·n₂ + n₁(n₁+1)/2 − R₁
- U₂ = n₁·n₂ + n₂(n₂+1)/2 − R₂
- (Or simply: U₂ = n₁·n₂ − U₁)
- Test statistic: U = min(U₁, U₂)
- Compare to critical value (or compute Z for large samples)
Example
Two teaching methods tested on students. Method A scores: 78, 82, 65, 91, 73. Method B scores: 88, 76, 95, 84, 69
Step 1: Combine and rank all 10 values:
| Value | Group | Rank |
|---|
| 65 | A | 1 |
| 69 | B | 2 |
| 73 | A | 3 |
| 76 | B | 4 |
| 78 | A | 5 |
| 82 | A | 6 |
| 84 | B | 7 |
| 88 | B | 8 |
| 91 | A | 9 |
| 95 | B | 10 |
Step 2: Sum ranks:
- R₁ (Group A) = 1 + 3 + 5 + 6 + 9 = 24
- R₂ (Group B) = 2 + 4 + 7 + 8 + 10 = 31
Step 3: Calculate U:
- U₁ = (5×5) + 5×6/2 − 24 = 25 + 15 − 24 = 16
- U₂ = (5×5) + 5×6/2 − 31 = 25 + 15 − 31 = 9
Step 4: U = min(16, 9) = 9
Step 5: At α = 0.05, n₁ = 5, n₂ = 5 → Critical value = 2
Since 9 > 2, Fail to Reject H₀. No significant difference between the two methods.
For large samples (n > 20): Use Z = (U − n₁n₂/2) / √(n₁n₂(n₁+n₂+1)/12)
5. Kruskal-Wallis Test
Non-parametric alternative to one-way ANOVA. Compares 3 or more independent groups.
Hypotheses
- H₀: All k groups have the same population distribution (medians equal)
- H₁: At least one group has a different median
Steps
- Combine all observations and assign ranks (1 = smallest)
- Sum ranks for each group: R₁, R₂, ..., Rₖ
- Calculate H statistic:
$$H = \frac{12}{N(N+1)} \sum_{i=1}^{k} \frac{R_i^2}{n_i} - 3(N+1)$$
- Compare H to Chi-square critical value with df = k − 1
Example
Three diet plans tested on weight loss (kg):
- Diet A: 3, 5, 4, 6
- Diet B: 7, 9, 6, 8
- Diet C: 2, 4, 1, 3
Step 1: Combine and rank all 12 values:
| Value | Group | Rank |
|---|
| 1 | C | 1 |
| 2 | C | 2 |
| 3 | A | 3.5 |
| 3 | C | 3.5 |
| 4 | A | 5.5 |
| 4 | C | 5.5 |
| 5 | A | 7 |
| 6 | A | 8.5 |
| 6 | B | 8.5 |
| 7 | B | 10 |
| 8 | B | 11 |
| 9 | B | 12 |
(Tied values get average ranks)
Step 2: Sum of ranks per group:
- R_A = 3.5 + 5.5 + 7 + 8.5 = 24.5
- R_B = 8.5 + 10 + 11 + 12 = 41.5
- R_C = 1 + 2 + 3.5 + 5.5 = 12
Step 3: N = 12, n_A = n_B = n_C = 4
H = [12/(12×13)] × [(24.5²/4) + (41.5²/4) + (12²/4)] − 3×13
H = [12/156] × [150.0625 + 430.5625 + 36] − 39
H = 0.0769 × 616.625 − 39
H = 47.37 − 39 = 8.37
Step 4: df = k − 1 = 2, χ² critical at α = 0.05 = 5.991
Since H = 8.37 > 5.991, Reject H₀. At least one diet produces significantly different weight loss.
Post-hoc: After rejection, use Dunn's test (pairwise comparisons) to find which groups differ.
6. Friedman Test
Non-parametric equivalent of Repeated Measures ANOVA. Used when the same subjects are measured under 3+ conditions.
Hypotheses
- H₀: All treatment conditions have the same distribution
- H₁: At least one condition differs
Steps
- Arrange data with rows = subjects, columns = treatments
- Rank values within each row (1 = smallest in that row)
- Sum ranks for each treatment column: R_j
- Calculate Friedman statistic:
$$\chi^2_r = \frac{12}{nk(k+1)} \sum_{j=1}^{k} R_j^2 - 3n(k+1)$$
- Compare to χ² critical value with df = k − 1
Example
4 students rated 3 teaching methods (scores out of 10):
| Student | Method 1 | Method 2 | Method 3 |
|---|
| 1 | 7 | 9 | 5 |
| 2 | 8 | 6 | 4 |
| 3 | 5 | 7 | 6 |
| 4 | 9 | 8 | 7 |
Step 1: Rank within each row:
| Student | M1 Rank | M2 Rank | M3 Rank |
|---|
| 1 | 2 | 3 | 1 |
| 2 | 3 | 2 | 1 |
| 3 | 1 | 3 | 2 |
| 4 | 3 | 2 | 1 |
| Sum (Rj) | 9 | 10 | 5 |
Step 2: n = 4, k = 3
χ²r = [12/(4×3×4)] × (9² + 10² + 5²) − 3×4×4
χ²r = [12/48] × (81 + 100 + 25) − 48
χ²r = 0.25 × 206 − 48
χ²r = 51.5 − 48 = 3.5
Step 3: df = k − 1 = 2, χ² critical at α = 0.05 = 5.991
Since 3.5 < 5.991, Fail to Reject H₀. No significant difference between teaching methods.
7. Spearman's Rank Correlation
Non-parametric version of Pearson's correlation. Measures the strength of a monotonic relationship between two ranked variables.
Formula
$$r_s = 1 - \frac{6 \sum d_i^2}{n(n^2-1)}$$
where d = difference between ranks of paired observations.
Hypotheses
- H₀: No correlation (ρ = 0)
- H₁: Correlation exists (ρ ≠ 0)
Example
Rank students by Math (X) and English (Y) scores:
| Student | Math | English | Rank X | Rank Y | d = Rx - Ry | d² |
|---|
| A | 85 | 78 | 1 | 2 | -1 | 1 |
| B | 78 | 82 | 3 | 1 | 2 | 4 |
| C | 90 | 74 | 2 (wait: 90 is highest) | 4 | ... | ... |
Let me redo with proper ranks (1 = highest):
| Student | Math | English | Rank X | Rank Y | d | d² |
|---|
| A | 90 | 85 | 1 | 2 | -1 | 1 |
| B | 85 | 88 | 2 | 1 | 1 | 1 |
| C | 75 | 70 | 3 | 4 | -1 | 1 |
| D | 70 | 72 | 4 | 3 | 1 | 1 |
| E | 60 | 65 | 5 | 5 | 0 | 0 |
Σd² = 4
rₛ = 1 − [6×4] / [5×(25−1)]
rₛ = 1 − 24/120 = 1 − 0.2 = 0.8
Interpretation: rₛ = 0.8 → Strong positive correlation between Math and English performance.
Critical value test: For n = 5, α = 0.05 → Critical value ≈ 0.9 → Since 0.8 < 0.9, Fail to Reject H₀ (but practically, the correlation is strong).
8. Chi-Square Test (χ²) for Independence
Tests whether two categorical variables are independent or associated.
Hypotheses
- H₀: The two variables are independent
- H₁: The two variables are associated
Formula
$$\chi^2 = \sum \frac{(O - E)^2}{E}$$
- O = Observed frequency
- E = Expected frequency = (Row Total × Column Total) / Grand Total
Example
Is there a relationship between gender and preference for a product?
| Prefer A | Prefer B | Total |
|---|
| Male | 30 | 20 | 50 |
| Female | 15 | 35 | 50 |
| Total | 45 | 55 | 100 |
Expected frequencies:
- E(Male, A) = 50×45/100 = 22.5
- E(Male, B) = 50×55/100 = 27.5
- E(Female, A) = 50×45/100 = 22.5
- E(Female, B) = 50×55/100 = 27.5
χ² calculation:
χ² = (30-22.5)²/22.5 + (20-27.5)²/27.5 + (15-22.5)²/22.5 + (35-27.5)²/27.5
χ² = 56.25/22.5 + 56.25/27.5 + 56.25/22.5 + 56.25/27.5
χ² = 2.5 + 2.045 + 2.5 + 2.045 = 9.09
df = (rows−1)(cols−1) = 1×1 = 1
Critical value at α = 0.05, df = 1 = 3.841
Since 9.09 > 3.841, Reject H₀. Gender and product preference are NOT independent (they are associated).
9. Summary - Decision Rules
| W (Wilcoxon) or U (Mann-Whitney) or H (Kruskal-Wallis) or χ² | Decision |
|---|
| Test statistic > Critical value (for H, χ²) | Reject H₀ |
| Test statistic < Critical value (for W, U) | Reject H₀ |
| p-value < α | Reject H₀ |
| p-value > α | Fail to Reject H₀ |
10. Advantages and Disadvantages
Advantages ✅
- No normality assumption needed
- Work with small samples
- Handle ordinal data and outliers well
- Simpler to compute by hand
Disadvantages ❌
- Less powerful than parametric tests when data IS normal
- Cannot estimate parameters like mean differences directly
- Fewer options for complex designs (interactions, covariates)
11. Quick Reference - Which Test to Use?
How many groups?
│
├─ 1 group
│ └─ vs. known value → Sign Test / Wilcoxon Signed-Rank
│
├─ 2 groups
│ ├─ Independent → Mann-Whitney U Test
│ └─ Paired / Matched → Wilcoxon Signed-Rank Test
│
└─ 3+ groups
├─ Independent → Kruskal-Wallis Test
│ └─ Post-hoc → Dunn's Test
└─ Repeated measures (same subjects) → Friedman Test
Categorical data (frequency tables) → Chi-Square Test
Association between two variables → Spearman's Rank Correlation
These notes cover all major non-parametric tests with step-by-step worked examples. The key to mastering these is practicing the ranking step - once you get the ranks right, the rest follows from plugging into formulas.