Comprehensive Guide to Chi-Square Tests

Introduction to Chi-Square Tests

  • Chi-square (χ2\chi^2) tests are statistical methods used to test hypotheses regarding patterns of outcomes.

  • These tests are based on frequency counts for categorical random variables.

  • The two primary types of chi-square tests covered in this chapter include:

    • Goodness of fit test: This test assesses how closely the distribution of a single categorical variable matches a specific expected distribution.

      • Example Application: Determining if the current transportation model (drive, bike, walk, other) for students matches the model used 5 years ago.

    • Test of independence: This test determines whether two categorical variables are independent of one another or if a significant association exists between them.

      • Example Application: Investigating if there is an association between gender and smoking habits.

Properties of the Chi-Square Distribution

  • Family of Distributions: The chi-square distribution is not a single curve but a family of distributions, with a unique curve for every different degree of freedom (dfdf).

  • Parameter: It has only one parameter, which is the degrees of freedom (dfdf).

  • Shape:

    • The distribution is skewed to the right.

    • As the degrees of freedom (dfdf) increase, the distribution becomes more symmetrical.

  • Values: The distribution assumes only non-negative values (≥0\ge 0).

  • Area: The total area under the chi-square curve is equal to 11.

The Chi-Square Test Statistic

  • The χ2\chi^2 test statistic represents the discrepancy between observed and expected frequencies.

  • It can be computed using either of the following formulas:

    1. χ2=∑O2E−n\chi^2 = \sum \frac{O^2}{E} - n

    2. χ2=∑(O−E)2E\chi^2 = \sum \frac{(O - E)^2}{E}

  • Variables Defined:

    • OO = Observed frequency

    • EE = Expected frequency

    • nn = Sample size

General Rejection Rule for Chi-Square Tests

  • Rejection Region: The area of the rejection region is defined by the level of significance (alpha), denoted as α\alpha.

  • Location: The rejection region always lies on the right side (upper tail) of the chi-square curve.

  • Critical Value: The boundary for the rejection region is the critical value, denoted as χdf;α2\chi^2_{df;\alpha}.

  • Decision Rule: If the calculated test statistic (χ2\chi^2) lies in the rejection region, reject the null hypothesis (H0H_0) in favour of the alternative hypothesis (H1H_1).

    • In mathematical terms: Reject H0H_0 if χ2>χdf;α2\chi^2 > \chi^2_{df;\alpha}.

The Goodness-of-Fit Test

  • The purpose is to verify if an observed sample distribution fits a theoretical distribution.

  • Degrees of Freedom: For this test, df=k−1df = k - 1, where kk is the number of categories.

Goodness-of-Fit Example 1: Drunk Driving Arrests

  • Scenario: A sample of 100100 people arrested for drunk driving is categorized by age to test if the proportion of arrests is the same for all age groups at a 1%1\% level of significance (α=0.01\alpha = 0.01).

  • Hypotheses:

    • H0H_0: The proportion of people arrested for drunk driving is the same for all age groups.

    • H1H_1: The proportion is not the same for all age groups.

  • Data and Calculation Table (n=100n = 100):

Age

Observed (O)

Expected (E)

O2E\frac{O^2}{E}

16-20

25

20

25220=31.25\frac{25^2}{20} = 31.25

21-25

32

20

51.251.2

26-30

19

20

18.0518.05

31-35

16

20

12.812.8

36-40

8

20

3.23.2

Total

100

100

116.5

  • Calculation of Expected Frequency: Since there are 55 categories, the expected frequency for each group is E=1005=20E = \frac{100}{5} = 20.

  • Test Statistic:

    • χ2=∑O2E−n=116.5−100=16.5\chi^2 = \sum \frac{O^2}{E} - n = 116.5 - 100 = 16.5

  • Critical Value Determination:

    • α=0.01\alpha = 0.01

    • df=k−1=5−1=4df = k - 1 = 5 - 1 = 4

    • χ4;0.012=13.277\chi^2_{4;0.01} = 13.277

  • Decision: Since the test statistic χ2=16.5\chi^2 = 16.5 is greater than the critical value 13.27713.277, we reject H0H_0 at a 1%1\% level of significance.

  • Conclusion: There is insufficient evidence to conclude that the proportion of drunk drivers is the same for all age groups.

