Chi-Squared Test Lecture

Jul 7, 2024

Chi-Squared Test Lecture

Introduction

  • Focus: Testing two or more proportions using chi-squared test
  • Proportion: Calculation based on categorical variables
  • Example: Testing college students' food preferences (pizza vs. salad bar) among freshmen and seniors

Setup and Definitions

  • Categorical Variables: Different categories (e.g., dog, cat, horse)
  • Chi-Squared Statistic: Calculated to test the claim that proportions are the same
  • Expected Counts:
    • Calculate for each cell
    • Formula: (Row Total * Column Total) / Table Total
    • Assumes null hypothesis (H0) is true

Table Layout

  • 2x2 Table: 2 rows and 2 columns
  • 2x3 Table: 2 rows and 3 columns
  • 4x2 Table: 4 rows and 2 columns

Example 1: Cats and Dogs Leisure Activity

  • Cats: 16 total
  • Dogs: 17 total
  • Activities: Playtime and Nap
  • Null Hypothesis (H0): No relationship between type of animal and activity preference
  • Expected Counts Calculation:
    • Playtime (Dogs): (17 * 15) / 33 = 7.6
    • Nap (Dogs): (17 * 18) / 33 = 9.2
    • Similar calculations for cats
  • Observed Data vs. Expected Count: Compare to determine if null hypothesis can be rejected

Hypothesis Testing

  • Null Hypothesis (H0): No relationship (independent variables)
  • Alternate Hypothesis (H1): Relationship exists (dependent variables)
  • Chi-Squared Test Statistic: Formula
    • Sum of (Observed Count - Expected Count)^2 / Expected Count for each cell
    • Use chi-squared distribution table or software for p-value

Example 2: Coke vs Pepsi Preference

  • Test: Can people identify preference between Coke and Pepsi?
  • Methods: Blind taste test after recording initial preference
  • Observed Data: How many people correctly identified their preference
  • Expected Count Calculation:
    • Example: (312 * 270) / 512 = 164 (Own Coke)
  • Requirements for Chi-Squared Test:
    1. Simple Random Sample with independent populations
    2. All expected counts ≥ 1
    3. At least 80% of expected counts are ≥ 5
  • Calculation and Interpretation:
    • Chi-Squared Statistic: 5.17 (example)
    • Degrees of Freedom: (2-1) * (2-1) = 1
    • P-value: Calculated via software (e.g., Excel)
    • Reject Null Hypothesis if p-value < alpha (typically 0.05)

Conclusion

  • Chi-squared test helps determine relationships between categorical variables
  • Following the steps and conditions ensures accurate hypothesis testing
  • Example showed real-world use in determining beverage preferenceё