DistFlow

Home / Guides

Chi-Squared Test Explained

A practical guide to the two main chi-squared tests: goodness-of-fit for checking distributional assumptions and independence for contingency tables.

Try This In The Plotter

Jump directly into the interval probability workflow and apply this guide on a live distribution chart.

Open Interactive Interval Probability

The Chi-Squared Test Statistic

Both chi-squared tests use the same core statistic: χ² = Σ (O − E)² / E, where O is the observed count and E is the expected count under the null hypothesis.

Large values of χ² indicate that observed data deviate substantially from what the null hypothesis predicts, leading to rejection.

Goodness-of-Fit Test

The goodness-of-fit test checks whether a sample of categorical data matches a hypothesized distribution. For example, testing whether a die is fair by comparing observed face frequencies to equal probabilities.

Degrees of freedom equal the number of categories minus 1, minus any parameters estimated from the data. Compare the test statistic to the chi-squared distribution to obtain a p-value.

Test of Independence

The independence test uses a contingency table to check whether two categorical variables are associated. Expected counts are computed from marginal totals under the assumption of no association.

Degrees of freedom are (rows − 1) × (columns − 1). A significant result means the variables are associated, but it does not quantify the strength or direction of the association.

Assumptions and Practical Tips

The approximation works well when expected counts are at least 5 in every cell. For sparse tables, consider Fisher's exact test or combine categories to meet the threshold.

Report effect size measures like Cramér's V alongside the p-value to give readers a sense of practical significance beyond statistical significance.