Goodness-of-Fit Example 2: Bokomo Cereal Sales Patterns

  • Scenario: Bokomo breakfast cereal sells nationally in three sizes (large, medium, small) in a ratio of 3:5:23:5:2. A sample from the Limpopo region shows sales of 190190, 250250, and 100100 cases respectively. Test at the 5%5\% level of significance (α=0.05\alpha = 0.05) if the Limpopo region's pattern differs from the national pattern.

  • Hypotheses:

    • H0H_0: The Limpopo region’s pattern of sales is the same as the national sales pattern.

    • H1H_1: The Limpopo region’s pattern of sales is not the same as the national sales pattern.

  • Total Sample Size (nn): 190+250+100=540190 + 250 + 100 = 540 cases.

  • Ratio Components: 3+5+2=103 + 5 + 2 = 10 parts in total.

  • Data and Calculation Table:

Size

Observed (O)

Expected (E)

O2E\frac{O^2}{E}

Large

190

540×310=162540 \times \frac{3}{10} = 162

222.84222.84

Medium

250

540×510=270540 \times \frac{5}{10} = 270

231.48231.48

Small

100

540×210=108540 \times \frac{2}{10} = 108

92.5992.59

Total

540

540

546.91

  • Test Statistic:

    • χ2=∑O2E−n=546.91−540=6.91\chi^2 = \sum \frac{O^2}{E} - n = 546.91 - 540 = 6.91

  • Critical Value Determination:

    • α=0.05\alpha = 0.05

    • df=k−1=3−1=2df = k - 1 = 3 - 1 = 2

    • χ2;0.052=5.991\chi^2_{2;0.05} = 5.991

  • Decision: Since χ2=6.91>5.991\chi^2 = 6.91 > 5.991, we reject H0H_0 at a 5%5\% level of significance.

  • Conclusion: There is insufficient evidence to conclude that the Limpopo region’s pattern of sales is the same as the national sales pattern.

The Chi-Square Test of Independence

  • This test uses a contingency table to determine if two categorical variables are related.

  • Degrees of Freedom: For a contingency table, df=(r−1)(c−1)df = (r - 1)(c - 1), where rr is the number of rows and cc is the number of columns.

  • Formula for Expected Frequency: For each cell in the table, the expected frequency is calculated as:

    • E=Row Total×Column TotalGrand TotalE = \frac{\text{Row Total} \times \text{Column Total}}{\text{Grand Total}}

Test of Independence Example: Gender and Television Habits

  • Scenario: A random sample of 9090 adults is classified by gender and time spent watching TV (under vs. over 2525 hours). Test at a 0.010.01 level of significance if TV time is independent of gender.

  • Hypotheses:

    • H0H_0: Gender and time spent watching TV are independent.

    • H1H_1: Gender and time spent watching TV are dependent.

  • Contingency Table (Observed and Expected):

Time Spent

Male

Female

Total

Under 25 hours

27 (21.4721.47)

19 (24.5324.53)

46

Over 25 hours

15 (20.5320.53)

29 (23.4723.47)

44

Total

42

48

90

  • Detailed Expected Frequency Calculations:

    • Cell 1 (Male/Under 25): E=46×4290=21.47E = \frac{46 \times 42}{90} = 21.47

    • Cell 2 (Female/Under 25): E=46×4890=24.53E = \frac{46 \times 48}{90} = 24.53

    • Cell 3 (Male/Over 25): E=44×4290=20.53E = \frac{44 \times 42}{90} = 20.53

    • Cell 4 (Female/Over 25): E=44×4890=23.47E = \frac{44 \times 48}{90} = 23.47

  • Test Statistic Calculation Table:

| Observed (O) | Expected (E) | O2E\frac{O^2}{E} | | :--- | :--- | :--- | :--- | | 27 | 21.47 | 33.95 | | 19 | 24.53 | 14.72 | | 15 | 20.53 | 10.96 | | 29 | 23.47 | 35.83 | | 90 | 90 | 95.46 |

  • Calculated Test Statistic:

    • χ2=∑O2E−n=95.46−90=5.46\chi^2 = \sum \frac{O^2}{E} - n = 95.46 - 90 = 5.46

  • Critical Value Determination:

    • α=0.01\alpha = 0.01

    • df=(2−1)(2−1)=1df = (2 - 1)(2 - 1) = 1

    • χ1;0.012=6.635\chi^2_{1;0.01} = 6.635

  • Decision: Since the calculated statistic (5.465.46 or 5.645.64 based on the transcript's comparison text) is less than the critical value of 6.6356.635, we do not reject H0H_0 at a 1%1\% level of significance.

  • Conclusion: There is insufficient evidence to conclude that the time spent watching TV is dependent on gender.