Wiki Page, Math 13 - Perez Sandbox : Module 27 - Chi-Square Test of Independence (1 of 3)

Wiki Page
2026-01-17T21:15:47-08:00

Overview

In this unit we learn to conduct the chi-square test of independence. ("Chi" rhymes with sky.") This test examines the relationship between two categorical variables to determine if they are independent.

Previously, in checking conditions for the ANOVA test, we used the term "independent samples" to indicate that the outcomes of one sample do not affect the outcomes of the other. For example, for a random sample of college students, hours of television viewing by males is independent of television viewing by females. However, for a random sample of heterosexual married couples, hours of television viewing by males is not independent of television viewing by females because husbands and wives are likely to influence each other's television viewing.

By contrast, we are now trying to determine if one categorical variable is independent of the other in a population. Here "independent" means there is no relationship between the two variables. If there is a relationship between the two variables in the population, then they are dependent.

We can answer the following research questions with a chi-square test of independence:

For young adults in the United States, is gender related to body image?

Is alcohol abuse by New York firefighters dependent on participation in the 9/11 rescue operation?

In the United States, is race associated with political views (conservative, moderate, liberal)?

The null hypothesis says in essence that there is no relationship between the two variables in the population. In other words, the variables are independent. The alternative hypothesis says that the two categorical variables are related in the population. In other words, the variables are dependent.

To test our hypotheses, we select a random sample from the population and gather data on two categorical variables from each individual. Usually, we identify one variable as the explanatory variable and the other variable as the response variable. Both variables can have multiple values. For example, the explanatory variable might be Gender (two values: male or female) or College Class (four values: freshman, sophomore, junior, senior). Similarly, the response variable can have multiple values. For example, the response variable might be Pet Ownership (two values: yes, no) or Employment Status (three values: unemployed, employed part-time, employed full-time).

EXAMPLE Gender and body image

What is your perception of your own body? Do you feel that you are overweight, underweight, or about right? A random sample of 1,200 U.S. college students answered this question as part of a larger survey. The following table shows part of the responses.

Students' Responses to Body Image Survey

Student | Gender | Body Image
Student 25 | M | Overweight
Student 26 | M | About right
Student 27 | F | Underweight
Student 28 | F | About right
Student 29 | M | About right

Notice that the sample is a random sample from a single population: U.S. college students. Notice also that we collected data on two categorical variables for each student: gender (the explanatory variable) and body image (the response variable). This is the type of situation that is appropriate for a chi-square test of independence.

Step 1: State the hypotheses

Here are two equivalent ways we can state the hypotheses for a test of independence.

: There is no relationship between gender and body image for U.S. college students.

: There is a relationship between gender and body image for U.S. college students.

We could also state the hypotheses like this:

: Gender and body image are independent in the population of U.S. college students.

: Gender and body image are dependent in the population of U.S. college students.

Step 2: Collect and analyze the data

We summarized the data for this sample in a two-way table. The observed counts come from the sample:

Observed Counts

| About right | Overweight | Underweight | Row Totals
Female | 560 | 163 | 37 | 760
Male | 295 | 72 | 73 | 440
Column Totals | 855 | 235 | 110 | 1200

To investigate the relationship between Gender and Body Image, we start by examining the distribution of Body Image (the response variable) without regard to Gender (the explanatory variable.) This gives us a baseline for comparison.

Then we add the explanatory variable Gender into the mix. We compare the baseline distribution of Body Image to the distribution of Body Image (the response variable) for males and females (for each of the groups defined by the explanatory variable).

The table below shows what we mean by "distribution" when talking about categorical variables.

Conditional Percentages

| About right | Overweight | Underweight | Row Totals

Female

560/760
73.68%

163/760
21.45%

37/760
4.87%

760/760
100%

Male

295/440
67.00%

72/440
16.36%

73/440
16.59%

440/440
100%

Column Totals

855/1200
71.25%

235/1200
19.58%

110/1200
9.17%

1200/1200
100%

The baseline is the bottom row. We simply calculate the percentage of the sample with each response; therefore, we calculate each percentage using the total sample size. The baseline ignores the effect of the explanatory variable.

The rows going across represent the groups defined by the explanatory variable. Here the explanatory variable is Gender, so we have a row for Females and a row for Males. The percentages across a row are conditional percentages; therefore, we calculate each percentage in a row using the total number in that group, not the total in the sample. The row percentages represent the effect of the explanatory variable on the response variable.

We graphed these conditional percentages using ribbon charts for a visual comparison.

In this sample, we can see that about 71.3% of the sample perceive their body weight to be “about right," but a larger percentage of females (73.7%) and a smaller percentage of males (67%) perceive their body weight to be “about right.”

About 19.6% of the sample feel they are "overweight," compared to a larger percentage of females (21.4%) and a smaller percentage of males (16.4%) with this view of their weight.

About 9.2% of the sample feel they are "underweight." Males are more likely to view themselves as underweight (16.6%), but females as much less likely to perceive their weight this way (4.9%).

For easier comparison below is the table with just the percentages shown. If Gender and Body Image are independent, then the percentages for each response variable category (underweight, overweight, about right) will be the same. In other words, the percentages in each column (going down) in the this table will be the same.

Conditional Percentages

| About right | Overweight | Underweight | Row Totals
Female | 73.68% | 21.45% | 4.87% | 100%
Male | 67.00% | 16.36% | 16.59% | 100%
Column Totals | 71.25% | 19.58% | 9.17% | 100%

Obviously, when we compare the conditional percentages for males and females in this sample, we see that they differ.

But do they differ enough to conclude that variables are dependent? Or could these differences be the result of chance fluctuation that happens when sampling from a population where gender and body image are independent? We need to conduct a chi-square test of independence to find out.