10.8 Lab 2: Chi-Square Test of Independence
SLO 4
Demonstrate an understanding of, and ability to use, basic ideas of statistical processes, including hypothesis tests and confidence interval estimation.
SLO 5
Identify appropriate statistical techniques and use technology-based statistical analysis to describe, interpret, and communicate results.
Learning Objectives
By the end of this lab, you will be able to:
- collect categorical data from your own class and organize it into a contingency table;
- judge by eye whether two factors look dependent, then test that impression formally;
- run a chi-square test of independence on data you gathered, including checking and repairing the expected-count condition;
- compare your formal conclusion against your initial impression and explain any disagreement.
Lab 1 tested one variable against a claimed distribution. This one tests two variables against each other, using the class itself as the sample. That makes the expected-count condition much harder to satisfy than it looked in Section 10.3, where every table arrived with hundreds of subjects already in it. A class of thirty people spread across two rows and four columns leaves very little in each cell, and dealing with that honestly is most of the work here.
10.8.1 Student Learning Outcome
The student will evaluate if there is a significant relationship between favorite type of snack and gender.
Before collecting anything, decide which of the three chi-square tests this lab calls for. Use the two questions from Section 10.5: how many populations are being sampled, and how many questions are being asked of each person?
Solution — classifying the design
Step 1 — Count the populations sampled. One: the class. Nobody drew two separate samples of fixed size.
Step 2 — Count the questions asked of each person. Two: favorite snack, and gender.
Step 3 — Match against the three designs. One population and two questions is a test of independence, and the data form a contingency table.
Step 4 — Confirm against the alternative. It is not homogeneity, because the row totals were not fixed in advance — how many men and women are in the class is a fact about the class, not a design choice.
Answer: A test of independence. One population, two questions, and row totals produced by the data rather than chosen by the researcher.
10.8.2 Collect the Data
- Using your class as a sample, complete Table 10.8.1. Ask each other what your favorite snack is, then total the results.
Every cell needs an expected value of at least five. With a class-sized sample spread over four snack categories and two rows, at least one cell will very likely fall short — this is the normal outcome here, not a sign that something went wrong. Combine adjacent categories until every expected count reaches five, and remember that each merge costs a column and therefore one degree of freedom.
| sweets (candy & baked goods) | ice cream | chips & pretzels | fruits & vegetables | Total | |
|---|---|---|---|---|---|
| men | |||||
| women | |||||
| Total |
- Looking at Table 10.8.1, does it appear to you that there is a dependence between gender and favorite type of snack food? Why or why not?
A class of 32 students records the counts in Table 10.8.2. Compute all the row totals, column totals and the grand total, then find the expected count for the men/ice cream cell.
| sweets | ice cream | chips & pretzels | fruits & vegetables | |
|---|---|---|---|---|
| men | 4 | 5 | 7 | 2 |
| women | 6 | 3 | 2 | 3 |
Solution — filling in the margins
Step 1 — Compute the row totals.
$$ \text{men} = 4 + 5 + 7 + 2 = 18 \qquad \text{women} = 6 + 3 + 2 + 3 = 14 $$Step 2 — Compute the column totals.
$$ 4+6 = 10 \qquad 5+3 = 8 \qquad 7+2 = 9 \qquad 2+3 = 5 $$Step 3 — Compute the grand total. \(18 + 14 = 32\), and checking against the columns, \(10 + 8 + 9 + 5 = 32\). The two agree, which is the arithmetic check worth doing every time.
Step 4 — Find the expected count for men/ice cream.
$$ E = \frac{(\text{row total})(\text{column total})}{\text{total surveyed}} = \frac{(18)(8)}{32} = 4.5 $$Answer: Row totals 18 and 14, column totals 10, 8, 9 and 5, grand total 32. The expected count for men/ice cream is 4.5.
Using the margins from Try It Now 10.8.2, build the full table of expected counts and decide whether the test may proceed as it stands.
Solution — a condition that fails in most of the table
Step 1 — Apply the formula to every cell. With row totals 18 and 14, column totals 10, 8, 9 and 5, and \(n = 32\):
| sweets | ice cream | chips & pretzels | fruits & vegetables | |
|---|---|---|---|---|
| men | 5.63 | 4.50 | 5.06 | 2.81 |
| women | 4.38 | 3.50 | 3.94 | 2.19 |
Step 2 — Check every cell against the floor of five. Only two cells clear it: men/sweets at 5.63 and men/chips at 5.06. The other six are below five.
Step 3 — State the verdict. The test may not proceed on this table.
Step 4 — Describe the repair. Combine categories until every expected count reaches five. Merging "ice cream" into "sweets" and "fruits & vegetables" into "chips & pretzels" leaves two columns with totals 18 and 14, which produces expected counts of 10.13, 7.88, 7.88 and 6.13 — all above five.
Step 5 — State the cost. Four columns became two, so the degrees of freedom falls from \((2-1)(4-1) = 3\) to \((2-1)(2-1) = 1\).
Answer: Six of the eight expected counts are below five, so the test cannot proceed. After merging to two snack categories every expected count clears the floor, at a cost of two degrees of freedom.
10.8.3 Reading the Table Before You Test It
Step 2 of Collect the Data asks for your impression before any arithmetic. That is deliberate, and it is worth taking seriously rather than treating as a formality — the comparison between your impression and the test result is what the Discussion Questions are about.
Looking only at Table 10.8.2, write down whether the two factors appear dependent and give one specific reason from the counts. Then say what would make that impression unreliable.
Solution — an impression, honestly labeled
Step 1 — Look for a pattern in the counts. Men chose chips & pretzels 7 times against women's 2, while women chose sweets 6 times against men's 4. The two rows do look differently shaped.
Step 2 — Say what that suggests. On appearance, snack preference and gender look dependent.
Step 3 — Name what makes it unreliable. The counts are tiny. A difference of 7 to 2 in a class of 32 can easily arise from ordinary variation, and eyes are not calibrated for how much variation to expect in cells this small.
Step 4 — Note the second problem. The rows hold different numbers of people, 18 and 14, so comparing raw counts across rows is already misleading. Shares would be a fairer look: 7 of 18 is about 39%, and 2 of 14 is about 14%.
Answer: The table looks dependent, driven by the chips column. The impression is unreliable because the cells are very small and the two row totals differ, so raw counts across rows are not directly comparable.
10.8.4 Hypothesis Test
Conduct a hypothesis test to determine if the factors are independent:
- \(H_{0}\): ____
- \(H_{a}\): ____
- What distribution should you use for a hypothesis test?
- Why did you choose this distribution?
- Calculate the test statistic.
- Find the p-value.
- Sketch a graph of the situation. Label and scale the x-axis, and shade the area corresponding to the p-value.
- State your decision.
- State your conclusion in a complete sentence.
Write out answers to items 1 through 4 for this lab, and state the degrees of freedom for the merged two-column table from Try It Now 10.8.3.
Solution — the setup, in the lab's own terms
Step 1 — Write the null hypothesis. \(H_{0}\): Favorite type of snack and gender are independent.
Step 2 — Write the alternative. \(H_{a}\): Favorite type of snack and gender are dependent.
Step 3 — Name the distribution. The chi-square distribution, and the test is right-tailed.
Step 4 — Justify that choice. The data are counts of subjects falling into the cells of a contingency table built from two categorical questions asked of one sample. That is precisely the setting the chi-square test of independence was built for, and the statistic sums squared differences, so only large values count as evidence.
Step 5 — Find the degrees of freedom for the merged table. Two rows and two columns:
$$ df = (\text{rows} - 1)(\text{columns} - 1) = (2-1)(2-1) = 1 $$Answer: \(H_{0}\): the factors are independent; \(H_{a}\): they are dependent; use the right-tailed chi-square distribution with \(df = 1\) on the merged table.
Carry the merged table through to a decision. After merging, the observed counts are: men 9 sweets-or-ice-cream and 9 chips-or-produce; women 9 and 5. Compute the expected counts, the test statistic, and state the decision at a 5% significance level given a p-value of about 0.42.
Solution — a full test on the repaired table
Step 1 — Confirm the margins. Row totals are \(9+9 = 18\) and \(9+5 = 14\); column totals are \(9+9 = 18\) and \(9+5 = 14\); the grand total is 32.
Step 2 — Compute the expected counts.
$$ E_{11} = \frac{(18)(18)}{32} = 10.125 \qquad E_{12} = \frac{(18)(14)}{32} = 7.875 $$ $$ E_{21} = \frac{(14)(18)}{32} = 7.875 \qquad E_{22} = \frac{(14)(14)}{32} = 6.125 $$Step 3 — Check the condition. All four clear five, so the test is legitimate.
Step 4 — Compute the test statistic.
$$ \chi^{2} = \frac{(9-10.125)^{2}}{10.125} + \frac{(9-7.875)^{2}}{7.875} + \frac{(9-7.875)^{2}}{7.875} + \frac{(5-6.125)^{2}}{6.125} \approx 0.65 $$Step 5 — Compare and decide. With \(\alpha = 0.05\) and a p-value of about 0.42, \(\alpha <\) p-value, so do not reject \(H_{0}\).
Step 6 — Write the conclusion. At a 5% level of significance there is insufficient evidence to conclude that favorite type of snack and gender are dependent.
Answer: \(\chi^{2} \approx 0.65\) with \(df = 1\); do not reject \(H_{0}\). The data do not support a claim of dependence.
10.8.5 Interpreting the Result
In Try It Now 10.8.4 the table looked dependent; in Try It Now 10.8.6 the test did not reject independence. Explain how both can be correct, and identify the single step that did the most to change the picture.
Solution — where the apparent pattern went
Step 1 — Restate what the eye saw. The most striking contrast was 7 men versus 2 women choosing chips & pretzels.
Step 2 — Identify what the merge did to it. Repairing the expected-count condition folded chips & pretzels together with fruits & vegetables. That put the 7 and the 2 into the same column as the 2 and the 3, producing 9 and 5, and the sharp contrast largely dissolved.
Step 3 — Explain why that is legitimate rather than a trick. With expected counts near 2.8, the original chips column could not support a reliable test at all. The merge is what made any conclusion possible; it did not hide a real finding so much as reveal that the finding rested on cells too small to trust.
Step 4 — Say what would settle it. A larger sample. With several classes pooled, four columns could be kept, and if the chips pattern is real it would then be measurable.
Answer: Both are correct. The apparent pattern lived almost entirely in the chips column, and repairing the expected-count condition merged that column away. The merge was the decisive step, and the honest reading is that this sample is too small to resolve the question rather than that no relationship exists.
Item 7 of the Hypothesis Test asks you to sketch the situation and shade the area for the p-value. For the merged table result of Try It Now 10.8.6, describe exactly what your sketch should show: the curve, where the statistic sits, and which region gets shaded.
Solution — drawing a right-tailed chi-square p-value
Step 1 — Draw the correct curve. The test uses \(\chi_{1}^{2}\), so sketch a chi-square curve with 1 degree of freedom. At \(df = 1\) the curve is extremely right-skewed, starting high near zero and falling away steeply.
Step 2 — Scale and label the horizontal axis. Label it \(\chi^{2}\) and mark values from 0 out to about 6, which is far enough to contain the statistic comfortably.
Step 3 — Mark the test statistic. Place a vertical line at \(\chi^{2} \approx 0.65\), which sits well to the LEFT on the axis, close to the bulk of the curve.
Step 4 — Shade the correct region. The test is right-tailed, so shade everything to the RIGHT of 0.65, out to the end of the axis.
Step 5 — Sanity-check the picture against the number. That shaded region is visibly most of the area under the curve, which matches a p-value of about 0.42. A shaded region that looks large and a p-value near zero would mean one of the two is wrong.
Answer: A \(\chi_{1}^{2}\) curve, a vertical line at 0.65, and the region to its right shaded — an area covering roughly 42% of the total, consistent with the p-value.
Suppose a class records three gender categories rather than two, so the table has three rows and four snack columns. State the degrees of freedom, say whether the \(df = ext{columns} - 1\) shortcut from Section 10.4 still applies, and describe what the extra row does to the expected-count condition.
Solution — a third row changes two things at once
Step 1 — Apply the general formula.
$$ df = ( ext{rows} - 1)( ext{columns} - 1) = (3-1)(4-1) = (2)(3) = 6 $$Step 2 — Check the shortcut. The \(df = ext{columns} - 1\) rule works only because a homogeneity table has exactly two rows, which makes \(( ext{rows}-1) = 1\). With three rows that factor is 2, so the shortcut does NOT apply — and this is a test of independence in any case.
Step 3 — Consider the expected counts. The same class-sized total is now spread over 12 cells instead of 8, so every expected count shrinks. A third category that only a few students select will produce very small expected counts across its entire row.
Step 4 — Describe the repair. The condition is repaired the same way as before, by combining categories — and rows may be merged just as columns can, though merging a row means the analysis no longer distinguishes the groups it combined, which is a real cost to weigh rather than an automatic move.
Answer: \(df = 6\). The columns-minus-one shortcut does not apply because there are three rows. Spreading the same sample over 12 cells shrinks every expected count, so merging is more likely to be needed, and merging rows loses the distinction the extra category was recording.
10.8.6 Discussion Questions
- Is the conclusion of your study the same as or different from your answer to question two under Collect the Data?
- Why do you think that occurred?
Suppose your test rejects \(H_{0}\) and concludes the factors are dependent. Write the conclusion in a complete sentence, then state two things you may NOT claim on the strength of it.
Solution — the limits of a rejection
Step 1 — Write the conclusion in context. At a 5% level of significance, from the data collected, there is sufficient evidence to conclude that favorite type of snack and gender are dependent.
Step 2 — Name the first thing you may not claim. You may not say which cell drives the relationship. The statistic pools every cell into one number, so "men prefer chips" is not something the test established — comparing the observed and expected tables can suggest it, but that is a further question.
Step 3 — Name the second. You may not claim causation. Dependence between two recorded characteristics says they vary together in this sample; it says nothing about one causing the other.
Step 4 — Add the sampling caveat. A single class is not a random sample of any larger population, so the conclusion describes this class rather than students generally.
Answer: The conclusion is that the two factors are dependent at the 5% level. You may not identify which category drives it, and you may not infer causation — and because the sample is one class, the result does not generalize.
Problem Set 10.8
Problem 1. State the two questions from Section 10.5 that identify which chi-square test a study calls for, and apply them to this lab.
Solution
Step 1 — State the two questions. The first question: how many populations are being sampled? The second question: how many questions (variables) are being asked of each person?
Step 2 — Apply the first question to this lab. One population is being sampled — the class itself. Nobody drew separate samples with fixed sizes from different groups.
Step 3 — Apply the second question to this lab. Two questions are asked of each person: their favorite type of snack, and their gender.
Step 4 — Match against the three chi-square designs. One population and two categorical questions per subject is a test of independence; the data form a contingency table. It is not goodness-of-fit (that involves one variable), and it is not homogeneity, because the row totals were not fixed in advance — the numbers of men and women are facts about the class, not design choices.
Answer: The two questions are "how many populations are sampled?" and "how many variables are recorded per person?" This lab has one population and two variables, so it calls for a chi-square test of independence.
Problem 2. A class of 28 students produces row totals of 15 and 13 and a column total of 6 for one snack category. Find both expected counts in that column and say whether they satisfy the condition.
Solution
Step 1 — Set up the expected-count formula. Each expected count is \(E = \frac{(\text{row total})(\text{column total})}{\text{total surveyed}}\). Here the column total is 6 and the grand total is \(n = 28\).
Step 2 — Compute the expected count for the men row.
$$ E_{\text{men}} = \frac{(15)(6)}{28} = \frac{90}{28} \approx 3.21 $$Step 3 — Compute the expected count for the women row.
$$ E_{\text{women}} = \frac{(13)(6)}{28} = \frac{78}{28} \approx 2.79 $$Step 4 — Check against the condition. Both expected counts must be at least five. Since \(3.21 < 5\) and \(2.79 < 5\), neither cell satisfies the condition.
Answer: The expected counts are approximately 3.21 (men) and 2.79 (women). Both fall below five, so the condition fails and categories would need to be combined before testing.
Problem 3. Explain why the expected-count condition constrains the expected counts rather than the observed ones.
Solution
Step 1 — Recall what the chi-square statistic assumes. The test compares each observed count to an expected count computed under the assumption that the factors are independent, and the sampling distribution of \(\chi^{2}\) that makes p-values meaningful was derived under that model.
Step 2 — Explain why observed counts cannot be constrained. Observed counts are data — they are whatever the sample produced, and the researcher has no control over them. A requirement placed on observed counts would be a requirement on chance outcomes.
Step 3 — Explain why expected counts are the right target. Expected counts are determined by the margins and the sample size, so they measure how much information the design actually supplies to each cell. When an expected count is small, the approximation behind the chi-square distribution breaks down there — large relative fluctuations are possible even under independence, inflating the statistic.
Step 4 — Note the practical consequence. Because expected counts depend only on the totals, the researcher can repair small expected counts by combining categories (changing the column structure) or gathering more data (raising every margin), whereas nothing can be done directly about an individual observed count.
Answer: The condition constrains expected counts because the validity of the chi-square approximation depends on what the cells would hold under independence, which is governed by the margins and sample size. Observed counts are random data beyond the researcher's control; expected counts reflect the design and can be repaired by merging categories or enlarging the sample.
Problem 4. A 2-by-4 contingency table has two columns whose expected counts fall below five. Give the degrees of freedom before and after merging those two columns into their neighbors.
Solution
Step 1 — Compute the degrees of freedom before merging. For a 2-by-4 table,
$$ df = (\text{rows} - 1)(\text{columns} - 1) = (2-1)(4-1) = (1)(3) = 3 $$Step 2 — Determine the table size after merging. Combining two columns into one removes one column, so the merged table is 2-by-3.
Step 3 — Compute the degrees of freedom after merging.
$$ df = (2-1)(3-1) = (1)(2) = 2 $$Step 4 — Confirm the cost rule. Each merge costs exactly one degree of freedom, and indeed \(3 - 1 = 2\).
Answer: Before merging, \(df = 3\); after merging the two columns into one neighbor, the table is 2-by-3 and \(df = 2\).
Problem 5. A student writes \(H_{a}\): "Men prefer chips more than women do." Explain why this is not a valid alternative hypothesis for a test of independence, and write a correct one.
Solution
Step 1 — Identify what is wrong with the student's statement. A test of independence asks whether the two factors are related at all. The alternative hypothesis must be the logical complement of the null: if \(H_0\) says the factors are independent, then \(H_a\) must say they are dependent. "Men prefer chips more than women do" asserts a specific direction and a specific category, which is a stronger claim than mere dependence.
Step 2 — Note the structural problem. The chi-square test of independence is inherently right-tailed and symmetric across all cells: it pools deviations from every cell into one statistic and cannot test a directional claim about one particular cell. A directional comparison would call for a different procedure (for example, a two-proportion z-test comparing chips preference between men and women).
Step 3 — Write a correct alternative hypothesis. \(H_a\): Favorite type of snack and gender are dependent.
Answer: The statement is invalid because it specifies a direction and a particular category, while the alternative in a test of independence must simply be the negation of independence. The correct alternative is \(H_a\): favorite type of snack and gender are dependent.
Problem 6. A class table gives \(\chi^{2} = 4.10\) with \(df = 1\) and a p-value of 0.043. State the decision at the 5% significance level and write the conclusion in a complete sentence.
Solution
Step 1 — Compare the p-value to the significance level. With \(\alpha = 0.05\) and p-value \(= 0.043\),
$$ \text{p-value} = 0.043 < 0.05 = \alpha $$Since the p-value is smaller than \(\alpha\), reject \(H_0\).
Step 2 — Write the conclusion in context. At a 5% level of significance, from the data collected, there is sufficient evidence to conclude that favorite type of snack and gender are dependent.
Step 3 — Sanity-check against the statistic. For \(df = 1\), the critical value at \(\alpha = 0.05\) is about 3.84, and \(\chi^{2} = 4.10 > 3.84\), which agrees with the decision to reject.
Answer: Reject \(H_0\). At the 5% level of significance, there is sufficient evidence to conclude that favorite type of snack and gender are dependent.
Problem 7. Using the same result as 10.8.6, state two claims you may NOT make.
Solution
Step 1 — Name the first forbidden claim. You may not identify which snack category drives the dependence. The chi-square statistic pools all cells into a single number, so rejecting \(H_0\) establishes that some relationship exists, not that any particular cell (such as men preferring chips) is responsible. Comparing observed and expected counts can suggest where the relationship lies, but that is a follow-up question, not something this test proved.
Step 2 — Name the second forbidden claim. You may not claim causation. Dependence means the two characteristics vary together in this sample; it says nothing about one causing the other. There may be confounding factors, and neither variable was assigned experimentally.
Step 3 — Add the generalization caveat. The sample is a single class, not a random sample of students generally, so the conclusion describes this class rather than a larger population.
Answer: You may not claim which category drives the relationship (the test pools all cells into one statistic), and you may not claim that one factor causes the other — dependence is association, not causation. Additionally, because the sample is one class, the result should not be generalized to all students.
Problem 8. A student merges two snack categories AFTER seeing which merge produces the largest test statistic. Explain what is wrong with that.
Solution
Step 1 — Identify the practice. Choosing among possible merges based on which one yields the largest test statistic is selecting the analysis after seeing the results — a form of data snooping.
Step 2 — Explain why it biases the test. The chi-square test's p-values are calibrated for a test whose hypotheses and category structure were fixed before the data were examined. Searching over merges and keeping the one that maximizes \(\chi^{2}\) cherry-picks the most extreme outcome out of many possibilities, so the reported p-value no longer reflects the true probability of such an extreme result under \(H_0\). The actual Type I error rate becomes much larger than the nominal \(\alpha\).
Step 3 — Contrast with the legitimate use of merging. Merging is justified only as a repair for the expected-count condition, decided by looking at the expected counts (which depend on the margins, not on how dependent the data look), and ideally specified before computing the statistic.
Answer: Choosing the merge that maximizes the test statistic is data snooping: it selects the most favorable analysis after seeing the data, inflating the Type I error rate and making the reported p-value invalid. Merges should be chosen to fix small expected counts, based on the margins alone, before the statistic is computed.
Problem 9. Two classes run this lab and reach opposite conclusions. Give two reasons that can happen without either class making a computational error.
Solution
Step 1 — Reason 1: sampling variability. Each class is a small sample, and small samples are noisy. Even if the true relationship (or lack of one) is identical, ordinary chance variation can push one class's \(\chi^{2}\) above its critical value and another's below. A p-value of 0.04 versus 0.06 represents nearly the same evidence but opposite decisions.
Step 2 — Reason 2: different class compositions. The two classes may genuinely differ — in size, in gender balance, or in cultural or regional snack preferences. Different margins change both the expected counts and the degrees of freedom available after repairing the expected-count condition, so the classes may effectively be testing slightly different tables.
Step 3 — Note why neither is an error. Both computations can be perfectly correct; the disagreement reflects the uncertainty inherent in small samples and the fact that each class tests its own members, not a common population.
Answer: Opposite conclusions can arise from (1) ordinary sampling variability — small samples are noisy, and p-values near \(\alpha\) can land on either side by chance — and (2) genuine differences between the classes in size, composition, or preferences, which change the margins and even the post-merge table being tested. Neither requires a computational mistake.
Problem 10. Explain why a single class is not a random sample of any larger population, and what that means for how the conclusion should be worded.
Solution
Step 1 — Define what a random sample requires. A random sample of a larger population requires that every member of that population have a known, equal (or at least specifiable) chance of appearing in the sample. Members of a single class were selected into it by scheduling, major requirements, and registration choices — mechanisms unrelated to random selection.
Step 2 — Explain the bias this introduces. A class shares characteristics — age range, field of study, institution, often region — that may be associated with the variables being studied. So the class systematically differs from the broader population in ways that could distort the relationship between snack preference and gender.
Step 3 — Draw the wording consequence. Statistical conclusions apply to the population from which the sample was drawn. Since the sample is the class, the conclusion must be worded as a statement about this class ("in this class, ...") rather than about students in general. Extending it further would require a properly drawn random sample.
Answer: A single class is not a random sample because membership was determined by scheduling and enrollment rather than by random selection, and the class shares systematic characteristics that may relate to the variables studied. Therefore the conclusion should be worded as applying to this class specifically — e.g., "in this class, favorite snack type and gender appear dependent" — and not generalized to students at large without new, randomly sampled data.
Key Terms
contingency table — a table that displays sample values for two different factors that may be dependent or contingent on one another; it facilitates determining conditional probabilities.
test of independence — the chi-square test used in this lab, deciding whether two factors recorded on one sample are independent or dependent.
expected count — \(\frac{(\text{row total})(\text{column total})}{\text{total surveyed}}\); the count a cell would hold if the two factors were independent.
expected-count condition — the requirement that every expected value be at least five; on a class-sized sample it usually fails, and categories must be combined until it holds.
degrees of freedom — \((\text{rows} - 1)(\text{columns} - 1)\); each merge that repairs the condition also removes one.