Solved Exercises on Chi-Square Test for Independence

Master the chi-square test for independence: contingency tables, expected frequencies, test statistics, degrees of freedom, decision rules, and interpretation through these 5 detailed exercises.

Solution: Exercises 1 to 3
1 Basic Independence Test
Exercise 1
A researcher wants to determine if there is an association between gender and preference for a new soft drink. A survey of 200 people yielded the following results:
Like Dislike Total
Male 60 40 100
Female 70 30 100
Total 130 70 200
Test at α = 0.05 whether gender and preference are independent.
Definition:

Chi-square test for independence: Tests whether two categorical variables are independent (not associated).

Methodology:
  1. State null and alternative hypotheses
  2. Calculate expected frequencies
  3. Compute the test statistic
  4. Determine degrees of freedom
  5. Find critical value or p-value
  6. Make a decision
Step 1: State hypotheses

H₀: Gender and preference are independent

H₁: Gender and preference are dependent

Step 2: Calculate expected frequencies

Expected frequency = (Row total × Column total) / Grand total

Male-Like: (100 × 130) / 200 = 65

Male-Dislike: (100 × 70) / 200 = 35

Female-Like: (100 × 130) / 200 = 65

Female-Dislike: (100 × 70) / 200 = 35

Step 3: Compute test statistic

χ² = Σ [(Observed - Expected)² / Expected]

χ² = [(60-65)²/65] + [(40-35)²/35] + [(70-65)²/65] + [(30-35)²/35]

χ² = 25/65 + 25/35 + 25/65 + 25/35 = 0.385 + 0.714 + 0.385 + 0.714 = 2.198

Step 4: Determine degrees of freedom

df = (rows - 1) × (columns - 1) = (2-1) × (2-1) = 1

Step 5: Compare with critical value

α = 0.05, df = 1 → Critical value = 3.841

Since 2.198 < 3.841, we fail to reject H₀

There is insufficient evidence to conclude that gender and preference are dependent.
Final answer:

We fail to reject the null hypothesis. There is no significant association between gender and soft drink preference at α = 0.05.

Applied rules:

• Independence assumption: Expected frequency ≥ 5 for all cells

• Test statistic: χ² = Σ [(O-E)²/E]

• Decision rule: Reject H₀ if χ² > critical value

2 Three-by-Two Table
Exercise 2
A study was conducted to determine if there is an association between education level and voting behavior. Results from 300 participants:
Voted Did Not Vote Total
High School 80 40 120
College 100 30 130
Graduate 40 10 50
Total 220 80 300
Test at α = 0.01 whether education level and voting behavior are independent.
Definition:

Expected frequency: E = (Row total × Column total) / Grand total

Step 1: Calculate expected frequencies

High School - Voted: (120 × 220) / 300 = 88

High School - Did Not Vote: (120 × 80) / 300 = 32

College - Voted: (130 × 220) / 300 = 95.33

College - Did Not Vote: (130 × 80) / 300 = 34.67

Graduate - Voted: (50 × 220) / 300 = 36.67

Graduate - Did Not Vote: (50 × 80) / 300 = 13.33

Step 2: Compute test statistic

χ² = [(80-88)²/88] + [(40-32)²/32] + [(100-95.33)²/95.33] + [(30-34.67)²/34.67] + [(40-36.67)²/36.67] + [(10-13.33)²/13.33]

χ² = 0.727 + 2.000 + 0.229 + 0.633 + 0.303 + 0.833 = 4.725

Step 3: Determine degrees of freedom

df = (3-1) × (2-1) = 2

Step 4: Compare with critical value

α = 0.01, df = 2 → Critical value = 9.210

Since 4.725 < 9.210, we fail to reject H₀

χ² = 4.725, df = 2, critical value = 9.210
Final answer:

We fail to reject the null hypothesis. There is no significant association between education level and voting behavior at α = 0.01.

Applied rules:

