STA215 Statistics II

Statistics IIUnit 410 min read

Non-parametric Tests & Hypothesis Testing: Methods, Assumptions & Applications

Unit 4 of Statistics II covers non-parametric tests (e.g., Mann-Whitney U, Kruskal-Wallis, Wilcoxon) and hypothesis testing frameworks, emphasizing when to use them over parametric alternatives, test procedures, and real-world applications in CS/IT (e.g., software efficiency, user surveys, hardware reliability).

Core Concepts

1. Non-parametric Tests: Overview and When to Use

Non-parametric tests are distribution-free statistical methods used when:

  • Data violates parametric test assumptions (e.g., normality, homogeneity of variance).
  • Data is ordinal or nominal (not continuous).
  • Sample size is small (<30).

Key Differences: Parametric vs. Non-parametric

Feature Parametric Tests Non-parametric Tests
Data Type Continuous, normally distributed Ordinal, nominal, or non-normal data
Assumptions Strict (normality, equal variance) Minimal (only rank-based)
Power Higher (if assumptions met) Lower (but robust to violations)
Examples t-test, ANOVA Mann-Whitney U, Kruskal-Wallis

Common Non-parametric Tests

Test Purpose Parametric Counterpart
Mann-Whitney U Compare 2 independent samples Independent t-test
Wilcoxon Signed-Rank Compare paired samples Paired t-test
Kruskal-Wallis Compare >2 independent samples One-way ANOVA
Friedman Compare paired samples (>2 groups) Repeated-measures ANOVA
Spearman’s Rho Measure ordinal correlation Pearson’s r
Chi-Square (χ²) Test categorical associations N/A (for contingency tables)

2. Hypothesis Testing Framework

Steps for Any Hypothesis Test

  1. State Hypotheses:
    • Null Hypothesis (H₀): Default assumption (e.g., "no effect").
    • Alternative Hypothesis (H₁/Hₐ): Research claim (e.g., "there is a difference").
  2. Choose Significance Level (α): Typically 0.05 or 0.01.
  3. Select Test Statistic: Depends on data type (e.g., U-statistic for Mann-Whitney).
  4. Calculate Test Statistic: From sample data.
  5. Determine Critical Value/ p-value:
    • Compare test statistic to critical value (from tables).
    • Or compare p-value to α.
  6. Make Decision:
    • Reject H₀ if p ≤ α (significant result).
    • Fail to reject H₀ otherwise.

Example: Mann-Whitney U Test

Scenario: Compare IT knowledge scores (ordinal data) between two groups of workers. Data:

  • Group A (n₁=5): 5, 8, 2, 7, 6
  • Group B (n₂=4): 9, 12, 4, 6

Steps:

  1. Rank all data together (ties get average rank):
    Value | Group | Rank
    ---------------------
    2     | A     | 1
    4     | B     | 2
    5     | A     | 3
    6     | A/B   | 4.5 (tie)
    6     | A/B   | 4.5
    7     | A     | 6
    8     | A     | 7
    9     | B     | 8
    12    | B     | 9
    
  2. Sum ranks for each group:
    • R₁ (Group A) = 1 + 3 + 4.5 + 6 + 7 = 21.5
    • R₂ (Group B) = 2 + 4.5 + 8 + 9 = 23.5
  3. Calculate U-statistic:
    • Use .
  4. Compare to critical value:
    • For α=0.05, two-tailed, (from Mann-Whitney table for n₁=5, n₂=4).
    • Since 8.5 > 2, fail to reject H₀ (no significant difference).

3. Chi-Square Tests for Categorical Data

Chi-Square Goodness-of-Fit Test

Tests if observed frequencies match expected frequencies. Example: Test if email hacking status is independent of email type. Data:

Type Hacked (Yes) Not Hacked (No) Total
Yahoo 60 40 100
Gmail 30 70 100
Total 90 110 200

Steps:

  1. State H₀: Hacking status is independent of email type.
  2. Calculate expected frequencies:
    • (Yahoo/Yes).
  3. Compute χ²:
  4. Critical value: For df = (rows-1)(cols-1) = 1, α=0.05 → χ²₀.₀₅ = 3.841.
    • Since 13.33 > 3.841, reject H₀ (dependence exists).

Chi-Square Test of Independence

Same as above but for association between two categorical variables.


4. Applications in CS/IT

Scenario Test Used Example
Compare software efficiency across 3 algorithms Kruskal-Wallis Test if algorithm A > B > C in processing time.
Check if user satisfaction (Likert scale) differs by OS Mann-Whitney U Compare Windows vs. Linux users.
Test if hardware failure rates vary by brand Chi-Square Compare Dell, HP, Lenovo failure data.
Analyze survey responses (nominal data) Chi-Square Test if education level affects IT adoption.

5. Advantages and Limitations

Advantages of Non-parametric Tests

  • Robustness: Work with non-normal data.
  • Flexibility: Handle ordinal/nominal data.
  • Simplicity: Fewer assumptions than parametric tests.

