This tutorial is going to run through a chi-square test of homogeneity. Specifically you will focus on:
Homogeneity is a test that uses multiple populations and tests to see if these populations are the same across categorical, or qualitative, variables.
So do the distributions of categorical that's qualitative data differ across different populations?
Instead of comparing the distributions to some hypothesized distribution that you think might be going on, you compare whether or not two sample distributions are significantly different from each other. Look at an example where you'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. Maybe they're not that different. You 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.
One of the conditions is going to be that the expected values are all greater than five. But the question is, how do you calculate expected values? You can't do the same thing you did in a goodness of fit test. You have to think about it this way. Of the 2,017 students, 326 of them don't drink at all. That's 16.2%.
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. 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.
Continue going through this for each row, but take a look at how this was calculated.
Take a closer look. So when you calculated the expected value for none and the U-- this cell that contains 140 in real life. If you calculated the expected value, you did it this way. This was the 16.2% that you found. You got it by dividing 326 out of the grand total of 2,017. And you said that percent of the 981.
If you look a little closer, you 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.
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.
The table on the left is what you observed. The table on the right is what you expected. Again, these don't have to be integers. At this point, you 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.
You stated the null and alternative hypotheses, chose an alpha level of 0.05. This is the chi-square test statistic:
What does this mean? It's observed minus expected squared over expected. Add all of them up. You can also use technology to calculate the chi-square test statistic and the p-value.
Here are the conditions. You have two independent random samples and all the cell counts are over five. The chi-square test statistic that you obtained is 96.6. In this case, the degrees of freedom is going to be three. It's not important how you 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. You 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.
The chi-square test of homogeneity allows you 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.
Source: This work adapted from Sophia Author Jonathan Osters.
A test used to determine if there is no difference in a categorical variable across several populations or treatments