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

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

Now we will complete the chi-square test for independence. On this page you will learn

how to check conditions for use of the chi-square test

how to interpret the StatCrunch print-out to draw a conclusion

and (for those who like formulas) how to calculate the formula for the chi-square test statistic and use an applet to find the P-value based on the chi-square model–this part is optional.

EXAMPLE Gender and body image (continued)

Here are our hypotheses from the previous page:

: There is no relationship between gender and body image for U.S. college students. (The variables are independent.)

: There is a relationship between gender and body image for U.S. college students. (The variables are dependent.)

Below are the StatCrunch results for the gender and body image data. (We will show you how to use StatCrunch to conduct a chi-square test for independence soon.)

Recall that this data comes from a random sample of 1200 college students. Expected counts are in parentheses.

Rows: Gender
Columns: None

Cell format

Count
(Expected count)

Contingency table results:

| About right | Overweight | Underweight | Total

Female

560
(541.5)

163
(148.83)

37
(69.67)

760

Male

295
(313.5)

72
(86.17)

73
(40.33)

440

Total | 855 | 235 | 110 | 1200

Chi-Square test:

Statistic | DF | Value | P-value
Chi-square | 2 | 47.176025 | <0.0001

Checking conditions

There are two conditions for use of the Chi-square test:

The sample is random.

All of the expected counts are 5 or greater.

The data meets these conditions; therefore, we can proceed with the chi-square test.

Stating a conclusion

As with all hypothesis tests, we use the P-value to choose between two possible conclusions:

A small P-value indicates that the differences between the observed and expected counts are statistically significant. We reject the null and accept the alternative hypothesis. We conclude that the variables are dependent (related to each other).

A large P-value indicates that the differences between the observed and expected counts are not statistically significant; differences this large are common in random sampling from a population in which the two variables are independent (not related.) We do not have strong enough evidence to reject the null hypothesis. We fail to reject it.

For this data, we see that the P-value is extremely small (P < 0.0001). Therefore, we reject the null hypothesis and accept the alternative hypothesis. We conclude that gender and self-perception of body weight are related (dependent).

The P-value is the probability that random samples will have a Chi-square test statistic larger then that calculated for the observed sample. We can also describe the P-value as the likelihood that random samples will have larger relative differences in observed and expected counts (relative to the expected counts) than we observe in our sample. As before, the P-value is a conditional probability based on the condition that the null hypothesis is true.

EXAMPLE (optional)

For those who like formulas, here we show how to calculate the Chi-square test statistic, denoted . In this course, you will not be required to calculate the chi-square test statistic by hand.

Calculating the Chi-Square Test Statistic

Here is the formula for the chi-square test statistic. Notice that it is a measurement of the differences between observed and expected counts.

In the StatCrunch print-out above, we see that the Chi-square test statistic is about 47 for this data. Here is the calculation.

| About right | | Overweight | | Underweight |
| female | | male | | female | | male | | female | | male |
= | | + | | + | | + | | + | | + | | = 47.18

Notice that each term in the equation contributes to the Chi-square calculation. For each term in the equation, we take the difference between the observed and expected count, square it, and divide by the expected count, then we add these values to get the chi-square test statistic.

Finding Degrees of Freedom and the P-Value

There are many chi-square curves just like there are many T-curves. Like the T-curve, the chi-square curve depends on degrees of freedom (df).

The degrees of freedom for the Test of Independence are

df= (number of explanatory categories − 1) × (number of response categories − 1)

You will also see this written: df = (r − 1)(c − 1), where r is the number of rows and c is the number of columns in the two-way table (when we write the table without row and column totals).

In this example the degrees of freedom are (2 − 1)(3 −1 ) = 2.

We use the chi-square distribution with df = 2 to find the P-value using an applet.

The applet shows the Chi-square curve based on the degrees of freedom and the area to the right of the Chi-square test statistic that represents the P-value. Notice that all Chi-square curves are skewed to the right and the P-value is always the area to the right of the test statistic. As the number of degrees of freedom increases, the peak of the corresponding Chi-square curve is farther to the right. You can see this in the applet below.

Enter df = 2 and the chi-square test statistic we calculated above (47.18) in the applet below. Then hit enter.

OOPS, the chi-square test statistic for this sample is so large that it is off the scale used in the applet! Oh well, this is not a problem. This tell us that the P-value (area to the right of the test statistic) is essentially zero. We see this in the applet where it says Probability = 0.000. If the Chi-square statistic was smaller, you would see the P-value as a darkly shaded area to the right.

Additional Comments About the Chi-Square Distribution and P-Values

Unlike other sampling distributions we have studied, the Chi-square model does not have a normal shape. It is skewed to the right. Like the T-model, the Chi-square model is a family of curves that depend on degrees of freedom.

For different degrees of freedom, the same Chi-square value will give different P-values. For example, a Chi-square value of 8 is statistically significant if with 3 degrees of freedom, but not with 8 degrees of freedom. As shown in the graphs below, this is due to the change in the chi-square curve.

The Chi-square curve with 3 degrees of freedom has a mean at 3. Most of the area of the curve is near Chi-square = 3, and the tail is very flat. The area to the right of Chi-square = 8, which is the P-value, is only 0.0460.

On the other hand, the Chi-square curve with 5 degrees of freedom has a mean at 5. Most of the area of the curve is around Chi-square = 5, and the tail is not as flat. The area to the right of Chi-square = 8, which is the P-value, is 0.1562.