Limitations

  • Lower power: Harder to detect true effects.
  • Less precise: Provide ranks, not exact values.
  • Tie sensitivity: Affects Mann-Whitney/Kruskal-Wallis results.

When to Use Which Test

Situation Recommended Test
2 independent groups, ordinal data Mann-Whitney U
2 paired groups, ordinal data Wilcoxon Signed-Rank
>2 independent groups, ordinal data Kruskal-Wallis
>2 paired groups, ordinal data Friedman
Categorical association Chi-Square
Small samples, unknown distribution Non-parametric

6. Worked Example: Kruskal-Wallis Test

Scenario: A manufacturer tests 3 catalysts (C1, C2, C3) for alcohol distillation. Data (cc):

  • C1: 380, 430, 410
  • C2: 290, 350, 270, 250, 270
  • C3: 400, 380, 450

Steps:

  1. Rank all data (n=11):
    Value | Group | Rank
    ------------------------
    250   | C2    | 1
    270   | C2    | 2.5 (tie)
    270   | C2    | 2.5
    290   | C2    | 4
    350   | C2    | 5
    380   | C1    | 6.5
    380   | C3    | 6.5
    400   | C3    | 8
    410   | C1    | 9
    430   | C1    | 10
    450   | C3    | 11
    
  2. Sum ranks per group:
    • R₁ (C1) = 6.5 + 9 + 10 = 25.5
    • R₂ (C2) = 1 + 2.5 + 2.5 + 4 + 5 = 15
    • R₃ (C3) = 6.5 + 8 + 11 = 25.5
  3. Calculate H-statistic: Where , = group sizes (3, 5, 3).
  4. Critical value: For df = 3-1 = 2, α=0.05 → χ²₀.₀₅ = 5.991.
    • Since 7.05 > 5.991, reject H₀ (significant differences exist).

Exam Tip

What Examiners Look For

  1. Correct Test Selection:

    • Always justify why a non-parametric test is appropriate (e.g., "data is ordinal" or "normality violated").
    • Common mistakes: Using t-test for non-normal data or Mann-Whitney for paired samples.
  2. Hypothesis Formulation:

    • Clearly state H₀ and H₁ (e.g., "H₀: μ₁ = μ₂ vs. H₁: μ₁ ≠ μ₂").
    • Specify directionality (one-tailed vs. two-tailed).
  3. Step-by-Step Calculations:

    • Show ranking, U-statistic, or χ² formula explicitly.
    • For Mann-Whitney: Always calculate both U₁ and U₂.
    • For Kruskal-Wallis: Verify degrees of freedom (k-1).
  4. Interpretation:

    • Link p-values to α (e.g., "p = 0.03 < 0.05 → reject H₀").
    • State conclusions in context (e.g., "Catalyst C1 performs significantly better than C2/C3").
  5. Assumptions Check:

    • For non-parametric tests, confirm:
      • Data is independent.
      • No extreme outliers (affects ranks).
    • For chi-square: Expected frequencies ≥5 in most cells (use Fisher’s exact test if violated).

Common Pitfalls

  • Ignoring ties: In Mann-Whitney/Kruskal-Wallis, ties must be averaged.
  • Wrong degrees of freedom: For Kruskal-Wallis, df = k-1 (not N-1).
  • Misapplying tests:
    • Wilcoxon for independent samples (use Mann-Whitney instead).
    • Chi-square for ordinal data (use Spearman’s rho).
  • Overlooking multiple testing: If running multiple tests, adjust α (e.g., Bonferroni correction).

Quick Reference Table for Exams

Test Hypotheses Test Statistic Critical Value Source
Mann-Whitney U H₀: medians equal U = min(U₁, U₂) Mann-Whitney table (n₁, n₂)
Wilcoxon Signed-Rank H₀: paired medians equal W = sum of positive ranks Wilcoxon table (n pairs)
Kruskal-Wallis H₀: all medians equal H ≈ χ² χ² table (df = k-1)
Chi-Square H₀: independent categories χ² χ² table (df = (r-1)(c-1))

Sample Exam Question Breakdown

Question: A survey of 200 students classified by class and opinion on a core curriculum change yielded:

Class Favoring Opposing Total
Freshman 125 80 205
Sophomore 60 140 200
Junior 50 60 110
Test at α=0.05 if opinion is independent of class.

Expected Answer Structure:

  1. State H₀/H₁:
    • H₀: Opinion is independent of class.
    • H₁: Opinion depends on class.
  2. Calculate expected frequencies (e.g., for Freshman/Favoring: ).
  3. Compute χ²:
  4. Critical value: df = (3-1)(2-1) = 2 → χ²₀.₀₅ = 5.991.
  5. Decision: If χ² > 5.991, reject H₀.
  6. Conclusion: "There is significant association between class and opinion on the curriculum change (p < 0.05)."

Note Length: ~1,800 words Key Coverage: Definitions, test selection, step-by-step procedures, comparisons, applications, and exam-specific tips. All subtopics from the syllabus are addressed with practical examples.

Based on the TU BSc CSIT syllabus for Statistics II (STA215), unit 4.

Discussion

Loading…