Examples
Worked examples
- Is an instance
Testing whether treatment group (drug vs. placebo) and outcome (improved vs. not improved) are associated, using a 2×2 contingency table of observed counts — a chi-square test of independence.
- Is an instance
Testing whether observed counts across four categories match an expected 25/25/25/25 split — a chi-square goodness-of-fit test.
Counter-examples
Looks similar, but isn't
- Not an instance
Comparing mean blood pressure (a continuous outcome) across three treatment arms is not a chi-square problem — that calls for ANOVA (three or more groups) or a t-test (two groups), since chi-square only applies to categorical/count data.
Editorial commentary
Operational definition
A chi-square test (χ², Pearson’s chi-square) is a hypothesis test for categorical data: it compares observed counts in a set of categories against the counts you would expect under a stated null hypothesis, and asks whether the difference is larger than random sampling variation alone would produce. There are two common forms, and a dataset only qualifies as a fit for either if the outcome being analysed is genuinely categorical (nominal or ordinal counts), not a continuous measurement:
- Chi-square test of independence — tests whether two categorical variables are associated with each other, using a contingency (cross-tab) table of observed counts. Degrees of freedom: (rows − 1) × (columns − 1).
- Chi-square goodness-of-fit test — tests whether the observed distribution of a single categorical variable matches a specified expected distribution (e.g. equal proportions, or a theoretical ratio). Degrees of freedom: (number of categories − 1).
Both forms use the same test statistic, summed across every cell: χ² = ∑ (O − E)² / E, where O is the observed count in a cell and E is the count expected under the null hypothesis. A large χ² value (and correspondingly small p-value) indicates the observed counts diverge from what the null hypothesis predicts.
Worked example: test of independence
Illustrative example: a researcher surveys 200 study participants and cross-tabulates two categorical variables — treatment group (drug vs. placebo) and outcome (improved vs. not improved) — into a 2×2 contingency table. The chi-square test of independence compares the observed cell counts to the counts that would be expected if treatment and outcome were statistically independent. A significant result (typically p < .05) supports reporting an association between treatment and outcome; it does not by itself establish the size or direction of that association — that’s what an effect size measure such as Cramér’s V or an odds ratio is for.
Worked example: goodness-of-fit
Illustrative example: a researcher records the category (A, B, C, D) that 120 observations fall into and wants to know whether the observed split matches an expected 25/25/25/25 distribution across the four categories. The goodness-of-fit test compares each category’s observed count to the expected count of 30, summing (O − E)² / E across all four categories to produce the test statistic, with 3 degrees of freedom.
Assumptions and when the test breaks down
- Categorical data. Both variables (independence test) or the single variable (goodness-of-fit) must be nominal or ordinal counts, not continuous measurements.
- Independent observations. Each observation contributes to exactly one cell; the test is not valid for repeated or matched measurements on the same subjects (McNemar’s test handles paired categorical data instead).
- Expected cell counts. The chi-square approximation is unreliable when expected cell counts are too small — the conventional rule of thumb is that no more than 20% of cells should have an expected count below 5, and no cell should have an expected count of 0. For small 2×2 tables that violate this, Fisher’s exact test is the standard alternative; Yates’ continuity correction is sometimes applied to 2×2 tables to reduce overstatement of significance.
Counter-example: when chi-square is the wrong test
Comparing mean blood pressure across three treatment arms is not a chi-square problem, even though it involves comparing groups — blood pressure is a continuous outcome, so the comparison calls for ANOVA (three or more groups) or a t-test (two groups), not a chi-square test. A useful shortcut when choosing a test: if the outcome variable is a count or category, chi-square is a candidate; if the outcome is a continuous measurement, it isn’t — t-tests and ANOVA are built for that case instead.
Reporting in a manuscript
Standard reporting for a chi-square result states the statistic, degrees of freedom, sample size, and p-value, e.g. χ²(1, N = 200) = 8.42, p = .004. Reviewers and journal statistical checklists typically expect the contingency table (or category counts) to be reported alongside the test statistic, not the test statistic alone, so a reader can evaluate the direction and size of any association independently of statistical significance.
Related terms
- ANOVA (Analysis of Variance) — the corresponding test for comparing means of a continuous outcome across groups.
- Descriptive Statistics vs. Inferential Statistics — chi-square is an inferential test built on top of descriptive contingency-table counts.
- Effect Size — a significant chi-square result should be paired with an effect size (Cramér’s V, phi coefficient) to convey magnitude, not just significance.
- Experimental Design — whether a chi-square test is appropriate is determined at the design stage, by what type of outcome variable the study collects.
Machine-readable encodings
Use in your systems
<role vocab="credit"
vocab-identifier="https://casrai.org/dictionary/"
vocab-term="Chi-Square Test (χ²)"
vocab-term-identifier="https://casrai.org/dictionary/term/chi-square-test" />{
"@context": "https://schema.org",
"@type": "DefinedTerm",
"@id": "https://casrai.org/dictionary/term/chi-square-test",
"name": "Chi-Square Test (χ²)",
"identifier": "https://casrai.org/dictionary/term/chi-square-test",
"description": "A hypothesis test for categorical data that compares observed category counts to the counts expected under a null hypothesis — either testing whether two categorical variables are independent (chi-square test of independence) or whether one categorical variable's observed distribution matches a specified expected distribution (goodness-of-fit). Distinct from t-tests and ANOVA, which test differences in a continuous outcome's mean rather than differences in categorical counts.",
"inDefinedTermSet": "https://casrai.org/dictionary/domain/research-outputs#set",
"url": "https://casrai.org/dictionary/term/chi-square-test",
"sameAs": [],
"license": "https://creativecommons.org/licenses/by/4.0/",
"publisher": {
"@id": "https://casrai.org/#organization"
},
"dateModified": "2026-07-23T06:37:54",
"inLanguage": "en"
}






