Posters · Glossary

What is a chi-square test?

A chi-square test checks whether the counts in categories differ from what would be expected by chance. The test of independence asks whether two categorical variables, such as region and preference, are associated, by comparing the observed counts in a table with the counts expected if there were no association.

Survey and cohort posters are full of percentages compared across groups. The chi-square test is usually what sits behind the p value beside them, and knowing how it works shows when that p value can be trusted.

· Co-founder

4 min read · Published

A worked chi-square test of independence: observed counts, with expected counts in brackets
Prefers onlinePrefers in personTotal
Urban60 (50)40 (50)100
Rural40 (50)60 (50)100
Total100100200
CalculationEach cell (O minus E) squared over E = 2Four cells sum to 8.0, 1 degree of freedomp is about 0.005, below 0.05

How the test works

Start with a table of counts. For each cell, work out the count you would expect if the two variables were unrelated: the row total times the column total, divided by the grand total. In the worked table, every expected count is 100 times 100 divided by 200, which is 50. For each cell, square the difference between observed and expected and divide by the expected count; add these up. Here each cell gives 100 divided by 50, which is 2, and the four sum to 8.0.

Reading the result

The total is compared with a chi-square distribution with degrees of freedom equal to rows minus one times columns minus one, which is one for a 2x2 table. A value of 8.0 with one degree of freedom corresponds to a p value of about 0.005, well below the conventional 0.05, so the data are unlikely if region and preference were unrelated. The test says there is an association; it does not say how strong, so report the percentages, and a measure such as a risk ratio or an odds ratio with its interval.

Assumptions to check

The observations must be independent, with each person counted once. The data must be counts, not percentages or means. And expected counts should not be too small: a common rule is that all expected counts are at least five. The review of the test of independence in Biochemia Medica discusses these conditions. When counts are small, Fisher's exact test is the usual alternative for a 2x2 table.

Other chi-square tests

The goodness of fit test compares the counts in one variable with a set of expected proportions, such as checking whether a sample's age groups match the census. The NIST Engineering Statistics Handbook describes this version. McNemar's test handles paired counts, such as the same people before and after an intervention, where the ordinary test of independence would wrongly treat the two answers as unrelated.

Showing it on a poster board

The observed and expected table fits on one of the three poster boards with a table slot, and the percentages in each group suit a vertical or horizontal bar chart, two of the ten chart kinds the boards offer. Stat blocks, on 26 boards, can carry the headline difference with the test statistic and p value beneath. The survey research example follows this pattern; give the counts in your brief, since the generator does not create statistics.

Questions people ask

When should I use a chi-square test instead of a t test?

Use a chi-square test when the outcome is a category, such as yes or no, or one of several options, and you are comparing counts. Use a t test when the outcome is a number, such as blood pressure or a score, and you are comparing means between two groups. The type of outcome variable decides it.

Can a chi-square test be used with percentages?

No. The test must be run on the actual counts, because the same percentages from 20 people and from 2,000 people carry very different evidence. Convert percentages back to counts using the group sizes, or go back to the raw data, before calculating anything.

What does a significant chi-square result not tell you?

It does not say which cells drive the association in a larger table, how strong the association is, or whether one variable causes the other. Look at the percentages, standardised residuals for each cell, and an effect measure. Confounding can also produce an association between two categorical variables.

What is Yates' continuity correction?

An adjustment sometimes applied to 2x2 tables that makes the test slightly more conservative by reducing each difference before squaring. It matters most with small samples. Many statisticians now prefer Fisher's exact test for small 2x2 tables instead. If software applies the correction by default, say so when reporting.

How should a chi-square result be reported on a poster?

Give the test used, the chi-square value, the degrees of freedom, the sample size and the p value, for example chi-square 8.0, 1 degree of freedom, n 200, p 0.005, alongside the percentages in each group. Readers need the percentages to judge whether the difference matters, not only whether it is unlikely by chance.

How large a sample does a chi-square test need?

Enough that every expected count in the table is at least about five, which depends on the number of cells and how the totals split. A 2x2 table with balanced groups needs only a few dozen people to meet the rule, but detecting a small difference reliably needs far more, which a power calculation can estimate.

Make one with posters

The button opens the generator with this use case already described. Change the wording to match your own.

Create a poster with OneCraft

Related questions

Step by step in the builder: Add charts and diagrams.

Sources

Written and checked by the OneCraft team. Last checked .