Tutorials › AP Statistics › Setup and Plan for a Chi-Square Test

Chi-square tests for categorical data · Tutorial 559 of 1000

Setup and Plan for a Chi-Square Test

Practice building a complete chi-square test setup by matching the study design to the hypotheses, procedure, and condition checks.

Intermediate 9 min read

What You'll Learn

  • Define the population and categorical variables in the State step.
  • Match independence or homogeneity hypotheses to the way the data were collected.
  • Name the appropriate chi-square procedure in the Plan step.
  • Check randomness, independence, the 10% condition when relevant, and expected counts.
  • Use a complete example to connect the setup to the later test calculation and conclusion.

Build the State and Plan Before Calculating

In “Common Mistakes in Choosing and Stating Chi-Square Tests,” you learned to audit a test choice and its hypotheses. Here, the goal is to turn that knowledge into a clear State and Plan: identify the population question, name the procedure, and justify that the conditions are met. A strong setup makes it clear what the test will evaluate before any test statistic or p-value is calculated.

The design determines the procedure. One sample classified by two categorical variables calls for a chi-square test of independence when the question asks whether the variables are associated. Separate samples or treatment groups compared on one categorical response call for a chi-square test of homogeneity when the question asks whether the response distribution differs among groups. These choices were developed in “Choosing the Chi-Square Test From a Study Description” and “Independence Versus Homogeneity: Choosing the Right Test.”

Key idea: In the State step, say what population question the study addresses and state hypotheses that match that question. In the Plan step, name the chi-square test and check its conditions using details of the study and the expected counts under the null hypothesis.

What to Include in State and Plan

A useful State step has two parts: define the relevant population and categorical variable or variables, then state the null and alternative hypotheses in context. For independence, the null says that the two variables are independent in the population; the alternative says they are associated. For homogeneity, the null says that one categorical response has the same distribution across the groups or populations; the alternative says that at least one distribution differs. As covered in “Stating Hypotheses for a Test of Independence” and “Stating Hypotheses for a Test of Homogeneity,” these hypotheses are about population patterns, not just the sample counts.

In the Plan step, state the procedure by its full name. Then address the conditions: an appropriate random sample or randomized experiment; independent observations, with the 10% condition checked for sampling without replacement from a finite population; and sufficiently large expected counts. For a chi-square test of independence or homogeneity, every expected cell count must be at least 5.

Expected counts are calculated assuming the null hypothesis is true. For a two-way table, the expected count in a cell is its row total multiplied by its column total, divided by the grand total. You do not need to calculate the chi-square statistic in order to plan the procedure, but you do need enough information to check the expected-count condition. If even one expected count is below 5, the usual chi-square procedure’s condition is not met.

Plan checklist: Name the test; describe the evidence for random sampling or random assignment; address independence and the 10% condition if sampling without replacement; and verify that every expected count is at least 5.

The 10% condition and the expected-count condition answer different questions. The 10% condition concerns dependence that can arise when sampling without replacement from a finite population. Expected counts concern whether the chi-square procedure is appropriate under the null model. Do not treat one check as a substitute for the other.

A Reliable Order for Writing the Setup

Use the following sequence to keep the design, hypotheses, and conditions aligned. The population and variables in State should match the study description; the procedure in Plan should match that design; and the conditions should be supported by facts or clearly stated assumptions.

1
Describe the population question.
Name the population or groups and the categorical response or variables being studied.
2
Write the hypotheses.
Use independence versus association for one sample classified twice, or same distribution versus at least one different distribution for separate groups.
3
Name the procedure.
Choose a chi-square test of independence or a chi-square test of homogeneity according to the study design and question.
4
Check conditions explicitly.
Refer to the sampling or assignment method, explain why observations are independent, check the 10% condition when applicable, and show that expected counts are all at least 5.

Worked Example: A Full Setup and Test of Independence

Worked Example: A Full Setup and Test of Independence

A fictional public library selects a random sample of 240 adult cardholders. Each person is classified by age group (18–39, 40–59, or 60 and older) and preferred event format (in-person or online). The library wants to know whether age group and preferred format are associated among its adult cardholders. The observed counts are:

Age groupIn-personOnlineTotal
18–39503080
40–59404080
60 and older305080
Total120120240

State. The population is all adult cardholders at this library. The two categorical variables are age group and preferred event format. \(H_0\): Age group and preferred event format are independent among the library’s adult cardholders. \(H_a\): Age group and preferred event format are associated among the library’s adult cardholders.

Plan. This is one random sample in which each cardholder is classified by two categorical variables, and the question is whether those variables are associated. Use a chi-square test of independence.

The random condition is met because the library selected a random sample. Each person contributes one classification for each variable, and the sample contains distinct cardholders, so treating the observations as independent is reasonable. Because the sample was selected without replacement, check the 10% condition: the population must contain at least \(10(240)=2{,}400\) adult cardholders. Assume the library has at least that many.

Check expected counts under \(H_0\). For example, the expected count for ages 18–39 who prefer in-person events is:

$$ E=\frac{(\text{row total})(\text{column total})}{\text{grand total}} =\frac{80(120)}{240}=40 $$

Each row total is 80, and each column total is 120, so all six expected counts are 40. They are all at least 5. The conditions for the chi-square test of independence are met.

Do. The deviations of the observed counts from their expected counts are \(10,-10,0,0,-10,10\). Thus the chi-square statistic is:

$$ X^2=\frac{10^2}{40}+\frac{(-10)^2}{40} +\frac{0^2}{40}+\frac{0^2}{40} +\frac{(-10)^2}{40}+\frac{10^2}{40} =10 $$

