Chi-square Tests
Run goodness-of-fit or contingency-table independence tests from counts, with expected counts, cell contributions, p-values and sparse-data warnings.
Question, try, then observe
Which counts depart from expectation?
Prespecify equal probabilities for three categories. Edit the observed counts; expectations recalculate with the total and each contribution updates.
What did you just see?
When each category expects 20 people, 20/20/20 matches the model while 30/20/10 departs more. Breaking the statistic into contributions reveals how discrepancies accumulate rather than showing only a p-value.
Two different questions
Goodness-of-fit H₀ specifies category probabilities; expectations equal the total times those probabilities, with df=k−1 in this version. Independence H₀ says the classifications are independent; expectations use row totals, column totals and the overall total, with df=(r−1)(c−1).
Counts and sampling design
Assign each independent observation to an appropriate mutually exclusive category. Repeated measurements or clustered household surveys do not become independent by being placed in a table. Expected counts must be positive; one effective category cannot support a meaningful goodness-of-fit test.
A large χ² is not an effect size
A larger sample can produce a larger χ² for the same proportional discrepancy. Cramér's V additionally scales association by sample size and table dimension. Read the actual proportions as well; V does not establish causal direction.
Another example
- Choose goodness-of-fit and enter counts with prespecified proportions, or supply a contingency table.
- Check proportion totals, expected counts and independent observations; set α.
- Read contributions, χ², df and p-value; independence also supplies Cramér’s V. Heed expected-count warnings.
Show formal definition and formula
Pearson's chi-square test compares categorical observed counts with expectations under a null model. Goodness-of-fit and independence share the statistic's form, but have different null hypotheses and df.
Observed versus expected
Expected counts
Contingency df and effect size
- Oᵢ, Eᵢ
- Observed and expected counts; enter counts, not percentages.
- pᵢ, n
- Prespecified probabilities (sum 1) and total count.
- r, c, ν
- Rows, columns and df; prespecified GOF df is categories−1.
- V
- Cramér's V association effect size; not causation.
Common mistakes
Percentages are not observed counts or sample sizes. Association is not causation. A chi-square right tail is not a symmetric two-tail calculation, and sparse expected counts do not become reliable just because a p-value was computed.
Frequently asked questions
Must every expected count exceed five?
Approximation quality depends on table size, sample size and the pattern of expectations. The tool flags cells below one, cells below five and their prevalence; a single cutoff is not a universal reliability guarantee.
Can I estimate the null proportions from these data?
This version restricts goodness-of-fit to prespecified theoretical proportions. It does not adjust df for parameters fitted from the same sample; in that setting k−1 cannot simply be retained.
Is Fisher's exact test available for sparse tables?
Fisher's exact test may be appropriate for some sparse contingency tables, but it is not implemented here. A chi-square approximation is not an exact Fisher result.
You can now explore…
- Compare observed and expected counts
- Check sparsity and categorical association