Stat Trek

Teach yourself statistics

Stat Trek

Teach yourself statistics


Chi-Square Test for Homogeneity

This lesson explains how to conduct a chi-square test for homogeneity. The test is applied to a single categorical variable from two or more different populations. It is used to determine whether frequency counts are distributed identically across different populations.

For example, in a survey of TV viewing preferences, we might ask respondents to identify their favorite program. We might ask the same question of two different populations, such as males and females. We could use a chi-square test for homogeneity to determine whether male viewing preferences differed significantly from female viewing preferences. The sample problem at the end of the lesson considers this example.

When to Use Chi-Square Test for Homogeneity

The chi-square test for homogeneity is appropriate when the following conditions are met:

  • For each population, the sampling method is an independent random sample.
  • The variable under study is categorical.
  • If sample data are displayed in a contingency table (Populations x Category levels), the expected frequency count for each cell of the table is at least 5.

General Procedure for Hypothesis Testing

To test any hypothesis, the same five-step procedure is used: (1) state the hypotheses, (2) choose the significance level, (3) compute the test statistic, (4) find the P-value, and (5) interpret results. Here, we apply the general procedure to the chi-square test for homogeneity.

State the Hypotheses

Every hypothesis test requires the analyst to state a null hypothesis and an alternative hypothesis. The hypotheses are stated in such a way that they are mutually exclusive. That is, if one is true, the other must be false; and vice versa.

Suppose that data were sampled from r populations, and assume that the categorical variable had c levels. At any specified level of the categorical variable, the null hypothesis states that each population has the same proportion of observations. Thus,

H0: Plevel 1 of pop 1 = Plevel 1 of pop 2 = . . . = Plevel 1 of pop r
H0: Plevel 2 of pop 1 = Plevel 2 of pop 2 = . . . = Plevel 2 of pop r
. . .
H0: Plevel c of pop 1 = Plevel c of pop 2 = . . . = Plevel c of pop r

The alternative hypothesis (Ha) is that at least one of the null hypothesis statements is false.

Choose the Significance Level

The significance level is the probability of rejecting the null hypothesis when it is actually true. Often, researchers choose significance levels equal to 0.01, 0.05, or 0.10.

Compute the Test Statistic

The chi-square test for homogeneity requires that you compute the degrees of freedom (df) for the test statistic, an expected frequency count (Er,c) for each cell of a contingency table (Populations x Category levels), and a chi-square test statistic (χ2). Formulas for all the necessary computations appear below.

  • Degrees of freedom. The degrees of freedom (df) is equal to:

    df = (r - 1) * (c - 1)

    where r is the number of populations, and c is the number of levels for the categorical variable.
  • Expected frequency counts. The expected frequency counts are computed separately for each population at each level of the categorical variable, according to the following formula.

    Er,c = (nr * nc) / n

    where Er,c is the expected frequency count for population r at level c of the categorical variable, nr is the total number of sample observations from population r, nc is the total number of sample observations at treatment level c, and n is the total sample size.
  • Test statistic. The test statistic is a chi-square random variable (χ2) defined by the following equation.

    χ2 = Σ [ (Or,c - Er,c)2 / Er,c ]

    where Or,c is the observed frequency count in population r for level c of the categorical variable, and Er,c is the expected frequency count in population r for level c of the categorical variable.

Find the P-Value

