Chi-Square Test of Homogeneity – Learn It 1

  • Complete a chi-square test of homogeneity

[latex]\chi^2[/latex] test of homogeneity

A chi-square test of homogeneity determines if two or more populations (or subgroups of a population) have the same distribution of a single categorical variable.

We use the test of homogeneity if the response variable has two or more categories and we wish to compare two or more populations (or subgroups.)

We can answer the following research question with a chi-square test of homogeneity:

  • Do dogs leaving the Long Beach Animal Shelter have the same distribution of outcomes (whether the dog is adopted, returned to its owner, transferred, or euthanized) in different years?

We could compare as many years as we like, but let’s look at the three most recent years in the data set (2022, 2023, and 2024) and compare the outcome distributions for dogs leaving the shelter. We can look at this information in a contingency table (i.e., a two-way table), where each row represents the outcome distribution for one year. The following table gives the number of dogs with each outcome in each year.[1] Notice that in this table, we are displaying the counts for the categories of one categorical variable (outcome) for three different populations (each population is all the dogs leaving the shelter in a single year).

  Adopted Returned to Owner Transferred Euthanized Total
2022 422 303 66 46 837
2023 575 331 91 96 1,093
2024 632 347 42 122 1,143
Total 1,629 981 199 264 3,073
A note about these data: These counts come from the records of a single shelter, not from random samples of dogs, so the results describe this shelter and should not be generalized to other shelters. We treat each year’s dogs as a sample from that year so that we can practice the test. We also include only the four outcomes shown; the shelter records other outcomes (for example, “rescue”) that we leave out.

Notice that the different years have different numbers of dogs, so it can be useful to look at the relative frequency distribution for each year as well (i.e., the proportions of dogs that have each outcome for each year).

Relative Frequencies

Since [latex]422[/latex] dogs were adopted in 2022 and [latex]837[/latex] dogs left the shelter in 2022 in total, the relative frequency (or proportion) of dogs that were adopted in 2022 is:

[latex]\dfrac{422}{837}=0.504=50.4\%[/latex]

In finding a similar proportion for each outcome, we find that the relative frequency distribution of outcomes for all three years is as displayed in the following table.

  Percentage Adopted Percentage Returned to Owner Percentage Transferred Percentage Euthanized Total
2022 [latex]50.4\%[/latex] [latex]36.2\%[/latex] [latex]7.9\%[/latex] [latex]5.5\%[/latex] [latex]100\%[/latex]
2023 [latex]52.6\%[/latex] [latex]30.3\%[/latex] [latex]8.3\%[/latex] [latex]8.8\%[/latex] [latex]100\%[/latex]
2024 [latex]55.3\%[/latex] [latex]30.4\%[/latex] [latex]3.7\%[/latex] [latex]10.7\%[/latex] [latex]100\%[/latex]

Using only the relative frequencies, do these distributions look significantly different? We’ll use a chi-square test of homogeneity to find out.

In comparing the outcome distributions for these years, we’ll build on two ideas we’ve seen before. We’ve already seen a test for determining whether two population proportions are equal: the two-proportion [latex]z[/latex]-test. For example, we could think of the dogs leaving the shelter in each year as a sample and consider whether the proportion of dogs adopted in 2022 is the same as the proportion of dogs adopted in 2023.

However, in this case, we’re generalizing on that idea by considering more than two populations and looking at the entire distribution of outcomes for all values of the categorical variable. Secondly, we’ll be building on the previous activity by using a chi-square test, but instead of comparing a distribution of counts to a theoretical model, we’re comparing distributions of a categorical variable (in this case, outcome) among different populations (in this case, there are three populations: all dogs leaving the shelter in each of three different years).

The word “homogeneous” means the same or similar, so the chi-square test of homogeneity is asking whether or not two or more distributions of a categorical variable are the same.In short, a chi-square test of homogeneity compares distributions of one categorical variable for multiple populations.

  1. City of Long Beach, Animal Care Services. (n.d.). Animal shelter intakes and outcomes [Data set]. City of Long Beach Open Data. https://data.longbeach.gov/explore/dataset/animal-shelter-intakes-and-outcomes/information/ Accessed via TidyTuesday, 2025-03-04: https://github.com/rfordatascience/tidytuesday/tree/main/data/2025/2025-03-04 ↵