• Assumptions: All expected frequencies should be ≥ 5

• Degrees of freedom: df = (r-1)(c-1)

• Decision rule: Compare calculated χ² with critical value

3 P-value Approach
Exercise 3
A survey of 250 college students examined the relationship between study habits and academic performance:
Good GPA Poor GPA Total
Regular Study 85 15 100
Irregular Study 120 30 150
Total 205 45 250
Use the p-value approach at α = 0.05 to test independence.
Definition:

P-value approach: Reject H₀ if p-value ≤ α

Step 1: Calculate expected frequencies

Regular-Good: (100 × 205) / 250 = 82

Regular-Poor: (100 × 45) / 250 = 18

Irregular-Good: (150 × 205) / 250 = 123

Irregular-Poor: (150 × 45) / 250 = 27

Step 2: Compute test statistic

χ² = [(85-82)²/82] + [(15-18)²/18] + [(120-123)²/123] + [(30-27)²/27]

χ² = 9/82 + 9/18 + 9/123 + 9/27 = 0.110 + 0.500 + 0.073 + 0.333 = 1.016

Step 3: Determine degrees of freedom

df = (2-1) × (2-1) = 1

Step 4: Find p-value

With χ² = 1.016 and df = 1, p-value ≈ 0.313

Step 5: Make decision

Since p-value (0.313) > α (0.05), we fail to reject H₀

p-value = 0.313 > 0.05, so we fail to reject H₀
Final answer:

We fail to reject the null hypothesis. There is no significant association between study habits and academic performance at α = 0.05.

Applied rules:

• P-value method: Compare p-value with significance level

• Decision rule: Reject H₀ if p-value ≤ α

• Interpretation: Larger p-value indicates weaker evidence against H₀

Key Formulas and Concepts
\( \chi^2 = \sum \frac{(O - E)^2}{E} \)
Chi-square Test Statistic
Degrees of Freedom
\( df = (r-1)(c-1) \)
Where r = rows, c = columns
Expected Frequency
\( E = \frac{RT \times CT}{GT} \)
RT=row total, CT=col total, GT=grand total
Null Hypothesis
\( H_0: \text{Independent} \)
Variables are independent
Key definitions:

Contingency table: Displays frequency distribution of two categorical variables

Expected frequency: Frequency expected under independence assumption

Observed frequency: Actual frequency from sample data

Complete methodology:
  1. Set up hypotheses: H₀: Independent vs H₁: Dependent
  2. Construct contingency table: Organize observed data
  3. Calculate expected frequencies: E = (Row total × Col total) / Grand total
  4. Compute test statistic: χ² = Σ[(O-E)²/E]
  5. Determine df: df = (r-1)(c-1)
  6. Find critical value or p-value
  7. Make decision: Reject H₀ if test statistic > critical value
  8. Draw conclusion: Interpret in context
Tip 1: Always check that all expected frequencies are ≥ 5 for validity.
Tip 2: The chi-square test is always right-tailed for independence.
Tip 3: Large χ² values provide evidence against independence.
Common errors: Forgetting to calculate expected frequencies, incorrect df calculation, misinterpreting results.
Exam preparation: Practice calculating expected frequencies, memorize df formula, understand decision rules.
Assumptions to verify:

• Data type: Categorical variables only

• Independence: Observations are independent

• Expected frequencies: All E ≥ 5 (at least 80% should be ≥ 5)

• Sample size: Sufficiently large sample

Solution: Exercises 4 to 5
4 Multi-category Analysis
Exercise 4
A researcher studied the relationship between major field of study and career choice among 400 recent graduates:
Business Technology Healthcare Total
Engineering 45 75 30 150
Liberal Arts 60 40 50 150
Science 45 35 20 100
Total 150 150 100 400
Test at α = 0.05 whether major field of study and career choice are independent.
Definition:

Three-by-three contingency table: Requires careful calculation of expected frequencies.

