How to run a chi-square goodness-of-fit test
- Copy the category column (one observation per row) together with the header.
- Selecting the category column fills the table below with the observed count of each category. If the proportions differ, choose 'Enter directly' and edit the expected proportions.
- Press Analyze and check the p-value in the test summary and the categories beyond the dashed lines in the residual chart.
Worked example with sample data
The sample data are the months of 82 claims received from January to June 2026, one claim per row. The test assumes the same proportion for every month (the default).
The expected count in the results table is 13.67 per month (82/6). The test summary shows χ²=14.44 (5 degrees of freedom) and a p-value of 0.01305, so the claims were not received evenly across the months.
2026-04 contributes 11.13 of the total χ² of 14.44. April alone had 26 claims, nearly twice the expectation (13.67), and in the residual chart only the April bar is red and crosses the +2 dashed line.
The other months range from 9 to 14, so the first step is to check what changed in April in the process, materials or shipments. If you have proportions set in advance, such as a peak season, choose 'Enter directly' and test against those expected proportions.
How it is calculated
The expected count is expected proportion / sum of proportions × total count, and χ² = Σ(observed - expected)² / expected is tested against the chi-square distribution with (categories - 1) degrees of freedom (the same as SciPy's chisquare).
The expected proportions do not have to add up to 1; they are divided by their sum.
Standardized residuals
(observed - expected) / √expected; categories with an absolute value above 2 are shown as red bars in the residual chart.
What the result shows
The results table, the test summary, an observed vs expected bar chart, a χ² contribution chart and a residual chart.
How to read the goodness-of-fit result
- If the p-value is below the significance level, the observed distribution differs from the expected proportions.
- The category with the largest χ² contribution drives the difference, and the sign of its residual tells you whether it has more or fewer than expected.
- If many categories have an expected count below 5, the approximation may be inaccurate; try merging categories and testing again.
Frequently asked questions
Do the expected proportions have to add up to 1?
No. Entering 3, 2, 1 also works; they are divided by their sum.
Is it the same as Excel CHISQ.TEST?
It gives the same p-value as CHISQ.TEST(observed, expected) with the observed and expected count ranges.
Can the categories be numbers?
Yes. Values are treated as text, equal values are counted together, and categories are sorted by name.