Activity 34

MATH 216: Statistical Thinking

Chi-Square Test of Independence

Time Allocation: 15 minutes total (5 min reading, 10 min individual work)

Part 1: Conceptual Understanding (2 minutes)

Instructions: Answer the following questions:

  1. What is the formula for calculating expected counts in a contingency table under the null hypothesis of independence?

Part 2: Chi-Square Calculations (13 minutes)

Perform chi-square test of independence calculations for the following 4 scenarios:

Example 1: Flu Vaccine Effectiveness

Context: Testing if flu vaccination affects flu contraction - Contingency table:

Status No Vaccine One Shot Two Shot Total
Flu 24 9 13 46
No Flu 289 100 565 954
Total 313 109 578 1000

Calculate:

  • Expected count for (Flu, One Shot) =
  • \(\chi^2\) =
  • \(df\) =
  • Decision at \(\alpha = 0.05\):

Example 2: Political Views & Space Exploration

Context: Testing if political affiliation is related to support for space exploration - Contingency table:

Support Level Republican Democrat Independent Total
Strong 8 10 12 30
Moderate 12 17 6 35
Weak 10 13 12 35
Total 30 40 30 100

Calculate:

  • Expected count for (Moderate, Democrat) =
  • \(\chi^2\) =
  • \(df\) =
  • Decision at \(\alpha = 0.05\):

Example 3: Smoking and Lung Disease

Context: Testing if smoking habits are associated with lung disease - Contingency table:

Disease Status Smoker Non-Smoker Total
Lung Disease 45 15 60
No Disease 105 135 240
Total 150 150 300

Calculate:

  • Expected count for (Lung Disease, Non-Smoker) =
  • \(\chi^2\) =
  • \(df\) =
  • Decision at \(\alpha = 0.05\):

Example 4: Education Level and Voting Behavior

Context: Testing if education level affects voting preferences - Contingency table:

Education Level Candidate A Candidate B Candidate C Total
High School 20 30 10 60
College 25 15 20 60
Graduate 15 5 10 30
Total 60 50 40 150

Calculate:

  • Expected count for (College, Candidate B) =
  • \(\chi^2\) =
  • \(df\) =
  • Decision at \(\alpha = 0.05\):

Show your work for one calculation:

# R code for chi-square test of independence calculations (for reference)

# Example 1: Flu Vaccine Effectiveness
flu_vaccine_data <- matrix(c(24, 9, 13, 289, 100, 565),
                          nrow = 2, byrow = TRUE,
                          dimnames = list(c("Flu", "No Flu"),
                                         c("No Vaccine", "One Shot", "Two Shot")))
vaccine_test <- chisq.test(flu_vaccine_data, correct = FALSE)
vaccine_test

    Pearson's Chi-squared test

data:  flu_vaccine_data
X-squared = 17.313, df = 2, p-value = 0.000174
# Example 2: Political Views & Space Exploration
politics_data <- matrix(c(8, 10, 12, 12, 17, 6, 10, 13, 12),
                       nrow = 3, byrow = TRUE,
                       dimnames = list(c("Strong", "Moderate", "Weak"),
                                      c("Republican", "Democrat", "Independent")))
politics_test <- chisq.test(politics_data, correct = FALSE)
politics_test

    Pearson's Chi-squared test

data:  politics_data
X-squared = 4.5397, df = 4, p-value = 0.3379
# Example 3: Smoking and Lung Disease
smoking_data <- matrix(c(45, 15, 105, 135),
                      nrow = 2, byrow = TRUE,
                      dimnames = list(c("Lung Disease", "No Disease"),
                                     c("Smoker", "Non-Smoker")))
smoking_test <- chisq.test(smoking_data, correct = FALSE)
smoking_test

    Pearson's Chi-squared test

data:  smoking_data
X-squared = 18.75, df = 1, p-value = 1.49e-05
# Example 4: Education Level and Voting Behavior
education_data <- matrix(c(20, 30, 10, 25, 15, 20, 15, 5, 10),
                        nrow = 3, byrow = TRUE,
                        dimnames = list(c("High School", "College", "Graduate"),
                                       c("Candidate A", "Candidate B", "Candidate C")))
education_test <- chisq.test(education_data, correct = FALSE)
education_test

    Pearson's Chi-squared test

data:  education_data
X-squared = 13.958, df = 4, p-value = 0.007429