Step 1: Calculate all expected frequencies

Using E = (Row total × Column total) / Grand total:

Engineering-Business: (150 × 150) / 400 = 56.25

Engineering-Technology: (150 × 150) / 400 = 56.25

Engineering-Healthcare: (150 × 100) / 400 = 37.5

Liberal Arts-Business: (150 × 150) / 400 = 56.25

Liberal Arts-Technology: (150 × 150) / 400 = 56.25

Liberal Arts-Healthcare: (150 × 100) / 400 = 37.5

Science-Business: (100 × 150) / 400 = 37.5

Science-Technology: (100 × 150) / 400 = 37.5

Science-Healthcare: (100 × 100) / 400 = 25

Step 2: Compute test statistic

χ² = Σ[(O-E)²/E] for all 9 cells

= [(45-56.25)²/56.25] + [(75-56.25)²/56.25] + [(30-37.5)²/37.5] + [(60-56.25)²/56.25] + [(40-56.25)²/56.25] + [(50-37.5)²/37.5] + [(45-37.5)²/37.5] + [(35-37.5)²/37.5] + [(20-25)²/25]

= 2.25 + 6.25 + 1.5 + 0.25 + 4.69 + 4.17 + 1.5 + 0.17 + 1.0 = 21.78

Step 3: Determine degrees of freedom

df = (3-1) × (3-1) = 4

Step 4: Compare with critical value

α = 0.05, df = 4 → Critical value = 9.488

Since 21.78 > 9.488, we reject H₀

χ² = 21.78 > 9.488, so we reject H₀
Final answer:

We reject the null hypothesis. There is a significant association between major field of study and career choice at α = 0.05.

Applied rules:

• Large table: Carefully calculate all expected frequencies

• Decision rule: Reject H₀ if χ² > critical value

• Interpretation: Significant association exists

5 Critical Value Method
Exercise 5
A marketing firm investigated whether age group affects product preference for a new snack. Results from 360 consumers:
Sweet Salty Spicy Total
18-25 40 35 25 100
26-40 50 45 30 125
41-60 45 35 20 100
Over 60 30 25 10 65
Total 165 140 85 390
Use critical value method at α = 0.01 to test independence.
Definition:

Critical value method: Compare test statistic with critical value from table.

Step 1: Calculate expected frequencies

All expected frequencies using E = (RT × CT)/GT:

Row 1: 42.31, 35.90, 21.79

Row 2: 53.13, 45.13, 27.44

Row 3: 42.31, 35.90, 21.79

Row 4: 27.25, 23.07, 14.08

Step 2: Compute test statistic

χ² = Σ[(O-E)²/E] for all 12 cells

= [(40-42.31)²/42.31] + [(35-35.90)²/35.90] + [(25-21.79)²/21.79] + ... + [(10-14.08)²/14.08]

= 0.127 + 0.023 + 0.473 + 0.106 + 0.013 + 0.235 + 0.127 + 0.023 + 0.146 + 0.969 + 0.307 + 1.179 = 3.728

Step 3: Determine degrees of freedom

df = (4-1) × (3-1) = 6

Step 4: Find critical value

α = 0.01, df = 6 → Critical value = 16.812

Step 5: Make decision

Since 3.728 < 16.812, we fail to reject H₀

χ² = 3.728 < 16.812, so we fail to reject H₀
Final answer:

We fail to reject the null hypothesis. There is no significant association between age group and product preference at α = 0.01.

Applied rules:

• Critical value method: Compare calculated χ² with table value

• Decision rule: Fail to reject if χ² < critical value

• Conclusion: No significant association found

Detailed Concepts and Applications
\( E_{ij} = \frac{R_i \times C_j}{N} \)
Expected Frequency Formula
Key definitions:

Contingency table: A table showing the distribution of one categorical variable across the categories of another categorical variable.

Chi-square distribution: A probability distribution used in hypothesis testing, characterized by its degrees of freedom.

