Skip to main content

3.15 Carrying Out a Chi-Square Test for Homogeneity or Independence

add to ChatGPT
Verified for the 2027 examUpdated October 2026Fiveable Content Team
Fiveable

📊AP Statistics Unit 3 Review

QR code for AP Statistics practice questions

3.15 Carrying Out a Chi-Square Test for Homogeneity or Independence

Carrying out a chi-square test for homogeneity or independence means calculating the chi-square statistic from observed and expected counts, finding the p-value using the right degrees of freedom, and stating a conclusion in context. You compare the p-value to your significance level to decide whether to reject the null hypothesis, and you never "accept" anything.

Once the hypotheses and conditions from the earlier Unit 3 setup work are in place, this is the step where you compute the statistic and reach a conclusion. Clear notation and context in that work make your reasoning easy to follow, which matters for full credit on free-response questions.

Computing the Chi-Square Statistic and Reaching a Conclusion

  • The test statistic is χ2=∑(O−E)2E\chi^2 = \sum \frac{(O-E)^2}{E}, summed over every cell in the two-way table.
  • Degrees of freedom equal (number of rows - 1)(number of columns - 1).
  • The p-value is the probability of getting a chi-square statistic as large or larger than yours, assuming the null hypothesis is true. It is right-tailed.
  • Compare the p-value to your significance level α\alpha: if it is smaller, reject the null; if not, fail to reject.
  • Write conclusions with nondeterministic language. Never say you "accept" the null or that there is "no association."
  • Always tie your conclusion back to context, naming the variables or populations from the question.

The Chi-Square Statistic

After choosing the correct test, checking conditions, and writing your hypotheses, you carry out the test. Like the goodness-of-fit test, this has two main numerical pieces: the chi-square statistic and the p-value.

The chi-square statistic compares the observed counts in your contingency table to the expected counts, which come from assuming the null hypothesis is true. For each cell, the expected count is:

expected count=(row total)(column total)table total\text{expected count}=\frac{(\text{row total})(\text{column total})}{\text{table total}}

Once you have the expected counts, the chi-square statistic formula is:

χ2=∑(O−E)2E{\chi}^2=\sum\frac{(O-E)^2}{E}

where OO is the observed count and EE is the expected count. You sum this across all cells in the table.

This formula is on the formula sheet provided for the exam. In practice, a graphing calculator computes the statistic for you once you enter the observed counts as a matrix, but you should still understand what the formula is doing: measuring how far observed counts fall from expected counts, relative to the expected counts.

Degrees of Freedom

Find degrees of freedom by subtracting 1 from the number of rows, subtracting 1 from the number of columns, and multiplying those results:

(number of rows - 1)(number of columns - 1)

For a table with 3 rows and 4 columns:

  • Rows: 3 - 1 = 2
  • Columns: 4 - 1 = 3
  • Degrees of freedom: 2 * 3 = 6

So a 3-by-4 table has 6 degrees of freedom.

Finding the P-Value

Once you have the chi-square statistic, find the p-value: the probability of getting a chi-square value at least as extreme as yours, assuming the null hypothesis is true. The chi-square test is right-tailed, so the p-value is the proportion of the chi-square distribution (with your degrees of freedom) that is at or above your test statistic.

You can get the p-value from a chi-square table or from technology. If you use a calculator to run the test, write down both the chi-square value and the p-value from the output so your work is clear.

Drawing a Conclusion

As with hypothesis tests in earlier units, compare your p-value to a given α\alpha:

  • If the p-value is less than α\alpha, reject H0H_0. You have convincing evidence for HaH_a.
  • If the p-value is greater than α\alpha, fail to reject H0H_0. You do not have convincing evidence for HaH_a.

Two reminders:

  1. Never "accept" anything.
  2. Include context.

Example conclusion: "Since our p-value (about 0) is less than 0.05, we reject the null hypothesis. We have convincing evidence that there is an association between the two variables in the population of interest."

Conclusion Template

  • First part: "Since our (p-value) is less than / greater than 0.05, we reject / fail to reject our null."
  • Second part, test for independence: "We have / do not have convincing evidence that there is an association between variable x and variable y in our intended population."
  • Second part, test for homogeneity: "We have / do not have convincing evidence that the distribution of categorical variable x is different across population x and population y."

Reporting Chi-Square Output and Writing the Conclusion

