STA215 Statistics II

Statistics IIUnit 77 min read

Chi-Square Tests & Categorical Data Analysis: Tests, Assumptions & Applications

Unit 7 of Statistics II covers chi-square goodness-of-fit tests, tests of independence, and categorical data analysis, including assumptions, test statistics, and real-world applications like market research and quality control.

Key Concepts & Definitions

1. Categorical Data

  • Data classified into categories (nominal/ordinal) rather than numerical values.
  • Example: Gender (Male/Female), Opinion (Agree/Disagree), Product Preference (Brand A/B/C).

2. Chi-Square (χ²) Tests

A family of non-parametric tests used to analyze categorical data by comparing observed frequencies with expected frequencies under a null hypothesis.


Types of Chi-Square Tests

1. Chi-Square Goodness-of-Fit Test

Purpose: Tests if a sample matches a population distribution. Formula: where:

  • = Observed frequency
  • = Expected frequency (calculated under )

Assumptions:

  • Categorical data (nominal/ordinal).
  • Expected frequency in at least 80% of cells (if violated, combine categories).
  • Independent observations.

Example: A die is rolled 60 times. Observed frequencies: 10, 8, 12, 9, 11, 10. Test if fair (: for each face).

Steps:

  1. Calculate : for each face.
  2. Compute :
  3. Degrees of Freedom (df): (where = number of categories).
  4. Critical Value: From χ² table, .
  5. Decision: Since , fail to reject (die is fair).

2. Chi-Square Test of Independence

Purpose: Tests if two categorical variables are independent (no association). Formula: Same as goodness-of-fit, but is calculated using row/column totals.

Assumptions:

  • Same as goodness-of-fit.
  • Variables are cross-classified (contingency table).

Example: Test if gender (Male/Female) and smoking status (Smoker/Non-smoker) are independent in a sample of 200 people.

Smoker Non-smoker Total
Male 40 60 100
Female 20 80 100
Total 60 140 200

Steps:

  1. Calculate :

  2. Compute :

  3. df: (where = rows, = columns).

  4. Critical Value: .

  5. Decision: Since , reject (gender and smoking status are dependent).


Comparison Table: Goodness-of-Fit vs. Test of Independence

Feature Goodness-of-Fit Test of Independence
Purpose Tests if data fits a distribution. Tests association between two variables.
Hypothesis : Observed = Expected. : Variables are independent.
Degrees of Freedom (categories). (rows × columns).
Example Use Case Testing fairness of a die. Testing if education level affects job choice.

Advantages & Limitations

Advantages:

  • Non-parametric: No assumptions about population distribution.
  • Versatile: Works for nominal/ordinal data.
  • Simple Interpretation: Rejecting suggests a meaningful pattern.

Limitations:

  • Sample Size Dependency: Requires (use Fisher’s exact test otherwise).
  • No Causality: Only tests association, not cause-effect.
  • Sensitive to Small Samples: May lack power with few observations.

Applications in Real World

  1. Market Research:
    • Test if customer preferences differ by age group (e.g., soft drink vs. energy drink).
  2. Quality Control:
    • Check if defects in products vary by production shift.
  3. Medical Studies:
    • Determine if a disease is associated with smoking status.
  4. Social Sciences:
    • Analyze voting patterns by demographic groups.

Worked Example: Past Exam Question (Adapted)

Question: A survey of 200 students classified by gender and preference for online vs. offline classes:

Online Offline Total
Male 50 50 100
Female 40 60 100
Total 90 110 200

Test at 5% significance if gender and class preference are independent.

Solution:

  1. Calculate :

  2. Compute :

  3. df: .

  4. Critical Value: .

  5. Decision: → Fail to reject (no significant association).


Exam Tip

What Examiners Look For:

  1. Correct Hypothesis Formulation:
    • Always state and clearly (e.g., ": Variables are independent").
  2. Expected Frequency Calculation:
    • Show all values (partial credit if missing).
  3. Chi-Square Formula Application:
    • Use the correct formula and compute each term separately.
  4. Degrees of Freedom:
    • Remember:
      • Goodness-of-fit:
      • Test of independence:
  5. Decision Rule:
    • Compare with critical value or use -value (if provided).
  6. Interpretation:
    • Avoid vague statements like "reject ". Instead:
      • ✅ "There is significant evidence to suggest an association between [variables]."
      • ❌ "The null hypothesis is wrong."

Common Mistakes to Avoid:

  • Ignoring Assumptions: If , mention it and suggest combining categories.
  • Incorrect df: Double-check for contingency tables.
  • Arithmetic Errors: Recompute carefully (examiners deduct for calculation mistakes).
  • Misinterpreting Results: A rejected means association exists, not causation.

Quick Revision Checklist:

  • Can I define chi-square tests and their types?
  • Do I know how to calculate expected frequencies?
  • Can I compute and determine df correctly?
  • Can I interpret results in context (e.g., "smoking and disease are associated")?
  • Do I recognize when to use goodness-of-fit vs. test of independence?

End of Note

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

Discussion

Loading…