From a Survey Table to a Test of Independence
In “Chi-Square Test With a Random Experiment,” the design involved randomly assigned treatment groups and a categorical outcome. This tutorial turns to a different design: one random sample in which each person is classified by two categorical variables. A chi-square test of independence uses the resulting two-way table to assess whether those variables are associated in the population.
A survey can reveal evidence of an association, but it does not generally show that one variable caused the other. For instance, if age group and preferred source of local news are associated in a sample, that does not establish that age causes a particular news preference. The test answers a question about evidence of association; the observational survey design limits what we can claim beyond that.
The Four Steps for a Survey Test
The study design determines the procedure. Here, researchers take one sample and record two categorical variables for every individual, so a chi-square test of independence is appropriate. In contrast, a test of homogeneity compares the distribution of one categorical response across separate samples or groups.
As in “Stating Hypotheses for a Test of Independence,” write the hypotheses about the population and define both variables. The null hypothesis is that the variables are independent. The alternative is that they are associated. Neither hypothesis says that the observed sample table must have identical percentages in every row; random variation can create differences even when the population variables are independent.
Under the null model of independence, expected counts are calculated from the table margins. For each cell, multiply its row total by its column total and divide by the grand total. The chi-square statistic adds the cell contributions \((O-E)^2/E\), where \(O\) is the observed count and \(E\) is the expected count.
The test’s degrees of freedom are \((r-1)(c-1)\), where \(r\) and \(c\) are the numbers of row and column categories. Its p-value is the upper-tail probability for the observed chi-square statistic and those degrees of freedom, assuming the null hypothesis is true. The expected-count condition requires every expected count to be at least 5.
Identify the population and the two categorical variables. State independence as \(H_0\) and association as \(H_a\), in context.
Name a chi-square test of independence. Check random sampling, independence of observations, the 10% condition when sampling without replacement, and the expected-count condition.
Calculate expected counts, \(X^2\), degrees of freedom, and the upper-tail p-value.
Compare the p-value with the significance level and describe the evidence about association between the variables in the population.
Worked Examples: Survey Data and Association
Worked Example: Age Group and Local News Source
Suppose a municipality randomly selects 240 adult residents for a survey. Each person reports an age group and their primary source for local news. The municipality has 18,000 adult residents. The following invented counts summarize the responses:
| Age group | App | Radio | Total | |
|---|---|---|---|---|
| 18–39 | 55 | 35 | 30 | 120 |
| 40 and older | 25 | 45 | 50 | 120 |
| Total | 80 | 80 | 80 | 240 |
State. The population is the adult residents of this municipality. The two variables are age group and primary source of local news. \(H_0\): age group and primary news source are independent among the municipality’s adult residents. \(H_a\): age group and primary news source are associated among those residents.
Plan. Use a chi-square test of independence because one sample of residents is classified by two categorical variables. The residents were randomly selected, satisfying the random condition. Each resident contributes once to one cell, and the sample is only \(240/18{,}000=0.0133\), or about 1.33%, of the adult population. Thus \(240\leq0.10(18{,}000)=1{,}800\), so the 10% condition is met. Expected counts will be checked below.
Do. The row totals are 120, each column total is 80, and the grand total is 240. For example, the expected count in the 18–39 and app cell is \(120(80)/240=40\). The same calculation applies to every cell, so all six expected counts are 40, meeting the Large Counts condition.
The observed counts differ from their expected counts by \(15,-5,-10\) in the first row and \(-15,5,10\) in the second. Therefore:
There are \(r=2\) rows and \(c=3\) columns, so \(df=(2-1)(3-1)=2\). The upper-tail p-value is approximately \(0.0002\), rounded to four decimal places.
Conclude. At \(\alpha=0.05\), \(0.0002<0.05\), so reject \(H_0\). The survey provides convincing evidence that age group and primary source of local news are associated among the municipality’s adult residents. Because this is a survey rather than a randomized experiment, the results do not show that age group causes people to choose a particular news source. The sample also does not identify which specific differences are independently significant; the test assesses the overall table.
Worked Example: Travel Mode and Preferred Commute Time
Suppose a random sample of 180 residents is asked about their usual travel mode to work and whether they prefer an earlier, middle, or later commute time. The adult population from which the sample is selected is 9,000. These invented counts are recorded:
| Usual travel mode | Earlier | Middle | Later | Total |
|---|---|---|---|---|
| Public transit | 35 | 28 | 27 | 90 |
| Car | 25 | 32 | 33 | 90 |
| Total | 60 | 60 | 60 | 180 |
State. The population is the adult residents represented by the sample. \(H_0\): usual travel mode and preferred commute time are independent in this population. \(H_a\): usual travel mode and preferred commute time are associated.
Plan. A chi-square test of independence fits because one sample is classified by two categorical variables. The sample was randomly selected. Each resident gives one response to each variable and appears in one table cell. The 10% check is \(180\leq0.10(9{,}000)=900\), so it is met. Every expected count is \(90(60)/180=30\), which is at least 5.
Do. The expected count is 30 in each of the six cells. The differences between observed and expected counts are \(5,-2,-3\) in the first row and \(-5,2,3\) in the second. Thus:
The degrees of freedom are \((2-1)(3-1)=2\), and the upper-tail p-value is approximately \(0.2817\), rounded to four decimal places.
Conclude. At \(\alpha=0.05\), \(0.2817>0.05\), so fail to reject \(H_0\). The sample does not provide convincing evidence of an association between usual travel mode and preferred commute time in the population. This does not prove that the variables are independent; it means the observed differences do not provide strong evidence against independence.
Worked Example: Recycling Access and Familiarity
Suppose a random sample of 200 residents is asked whether their home has convenient recycling access and whether they are familiar with the local recycling guidelines. Each variable has two categories. The adult population is 12,000. The following invented counts are obtained:
| Recycling access | Familiar | Not familiar | Total |
|---|---|---|---|
| Convenient | 58 | 42 | 100 |
| Not convenient | 42 | 58 | 100 |
| Total | 100 | 100 | 200 |
State. The population is the adult residents represented by the sample. \(H_0\): recycling access and familiarity with the guidelines are independent in this population. \(H_a\): recycling access and familiarity are associated.
Plan. Use a chi-square test of independence because one sample is classified by two categorical variables. The sample is random, and each person is counted once. The 10% condition is satisfied because \(200\leq0.10(12{,}000)=1{,}200\). Each expected count is \(100(100)/200=50\), so the expected-count condition is met.
Do. Each observed count differs from its expected count of 50 by 8 in absolute value. Therefore:
The degrees of freedom are \((2-1)(2-1)=1\). The upper-tail p-value is approximately \(0.0236\), rounded to four decimal places.
Conclude. At \(\alpha=0.05\), \(0.0236<0.05\), so reject \(H_0\). The survey provides convincing evidence that convenient recycling access and familiarity with the guidelines are associated among the adult residents represented by the sample. The data do not establish that access causes familiarity: other factors could be related to both.
Common Mistakes and AP Exam Tip
- Choosing the test from the table’s appearance alone: A two-way table can be used for different chi-square procedures. One sample classified by two variables calls for a test of independence; separate groups compared on one response call for homogeneity.
- Writing hypotheses about the sample: The hypotheses are claims about the population variables, not about whether the sample percentages look exactly equal. Define both variables and the population, then state independence versus association.
- Forgetting a condition: Explicitly address random sampling, independent observations, the 10% condition when sampling without replacement, and every expected count. Do not check the expected-count condition using observed counts.
- Interpreting a large p-value as proof of independence: “Fail to reject” means the data do not provide convincing evidence of an association. It does not prove that there is no association.
- Claiming causation from a survey: A random sample can support generalizing results to its population, but it does not create random assignment. An observed association does not establish a cause-and-effect relationship.
- Claiming a particular cell difference is significant from the overall test: A significant chi-square result indicates an overall departure from independence. It does not, by itself, identify which cells or category comparisons account for that result.
For full-credit communication, name the test, give the decision, and state what the evidence says about the two variables in the population. For a survey, distinguish generalization supported by random sampling from causal conclusions, which the survey design does not establish.
Check Your Understanding
Use the study design, hypotheses, conditions, and conclusion wording in your answers.
- A random sample of residents is classified by neighborhood and preferred park activity. Which chi-square procedure fits, and what does its null hypothesis say?
- A sample of 300 is taken without replacement from a population of 2,500. Is the 10% condition met? Show the comparison.
- A test of independence has \(r=3\) row categories and \(c=4\) column categories. Find its degrees of freedom.
- A test has \(p=0.18\) and \(\alpha=0.05\). State the decision and explain what it means in context, without claiming the variables are proven independent.
- Why can a random survey support generalization to a population but still not establish that one categorical variable causes the other?