There are three age groups and two event formats, so \(df=(3-1)(2-1)=2\). The upper-tail p-value is \(P(\chi^2\ge10)\approx0.0067\), rounded. This value can also be checked using the upper-tail probability for a chi-square distribution with 2 degrees of freedom.

Conclude. At the 0.05 significance level, \(0.0067<0.05\), so reject \(H_0\). The sample provides convincing evidence that age group and preferred event format are associated among the library’s adult cardholders.

Notice how the setup is justified before the calculation begins: the one-sample design identifies independence as the procedure, and the population hypotheses describe the association the test evaluates. The sample table alone would not be enough to choose the test; the study design supplies that information.

Worked Example: Plan a Test of Homogeneity

Worked Example: Plan a Test of Homogeneity

A fictional recreation department takes separate random samples of 90 registered users at each of three community centers. Each person names a preferred workshop time: morning, afternoon, or evening. The department asks whether the distribution of preferred time is the same at all three centers.

CenterMorningAfternoonEveningTotal
East40302090
West25353090
Central25254090
Total909090270

State. The populations are the registered users at the East, West, and Central centers. The response is preferred workshop time. \(H_0\): The distribution of preferred workshop time is the same at all three centers. \(H_a\): At least one center has a different distribution of preferred workshop time.

Plan. The department has separate random samples from three groups and measures one categorical response in each group. Use a chi-square test of homogeneity. Each sample was randomly selected, and the samples are independent because they come from separate center populations; assume no person is included in more than one sample. Since sampling is without replacement, the 10% condition requires at least 900 registered users in each center population; assume this is true.

For each center, the expected count in each response category is \(90(90)/270=30\). Therefore, all nine expected counts are 30, meeting the requirement that every expected count be at least 5. There are three groups and three response categories, so \(df=(3-1)(3-1)=4\) when the test statistic is later evaluated.

The hypotheses use “same distribution” and “at least one differs” because this design compares separate groups on one response. Calling this a test of independence would not match how the data were collected, even though the counts can be arranged in a two-way table.

Worked Example: Plan for a Randomized Experiment

Worked Example: Plan for a Randomized Experiment

A fictional software team randomly assigns 240 volunteers equally to test three versions of a sign-up page. Each volunteer is recorded as either completing or not completing the sign-up. The observed counts are:

Page versionCompletedDid not completeTotal
A522880
B423880
C354580
Total129111240

State. The response is sign-up completion, and the groups are the three page versions. \(H_0\): The distribution of sign-up completion is the same for all three page versions. \(H_a\): At least one page version has a different distribution of sign-up completion.

Plan. This is a randomized experiment comparing one categorical response across three treatment groups, so use a chi-square test of homogeneity. The random condition is met by the stated random assignment. Each volunteer contributes one outcome, and it is reasonable to treat volunteers’ outcomes as independent if they complete the task individually without influencing one another.

The 10% condition is for random sampling without replacement from a finite population; it is not the relevant check here because volunteers were randomly assigned to page versions rather than selected as a sample from that population. Instead, justify independence from the experiment’s setup. Under the null hypothesis, the expected count of completions in each group is \(80(129)/240=43\), and the expected count of non-completions is \(80(111)/240=37\). All six expected counts are at least 5. The plan’s conditions are met.

With three page versions and two outcome categories, the degrees of freedom for the later test calculation will be \((3-1)(2-1)=2\). Because the treatment was randomly assigned, a test result can provide evidence about differences in outcomes among the page versions in this experiment.

Common Mistakes and What a Full-Credit Setup Says

  • Naming a test without connecting it to the design: State whether there is one sample classified by two variables or separate groups compared on one response. Then name the matching test.
  • Writing hypotheses about the sample rather than the population: Hypotheses concern the population relationship or group distributions. Avoid statements such as “the counts are equal in this table.”
  • Leaving the condition checks vague: “The conditions are met” does not show why. Identify the random sample or assignment, explain independence, address the 10% condition when appropriate, and report the expected counts or their minimum.
  • Checking observed counts instead of expected counts: The chi-square count condition is about expected counts under the null hypothesis. Use the row totals, column totals, and grand total to calculate them.
  • Applying the 10% condition to every design: Explain when it applies: sampling without replacement from a finite population. A randomized experiment requires attention to random assignment and independence, but not a 10% check merely because the sample has a particular size.
  • Using directional hypotheses: For these chi-square tests, the alternative is association or a difference in distributions, not a claim that one named category is higher or lower. The test evaluates departure from the null pattern across the table.
AP Exam Tip: A full-credit State and Plan is specific enough that another reader can identify the population question, see why the named chi-square procedure fits, and verify every condition from the information given. If a population size or design detail is not supplied, state the assumption needed rather than silently claiming the condition is satisfied.
Key takeaway: Write the State and Plan as one connected argument: define the population question, choose hypotheses that match the study design, name the corresponding chi-square test, and justify randomness, independence, the 10% condition when relevant, and expected counts.

Check Your Understanding

For each situation, write or evaluate the State and Plan elements. Include the relevant condition checks.

  1. A random sample of residents is classified by housing type and preferred emergency-alert method. What test is appropriate, and how should the hypotheses be stated?
  2. Separate random samples from four campuses are asked to choose one of three lunch options. State the homogeneity hypotheses and identify the procedure.
  3. A random sample of 150 customers is selected without replacement. What minimum population size satisfies the 10% condition?
  4. A two-way table has expected counts of 4, 12, 18, and 26. Is the expected-count condition met? Explain.
  5. In a randomized experiment, participants are assigned to two app designs and classified by whether they finish setup. Which condition checks apply, and why is the 10% condition not the relevant check?