The formula
How to calculate chi square
The chi-square test of independence asks whether two categorical variables are related — whether the outcome rate differs between groups by more than chance would produce.
For a 2×2 table the general formula collapses to the shortcut above, which needs only the four cell counts. With one degree of freedom, the square root of chi-square is the equivalent z-score, which is how the p-value here is derived.
What to enter:
- Group 1, outcome present
- Group 1, outcome absent
- Group 2, outcome present
- Group 2, outcome absent
No submit button: type and the answer moves. Your inputs end up in the link, so the page can be shared already filled in.
Units matter more here than the arithmetic itself: the formula assumes a specific set of units for each input, stated next to the field, and converting into those units first is usually the difference between a correct result and one that is wrong by a clean power of ten.
Why chi square matters
The formula behind chi square is standard and appears in the same form across textbooks and reference material; what a calculator adds is speed and the ability to see instantly how the result responds to a change in any one of the inputs, which is far slower to do by hand.
This also functions as a reference implementation of the formula itself: where the exact form of an equation is in question, the one used on this page, stated in the formula section above, is the standard version found in the relevant textbooks and reference material.
A formula like this one is rarely the last step in a piece of work — the figure it produces usually feeds into a further calculation, a comparison against a published value, or a write-up that needs to state both the result and how confident it is. Getting this step right the first time, rather than propagating a small arithmetic slip through several more steps, is the main practical reason to check a manual calculation against a tool like this one before building on top of it.
Where a calculation like this one is part of a larger piece of work, it is generally worth running it with a round, easy-to-check set of numbers first — inputs of exactly 1, 10 or 100 — purely to confirm the formula is being applied correctly, before switching to the real measured values the actual result depends on.
Worked example
A concrete run-through, using the values already in the fields:
- Group 1, outcome present: 218
- Group 1, outcome absent: 4,982
- Group 2, outcome present: 263
- Group 2, outcome absent: 4,887
That gives:
- Chi-square statistic: 4.883
- p-value, 1 df: 0.0271
- Odds ratio: 0.8131
The figures above are the calculator's own default values, shown purely so the working is visible rather than hidden — the same steps apply exactly to your own numbers, entered in the fields at the top of this page.
Reading the result
A chi-square above 3.84 is significant at the 5% level with one degree of freedom, and above 6.63 at the 1% level. The odds ratio tells you the direction and size of the association, which the test statistic alone does not.
Where this goes wrong. The approximation requires reasonable cell counts — the usual rule is an expected count of at least five in every cell. With smaller counts, Fisher's exact test is the correct choice.
A result that is wrong by an exact factor of ten, a hundred or a similar round number is almost always a units error rather than a mistake in the formula itself — checking each input against the unit stated beside it is the fastest way to track it down.
Whether the association between two categorical variables is stronger than chance would explain. It does not indicate direction or strength — use the odds ratio or relative risk for that.
It was designed for small samples and is now generally considered too conservative. With adequate cell counts the uncorrected statistic is fine; with inadequate counts, use Fisher's exact test rather than correcting.
The answer it gives you is chi-square statistic. With 218 group 1, outcome present, 4,982 group 1, outcome absent and 263 group 2, outcome present, that comes to 4.883. Change any field and the figure moves with it.
Generally, no more than the least precise input justifies — a result reported to six decimal places from inputs measured to two significant figures is implying a precision the calculation does not actually have. The calculator shows full precision so you can round appropriately for your own use.
Yes — the equation shown in the formula section above is the standard form used in textbooks and reference material for this calculation, not a simplified or approximate version.
Yes, in the sense that it applies the correct standard formula and returns an accurate result for the inputs given — but check your own course or publication's requirements for how results should be rounded, presented and referenced, since those conventions vary and are not something a calculator can know on your behalf.