The P-value is the probability of observing a sample statistic as extreme as the test statistic. To find the probability for a chi-square test statistic with degrees of freedom equal to df, use a chi-square distribution table or a statistical software. (The sample problem at the end of this lesson uses Stat Trek's Chi-Square Distribution Calculator to find the P-value for a chi-square test statistic.)

Interpret Results

If the sample findings are unlikely, given the null hypothesis, the researcher rejects the null hypothesis. This involves comparing the P-value to the significance level, and rejecting the null hypothesis when the P-value is less than the significance level.

Test Your Understanding

Problem

In a study of the television viewing habits of children, a developmental psychologist selects a random sample of 300 first graders - 100 boys and 200 girls. Each child is asked which of the following TV programs they like best: The Lone Ranger, Sesame Street, or The Simpsons. Results are shown in the contingency table below.

Viewing Preferences Total
Lone RangerLone
Ranger
Sesame StreetSesame
Street
The SimpsonsThe
Simpsons
Boys 50 30 20 100
Girls 50 80 70 200
Total 100 110 90 300

Do the boys' preferences for these TV programs differ significantly from the girls' preferences? Use a 0.05 level of significance.

Solution

To solve this problem, we conduct a chi-square test for homogeneity. Like any hypothesis test, a chi-square test for homogeneity consists of five steps: (1) state the hypotheses, (2) choose the significance level, (3) compute the test statistic, (4) find the P-value, and (5) interpret results.

  1. State the hypotheses. The first step is to state the null hypothesis and an alternative hypothesis.

    • Null hypothesis: The null hypothesis states that the proportion of boys who prefer the Lone Ranger is identical to the proportion of girls. Similarly, for the other programs. Thus,

      H0: Pboys like Lone Ranger = Pgirls like Lone Ranger

      H0: Pboys like Sesame Street = Pgirls like Sesame Street

      H0: Pboys like Simpsons = Pgirls like Simpsons

    • Alternative hypothesis: At least one of the null hypothesis statements is false.
  2. Choose the significance level. For this analysis, the significance level is 0.05.
  3. Compute the test statistic. Applying the chi-square test for homogeneity to sample data, we compute the degrees of freedom (df), the expected frequency counts (Er,c), and the chi-square test statistic (χ2).

    df = (r - 1) * (c - 1)
    df = (r - 1) * (c - 1) = (2 - 1) * (3 - 1) = 2

    Er,c = (nr * nc) / n
    E1,1 = (100 * 100) / 300 = 10000/300 = 33.3
    E1,2 = (100 * 110) / 300 = 11000/300 = 36.7
    E1,3 = (100 * 90) / 300 = 9000/300 = 30.0
    E2,1 = (200 * 100) / 300 = 20000/300 = 66.7
    E2,2 = (200 * 110) / 300 = 22000/300 = 73.3
    E2,3 = (200 * 90) / 300 = 18000/300 = 60.0

    χ2 = Σ[ (Or,c - Er,c)2 / Er,c ]
    χ2 = (50 - 33.3)2/33.3 + (30 - 36.7)2/36.7 +
    (20 - 30)2/30 + (50 - 66.7)2/66.7 +
    (80 - 73.3)2/73.3 + (70 - 60)2/60
    χ2 = (16.7)2/33.3 + (-6.7)2/36.7 +
    (-10.0)2/30 + (-16.7)2/66.7 +
    (3.3)2/73.3 + (10)2/60
    χ2 = 8.38 + 1.22 + 3.33 + 4.18 + 0.61 + 1.67 = 19.39

    where df is the degrees of freedom, r is the number of populations, c is the number of levels of the categorical variable, nr is the number of observations from population r, nc is the number of observations from level c of the categorical variable, n is the number of observations in the sample, Er,c is the expected frequency count in population r for level c, and Or,c is the observed frequency count in population r for level c, and χ2 is the chi-square test statistic.

  4. Find the P-value. The P-value is the probability that a chi-square statistic having 2 degrees of freedom would be more extreme (bigger) than the test statistic of 19.39. We use the Chi-Square Distribution Calculator to find P(χ2 > 19.39) = 0.00006.
Chi-Square Calculator
  1. Interpret results. Since the P-value (0.00006) is less than the significance level (0.05), we reject the null hypothesis that the proportion of boys that prefer each program is the same as the proportion of girls.

Note: If you use this approach on an exam, you may also want to mention why this approach is appropriate. Specifically, the approach is appropriate because the sampling method was simple random sampling, the variable under study was categorical, and the expected frequency count was at least 5 in each population at each level of the categorical variable.