Online College Courses for Credit

4 Tutorials that teach Chi-Square Test for Homogeneity
Take your pick:
Chi-Square Test for Homogeneity

Chi-Square Test for Homogeneity

Author: Jonathan Osters

Calculate the expected frequency for a a chi-square test.

See More

Source: Tables created by Jonathan Osters

Video Transcription

Download PDF

This tutorial is going to run through a chi-square test of homogeneity. Now, homogeneity means that there are multiple populations that we have. We want to know whether or not these categorical variables are homogeneous across the different populations or whether they're different. So do the distributions of categorical that's qualitative data differ across different populations?

So instead of comparing the distributions to some hypothesized distribution that we think might be going on, we compare whether or not two sample distributions are significantly different from each other. So let's look at an example where we'd use this kind of a test. Suppose that two colleges, the U and State are worried about the student drinking behaviors. So they both independently choose random samples of their students. The results of the drinking behaviors are given in the table here.

The question is, does there appear to be a difference with drinking behaviors between the two colleges? Obviously, those who drink a lot represent the lowest category in both schools, and those who drink a little represent the highest in both schools. So maybe they're not that different. We can run a test though to make sure whether that's the case or to dispute whether that's the case.

In the test for homogeneity, the null hypothesis is that they are the same distribution or they're not significantly different, the two sample distributions aren't. The distribution of drinking levels is the same at the U as it is for State. The alternative hypothesis is that the two distributions are not the same.

Now, one of the conditions is going to be that the expected values are all greater than five. But the question is, how do we calculate expected values? We can't do the same thing we did in a goodness of fit test. Here's what we're going to do. We have to think about it this way of the 2,017 students, 326 of them don't drink at all. That's 16.2%.

So the idea here is that if the two distributions were homogeneous, then it would be 16.2% at the U that don't drink it all and 16.2% at State that don't drink it all. So that would be these expected values here, 16.2% percent of the 981 U students and 167.44 of the 1,036 state students that participated in this survey would be the expectation for the never row.

We can continue going through this for each of the rows, but take a look at how this was calculated. Let's take a look just a little bit closer. So when we calculated the expected value for none and the U-- this cell that contains 140 in real life. If we calculated the expected value, we did it this way. This was the 16.2% that we found. We got it by dividing 326 out of the grand total of 2,017. And we said that percent of the 981.

If we look a little closer, we see that the expected none and U value ends up being 326 times 981 over 2017. But where were those numbers? Where did those come from? 326 is all the students who said none, 981 is all the students at the U, and 2017 is all the students total. So the expected values are going to be, for each cell, the row total times the column total over the grand total. From that, it's not too hard to create an entire table of expected values.

So this is what we ended up observing, and this is what we expected. Again, these don't have to be integers. At this point, we can calculate the chi-square statistic using the observed and expected. The conditions can be verified because all cell counts in the expected table are at least five, the smallest one is 38.42.

So now back at the situation at hand. We stated the null and alternative hypotheses, chose an alpha level of 0.05. This is the chi-square test statistic, observed minus expected squared over expected. Add all of them up. We can also use technology to calculate the chi-square test statistic and the p-value.

Here's our conditions. We have two independent random samples and all the cell counts are over five. The chi-square test statistic that we obtained is 96.6. That is huge. In this case, the degrees of freedom is going to be three. It's not important how we obtain that number. This can be all obtained using technology in this case. The p-value ends up being 0.001, very low, less than 0.05. So we reject the null hypothesis and conclude that there is a difference in drinking behavior between the students at the U and the students at State.

So to recap, the chi-square test of homogeneity allows us to test whether two populations have significantly different distributions across the categories. The expected counts for each cell is the product of the row total and the column total divided by the grand total from all this. And the conditions are the same as they are for a goodness of fit test, in that all the expected values have to be greater than five. So we talked about the chi-square test for homogeneity. Good luck and we'll see you next time.

Terms to Know
Chi-square test for homogeneity

A test used to determine if there is no difference in a categorical variable across several populations or treatments

Formulas to Know
Chi-square Degrees of Freedom

d e g r e e s space o f space f r e e d o m space equals space left parenthesis r o w space t o t a l minus 1 right parenthesis left parenthesis c o l u m n space t o t a l minus 1 right parenthesis

Expected Value for Cell in Chi-Square Test for Homogeneity

fraction numerator left parenthesis R o w space T o t a l right parenthesis left parenthesis C o l u m n space T o t a l right parenthesis over denominator G r a n d space T o t a l end fraction