5.06a - Chi-squared tests for independence
Decide whether two categorical variables are associated, using observed counts and the counts independence would predict. You will calculate expected frequencies and contributions, combine categories when necessary, choose the degrees of freedom and complete a chi-squared test, including Yates’s correction for a two-by-two table.
Independence and hypotheses
Does a preferred revision format depend on whether a student studies a language? Suppose a random sample gives the following counts.
| Printed notes | Video | Both | Total | |
|---|---|---|---|---|
| Studies a language | ||||
| Does not | ||||
| Total |
The proportions differ, but random sampling can produce differences even when the population variables are independent. How large must the discrepancy be before it is convincing evidence of association? We will return to these counts after building the test.
You already know
Events and are independent when . A significance test compares data with a null hypothesis at a chosen significance level; not rejecting a hypothesis does not prove it.
Each person contributes to exactly one cell. The variables are the row category and column category, rather than the individual cells themselves. Treating repeated answers from the same person as independent observations would misrepresent the amount of information.
Contingency table
A contingency table classifies observations by two categorical variables, with one variable defining the rows and the other defining the columns. The entries are observed frequencies, denoted by . The categories within each variable must be mutually exclusive and cover all observations.
For the opening question, write : revision-format preference and language study are independent. The alternative is : revision-format preference and language study are associated.
“No association” is equivalent to “independent”. “No correlation” is unsuitable here: these are categories, not numerical measurements to which a correlation coefficient applies. Hypotheses state population claims, without the words “there is evidence”.
A random sample, independently classified observations and sufficiently large expected frequencies support the chi-squared approximation. A convenient sample of volunteers can still be calculated with, but cannot automatically support conclusions about all students. Association also does not establish cause: taking a language has not been randomly assigned.
Key idea
The test asks whether the differences between observed and independence-based counts are too large to explain plausibly by sampling variation.
Check both the population claim and the way the data were collected before touching the calculator.
Expected frequencies under independence
An expected frequency is the count predicted under the null hypothesis, using the observed row and column totals.
In the opening table, half the sample studies a language and prefer printed notes. Independence predicts a fraction in both categories, giving people. Expected counts may be fractional: they are model averages, not a second observed sample.
Expected frequency in a contingency table
For a cell whose row total is , column total is , and grand total is ,
This fits the null hypothesis of independence using the table's margins.
Not in the formula booklet: learn it.
Calculate from the original margins, not by averaging the observed counts within a row.
Worked example 1: equal row totals
Question. Find the expected frequencies for the opening table.
Plan. Multiply each row total by each column total and divide by .
Why this step? Independence gives each row the same column proportions, not necessarily equal column counts.
Answer. The expected table is , because both row totals are .
Check. The row totals remain , the column totals remain , and all expected frequencies are at least .
Worked example 2 changes only the balance between the row totals. The same column proportions now produce different expected counts in the two rows.
Worked example 2: unequal row totals
Question. A table has observed counts . Find its expected frequencies under independence.
Plan. Find the margins before applying .
Why this step? A row containing three times as many people must have three times each expected frequency under independence.
Answer. .
Check. The first expected column totals ; the smallest expected count is exactly , which meets the condition.
An observed zero is possible under a model with positive expected frequency. Conversely, an observed count of does not make a cell suitable if its expected count is only .
Watch out
Wrong: “Every observed count exceeds , so the condition is satisfied.” Right: check every expected frequency. The threshold is , not .
Preserving the margins provides a quick check on a whole expected table.
Contributions and degrees of freedom
A chi-squared statistic adds scaled discrepancies: each cell contributes , so positive and negative differences cannot cancel.
Dividing by matters. A discrepancy of is more striking beside an expectation of than beside an expectation of . Every contribution is non-negative; exact agreement gives zero.
Chi-squared statistic
For a contingency table other than a two-by-two table, with every expected frequency at least ,
Under , this is approximately distributed as .
In the formula booklet.
The observed total and fitted margins constrain the cells. In a two-by-three table, once the first two counts in the first row are chosen, its third count is fixed by that row total, and the entire second row is fixed by the column totals. Only two cells vary freely.
Degrees of freedom for independence
For a retained table with rows and columns,
Use the dimensions after any combining of rows or columns.
Not in the formula booklet: learn it.
Large values of contradict independence, so the rejection region is always in the upper tail. At the level, choose the critical value with upper-tail probability . The chi-squared critical-value table is in the formula booklet; do not split this probability between two tails.
[DIAGRAM: asset_name: The upper-tail rejection region; asset_slug: h245_5_06_chi_squared_tail; caption: With two degrees of freedom, the upper five per cent begins at 5.991; description: A chi-squared density with two degrees of freedom is drawn above a horizontal statistic axis. The area to the right of the vertical line at 5.991 is shaded pale clay and labelled upper-tail probability 0.05. A marker at 2.4 lies to the left of the line and a marker at 10.667 lies to its right]

Worked example 3: complete the opening test
Question. Test the opening revision-format data at the significance level. Assume independent observations from a random sample.
Plan. Use the expected counts in each row, add all six contributions and compare with .
The hypotheses are those stated in the first part.
Why this step? The small statistic says the observed differences are not unusually large under independence; different observed proportions alone are insufficient.
Answer. Do not reject . At the level there is insufficient evidence of association between revision-format preference and language study.
Check. Both -count cells agree exactly with expectation, and all four other contributions are .
Worked example 4 changes only the allocation of counts within the same margins. The expected counts and critical value stay fixed, isolating the effect of greater discrepancy.
Worked example 4: stronger disagreement with the same margins
Question. Another independent random sample gives for the same two variables. Test for association at the level.
Plan. Keep the same hypotheses and expected table, then recalculate the contributions.
Why this step? The margins determine expectation; the cells' departures from that expectation determine evidence against independence.
Answer. Reject . There is sufficient evidence, at the level, of association between revision-format preference and language study.
Check. The first column alone contributes , already beyond the critical value; the full sum must be larger.
Continue this lesson.
You’re previewing NovaLearn without an account. Create a free account to read the rest.
Create free account