Problem Solving:

  • Enter your observed counts into a matrix and run the chi-square test on your calculator, then record both the chi-square statistic and the p-value.
  • Show the degrees of freedom using (rows - 1)(columns - 1) so a reader can follow your setup.
  • Remember the test is right-tailed, so a larger chi-square statistic means a smaller p-value.

Free Response:

  • State your conclusion in two parts: the reject / fail to reject decision linked to the p-value, then the meaning in context.
  • Name the actual variables or populations from the prompt instead of writing "variable x" and "variable y."
  • Use nondeterministic language. For a large p-value, say there is not enough evidence of an association or difference, not that the variables are independent or identical.

Common Trap:

  • Mixing up homogeneity and independence in your conclusion. Independence talks about an association between two variables in one population. Homogeneity talks about whether a distribution is the same across different populations or treatments.

Common Misconceptions

  • Misconception: A large p-value proves the variables are independent.
    Actually: It does not. You can only say there is not enough evidence of an association. Failing to reject is not the same as accepting the null.
  • Misconception: I can use observed counts to check the large counts condition.
    Actually: The condition is about expected counts. All expected counts should be at least 5.
  • Misconception: Degrees of freedom is the sample size minus 1.
    Actually: For a two-way table, it is (rows - 1)(columns - 1), not based on sample size.
  • Misconception: The chi-square test can be two-tailed.
    Actually: The chi-square test for two-way tables is right-tailed. The p-value always comes from the upper tail.
  • Misconception: Independence and homogeneity are the same test with the same conclusion.
    Actually: They use the same statistic and formula, but the hypotheses and the way you describe the result differ, since independence involves one population and homogeneity compares groups.

Practice Questions for 3.15

1 of 10

The segmented bar chart above displays the distribution of a categorical variable across four different populations.

A chi-square test for homogeneity is performed on the count data used to create the chart. How does the theoretical chi-square distribution for this test compare to the distribution for a test based on a 2-by-2 table?

A.

The distribution for this test has less right skew because it has more degrees of freedom.

B.

The distribution for this test has more right skew because it has fewer degrees of freedom.

C.

The distribution for this test has more right skew because it has more degrees of freedom.

D.

The distribution for this test has less right skew because it has fewer degrees of freedom.

Vocabulary

The following words are mentioned explicitly in the AP® course framework for this topic.

Term

Definition

categorical data

Data that represents categories or groups rather than numerical measurements, such as colors, types, or classifications.

chi-square distribution

A probability distribution used in chi-square tests, characterized by degrees of freedom and used to determine p-values for test statistics.

chi-square distributions

Probability distributions used to test the goodness of fit between observed and expected categorical data, characterized by positive values and right skewness.

chi-square statistic

A test statistic that measures the distance between observed and expected counts relative to the expected counts.

chi-square test for homogeneity

A statistical test used to determine whether the distributions of a categorical variable are the same across different populations or treatments.

chi-square test for independence

A statistical test used to determine whether two categorical variables in a population are associated or independent.

degrees of freedom

A parameter of the t-distribution that affects its shape; as degrees of freedom increase, the t-distribution approaches the normal distribution.

expected count

The theoretical frequency in each cell of a contingency table that would be expected if the null hypothesis of independence or homogeneity were true.

null hypothesis

The initial claim or assumption being tested in a hypothesis test, typically stating that there is no effect or no difference.

observed count

The actual frequency or number of observations in each cell of a contingency table from the collected data.

p-value

The probability of observing a test statistic as extreme as or more extreme than the one calculated from the sample data, assuming the null hypothesis is true.

probability model

A mathematical framework that describes the probability distribution of outcomes under specified assumptions.

reject the null hypothesis

The decision made when the p-value is less than or equal to the significance level, indicating sufficient evidence against the null hypothesis.

research question

The specific question about a population or populations that a statistical test is designed to answer.

significance level

The threshold probability (α) used to determine whether to reject the null hypothesis in a significance test.

test statistic

A calculated value used to determine whether to reject the null hypothesis in a hypothesis test, computed from sample data.

two-way table

A table that displays the frequency distribution of two categorical variables, organized in rows and columns.

See Fiveable more often in Google

Mark Fiveable as a preferred source and Google is more likely to show you our guides in Top Stories, with a "preferred" badge in AI Mode and AI Overviews.

Prefer us on Google