Independence: Two variables are independent if knowing the value of one does not provide information about the value of the other.

Step-by-step methodology:
  1. Formulate hypotheses: H₀: Variables are independent vs H₁: Variables are dependent
  2. Organize data: Create a contingency table with observed frequencies
  3. Calculate marginal totals: Row totals, column totals, and grand total
  4. Calculate expected frequencies: E = (row total × column total) / grand total
  5. Verify assumptions: Check that all expected frequencies are ≥ 5
  6. Calculate test statistic: χ² = Σ[(observed - expected)²/expected]
  7. Determine degrees of freedom: df = (number of rows - 1) × (number of columns - 1)
  8. Find critical value or p-value: Based on significance level and df
  9. Make decision: Compare test statistic with critical value
  10. Draw conclusion: State in context of the problem
Tip 1: The chi-square test is non-parametric and doesn't assume normal distribution.
Tip 2: Large samples are preferred for the chi-square approximation to be valid.
Tip 3: The test only indicates association, not causation.
Tip 4: When expected frequencies are too small, consider combining categories.
Common applications: Market research, medical studies, social sciences, quality control.
Limitations: Assumes random sampling, sensitive to sample size, only detects associations.
Key formulas and rules:

• Test statistic: χ² = Σ[(O - E)²/E]

• Degrees of freedom: df = (r-1)(c-1)

• Expected frequency: E = (row total × column total) / grand total

• Decision rule: Reject H₀ if calculated χ² > critical χ² value

• Assumption: All expected frequencies should be ≥ 5

Questions & Answers

Question: I don't understand why we calculate expected frequencies in the chi-square test for independence. What's the purpose of comparing observed versus expected?

Answer: Great question! The expected frequencies represent what we would observe if the null hypothesis (independence) were true. Here's the logic:

  • If two variables are independent, then P(A and B) = P(A) × P(B)
  • This means the probability of being in a particular cell equals the probability of being in that row multiplied by the probability of being in that column
  • So the expected count in each cell = (row total/N) × (column total/N) × N = (row total × column total) / N

When observed frequencies differ significantly from expected frequencies, it suggests that the variables are not independent. The larger the difference between observed and expected, the stronger the evidence against independence.

Think of it this way: if gender and preference were truly independent, we'd expect the proportion of males who like the drink to equal the proportion of females who like it. The expected frequencies capture what we'd see if this were true.

Question: When should I use the chi-square test for independence versus the chi-square goodness-of-fit test?

Answer: The key difference lies in the number of variables and the research question:

  • Chi-square test for independence: Tests the relationship between TWO categorical variables. Example: Is there an association between smoking (yes/no) and lung cancer (yes/no)?
  • Chi-square goodness-of-fit test: Tests whether ONE categorical variable follows a specified distribution. Example: Do observed eye colors match the expected 9:3:3:1 ratio from Mendelian genetics?

Independence test uses contingency tables (rows × columns), while goodness-of-fit has one row with multiple categories.

Independence test asks: "Are these variables related?" Goodness-of-fit asks: "Does this variable follow the expected pattern?"

Both use the same test statistic formula χ² = Σ[(O-E)²/E], but the interpretation differs significantly.

Question: What should I do if some expected frequencies are less than 5? I often encounter this issue in market research.

Answer: This is a common issue! Here are your options:

  • Combine categories: Merge adjacent rows or columns that make logical sense. For example, combine "Strongly Disagree" and "Disagree" responses.
  • Collect more data: Increase your sample size to boost expected frequencies.
  • Use Fisher's Exact Test: For 2×2 tables, this is an exact alternative to chi-square.
  • Yates' continuity correction: For 2×2 tables, apply a correction factor.

The rule of thumb is that all expected frequencies should be ≥ 5, or at least 80% of them should be ≥ 5 with none below 1.

When combining categories, ensure the combination makes substantive sense and doesn't obscure important relationships in your data.