1. Choose the test before calculating
Suppose a library wants to know whether borrowers choose its three pickup points in a planned split. Count one categorical variable and compare it with stated probabilities: use goodness of fit. If the library instead records both pickup point and membership type for each borrower, ask whether two categorical variables are associated: use independence.
Use counts, not percentages, and assign each independent observation to exactly one category or one cell. In both tests compare observed counts with expected counts under :
The square treats excesses and shortfalls alike. Dividing by means a gap of five counts does not have the same weight in a cell expected to have ten as in one expected to have a hundred. Large values count against , so use the right tail. The p-value is the probability, under and the test assumptions, of a statistic at least as large as the observed one. It is not the probability that is true.
2. Worked example: compare counts with a planned split
A workshop offered three pickup days and planned for . In a random sample of independent orders, the counts were . At , do the data disagree with the plan?
- Under , the three population probabilities are those specified in the plan. The alternative is that at least one differs.
- Multiply the sample size by each probability: . Check that these counts sum to . None is small.
- Compute There are degrees of freedom because the three counts share a fixed total and no probabilities were fitted from the sample.
- The right-tail p-value is about . Reject at . The sample provides evidence against the stated split. The first category contributes , the most of the three, but the overall test does not separately establish which probabilities differ.
3. Worked example: are pickup choice and membership related?
For independently sampled borrowers, record membership and weekday versus weekend pickup. In the table, parentheses show the expected counts under independence.
| Membership | Weekday | Weekend | Total |
|---|---|---|---|
| Individual | 36 (30) | 14 (20) | 50 |
| Family | 24 (30) | 26 (20) | 50 |
| Total | 60 | 40 | 100 |
- Under , the pickup proportions are the same for the two membership types in the population. Under the alternative, they are not.
- Each row has people; of the picked a weekday. Under independence the first expected count is . In general, use the row total times the column total divided by the grand total. The expected counts preserve both margins.
- Sum the four contributions: The degrees of freedom are . Once the row and column totals and one cell are fixed, the other cells are determined.
- The right-tail p-value is about . At , there is evidence of association in the population represented by this sample. In the sample, weekday pickup is versus . This comparison describes the direction; it does not establish that membership causes the choice.
4. Worked example: when the approximation is not reliable
A mailroom expects of packages to fall in three weight bands. In independent packages it observes . The expected counts are . The arithmetic formula gives a statistic, but two low expected counts make the usual chi-square approximation questionable. Do not use a standard chi-square table as if the assumptions held. For this specified model, a simulation can repeatedly draw packages under the stated probabilities and compare the simulated statistics with the observed one.
As a conservative classroom rule, check that each expected count is at least five; follow your course’s convention. Which threshold to use depends on the design and test. Do not remove a cell because its observed count is zero or pool categories after seeing which gives a preferred conclusion. For a sparse table, Fisher’s exact test can be an option when appropriate to the sampling design. Repeated observations on the same person are a separate problem not fixed by larger counts. If goodness-of-fit probabilities were estimated from the data, the simple rule used here may not apply; verify the test and degrees of freedom for the fitted model.
Six practice exercises
1. Identify the test
An instructor compares counts for multiple-choice responses with probabilities stated before sampling. She then asks whether the response category is related to which of two course sections the student attends. Which test answers each question?
Show a hint
Count how many categorical variables are recorded per observation.
Show the explained solution
The first question concerns one response distribution and prescribed probabilities: goodness of fit. The second tests association between response category and course group: independence, assuming a joint sample of independent students. With group sample sizes fixed by design, the related test is called homogeneity.
2. Find expectations and degrees of freedom
An expected distribution for observations is . Observed counts are . Find the expected counts, degrees of freedom and the statistic.
Show a hint
Check that the expected counts sum to the sample size.
Show the explained solution
The expectations are . The differences are . Therefore , with degrees of freedom.
3. Make a decision from the right tail
With three equally probable categories and independent observations, the counts are . Compute the statistic and decide at and . The right-tail cutoffs for two degrees of freedom are and , respectively.
Show a hint
Reject only if the test statistic exceeds the specified cutoff.
Show the explained solution
The expected count in each category is . The statistic is . Reject at , but not at . In fact, the p-value is about ; the data give the same p-value for both decisions.
4. Check an independence table
A sample of independent students records whether they prefer morning or afternoon review and whether they come by bus or otherwise. The two rows of counts are and . Find all expected counts and decide at ; the one-degree cutoff is .
Show a hint
Both row totals and both column totals are equal.
Show the explained solution
Each expectation is . For one degree of freedom, . Do not reject at ; there is insufficient evidence of association, not proof of independence.
5. Challenge the small-count shortcut
In an independent sample of days, a model predicts for two event types. The observed counts are . Can the observed count of eight rescue the usual chi-square approximation?
Show a hint
Apply the small-count check under the null, not to the observed counts.
Show the explained solution
No. Expected counts are . Here the count of the rarer event under the null has an exact binomial model with and . Use an exact procedure matched to the alternative instead of trusting the approximate chi-square p-value.
6. Compare the test with the story
The library example has . A friend says, “There’s about a one-in-seventy chance the variables are independent, and membership changes behaviour.” Fix both claims.
Show a hint
Identify the assumption used to calculate the p-value and what the sampling design permits.
Show the explained solution
Assuming independence and the test conditions, a chi-square statistic at least as large as the observed one occurs with probability about 1.43%. This is evidence against independence, not a probability of the hypothesis. Observing an association does not establish causality.
The UQAM MAT2082 course description includes chi-square tests. These are original practice problems, not an official exam. Follow the conventions taught in your course.
Useful for
Work on the step you’re missing.
Tell us the subject and your preferred time. Nablio confirms the details by text or email.
Request a lesson