Introduction
Welcome to the final lesson in our module on the foundations of categorical data. In the last two lessons, you've learned how to identify a study's sampling scheme and use that to decide whether row or column percentages are appropriate for making comparisons. This was a critical first step in analyzing data from a contingency table.
Today, we'll build directly on that knowledge. The sampling scheme doesn't just guide our descriptive comparisons; it dictates the fundamental question we're trying to answer with our statistical test. Your goal in this lesson is to learn how to use the sampling scheme to formulate the correct null hypothesis—either a test of homogeneity or a test of independence.
Mastering this distinction is crucial for your exam. It's often the very first decision you need to make when faced with a contingency table problem. By the end of this lesson, you'll have a clear decision rule to confidently choose and state the correct hypothesis.
The Core Distinction: One Sample or Many?
The choice between a test of homogeneity and a test of independence boils down to a single question: How was the data collected? Specifically, did the researcher take one single sample and measure two variables, or did they take two or more separate samples and measure the same variable on all of them?
To see this distinction in action, let's watch a video that breaks it down with clear examples.
Which chi-square test? Goodness-of-fit, Homogeneity, Independence?
The following video, 'Which chi-square test?' from Vu Do Math, provides an excellent, concise explanation for how to distinguish a test of homogeneity from a test of independence based on the study's sampling design.
Please watch from 05:01 to 13:09. Pay close attention to: The key difference explained at 07:51: 'A test of homogeneity uses two or more samples. A test of independence uses one sample but two variables.' The meaning of 'homogeneity' (same proportions) explained around 08:31. The summary table presented at 10:35, which provides a great decision-making tool.
The video provides a powerful and easy-to-remember rule. Let's formalize it.
-
Test of Homogeneity: Used when you have two or more distinct populations (or groups) and you take a separate random sample from each one. You then compare the distribution of a single categorical variable across these populations.
- Sampling Scheme: This corresponds to the Product Multinomial sampling you learned about. The row or column totals are fixed in advance because you decided how many subjects to sample from each population.
- Research Question: Are the populations homogeneous (the same) with respect to the categorical variable?
-
Test of Independence: Used when you have one single population and you take a single random sample. You then measure two different categorical variables on each subject in the sample.
- Sampling Scheme: This corresponds to (Single) Multinomial Sampling. Only the grand total is fixed.
- Research Question: Are the two categorical variables independent (unrelated) within this population?
Here is a summary table to help you on your exam:
| Test Type | Number of Samples | Number of Variables Measured | Corresponding Sampling Scheme | Key Question |
|---|---|---|---|---|
| Homogeneity | Two or more | One | Product Multinomial | Are the distributions the same across groups? |
| Independence | One | Two | Single Multinomial | Are the two variables associated? |
Formulating the Null Hypothesis ()
Now that you can identify which test to use, let's look at how to formally state the null hypothesis for each.
1. Test of Homogeneity
The word "homogeneous" means "of the same kind." The null hypothesis for a test of homogeneity states that the probability distribution of the single categorical variable is the same across all the different populations.
This resource from Penn State's STAT 415 course provides a formal definition and a clear example of how to write the null hypothesis for a test of homogeneity.
First, read the introduction to the 'Test For Homogeneity' and Example 17-1. This sets up the idea of equal distributions. Then, focus on the formal hypothesis statement just below Example 17-2. Finally, review Example 17-3 to see the hypothesis stated for a different scenario (physicians vs. residents).
As you saw in the resource, the null hypothesis can be stated in two ways:
- In Words: : The distribution of [Categorical Variable] is the same across all populations.
- In Notation: for all categories .
- Here, is the number of populations (rows or columns) and is the proportion of population that falls into category .

Let's use an example from our previous lesson: The clinical trial comparing Aspirin and a Placebo.
- Setup: Researchers took two separate samples: 11,037 physicians for the aspirin group and 11,034 for the placebo group. This is Product Multinomial sampling.
- Test: Test of Homogeneity.
- Null Hypothesis ():
- In words: The distribution of cardiac outcomes (fatal attack, non-fatal attack, no attack) is the same for the physician population taking aspirin and the physician population taking a placebo.
2. Test of Independence
The null hypothesis for a test of independence states that the two categorical variables are not associated in the population. In statistical terms, they are independent.
Let's return to the Penn State resource to see how it defines the hypothesis for a test of independence, contrasting it with homogeneity.
Read the section '17.2 - Test for Independence,' focusing on 'The Sampling Schemes.' Note how it explicitly describes the 'one random sample' approach and then states the null hypothesis in terms of independence.
From the resource, and your basic probability knowledge, recall that two events A and B are independent if . This is the basis of our null hypothesis.
- In Words: : [Variable 1] and [Variable 2] are independent in the population.
- In Notation: for all categories and .
Let's use another example from our previous lesson: The survey of developers' OS and programming language preferences.
- Setup: A single random sample of 500 developers was surveyed and cross-classified on two variables: OS and Language. This is Single Multinomial sampling.
- Test: Test of Independence.
- Null Hypothesis ():
- In words: A developer's choice of operating system is independent of their primary programming language.
Worked Application
Let's consolidate this with a practice problem structured like one you might see on your exam.
Problem:
Researchers are interested in the effectiveness of a new antidepressant. They recruit 150 volunteers diagnosed with depression. 75 are randomly assigned to receive the new drug, and 75 are assigned a placebo. After 3 months, each volunteer's condition is assessed as 'Improved', 'No Change', or 'Worsened'.
Task: State the appropriate null hypothesis for this study, both in words and in notation.
Solution:
-
Identify the Sampling Scheme: The researchers created two groups (Drug, Placebo) with fixed sizes (75 each) before observing the outcome. This is Product Multinomial Sampling.
-
Identify the Test: Since we have two distinct samples from two populations (those receiving the drug, those receiving the placebo), we must use a Test of Homogeneity.
-
Formulate the Hypothesis:
- In Words: The distribution of patient outcomes (Improved, No Change, Worsened) is the same for the group receiving the new drug and the group receiving the placebo.
- In Notation: Let be the proportion of the drug group in outcome category , and be the proportion of the placebo group in outcome category . This is equivalent to stating that the vector of proportions for the drug group is equal to the vector of proportions for the placebo group.
Conclusion
You have now completed the foundational module for analyzing categorical data. You've connected the study design to the data presentation (row/column percentages) and, most importantly, to the core hypothesis being tested.
Key Takeaways:
- The Decision Rule: The sampling scheme is everything.
- Two or more samples (Product Multinomial) Test of Homogeneity. The null hypothesis is that the distribution of one variable is the same across different populations.
- One sample (Single Multinomial) Test of Independence. The null hypothesis is that two variables are independent within a single population.
- Keywords: For homogeneity, think "same," "equal distributions." For independence, think "no association," "unrelated."
In our next lesson, we will begin Module 2 by learning how to quantify the evidence against these null hypotheses. You will learn to compute the Pearson chi-square statistic, which measures the discrepancy between what you observed in your data and what you would expect to see if the null hypothesis were true.