Chi-square test calculator (contingency tables)
The chi-square test of independence checks whether two categorical variables are associated, using a table of counts. For 2×2 tables DATAJIN also gives Fisher’s exact test (accurate for small counts), the odds ratio, the relative risk and the risk difference, with optional Yates continuity correction.
No sign-up, nothing to install. Calculations run in your browser; the worksheets, results and charts you create are stored by AI Walay to improve DATAJIN.
When to use it
- Comparing proportions between groups, such as recovery rates under two treatments.
- Testing whether two categorical variables (smoking and disease, gender and preference) are related.
Assumptions
- The table contains counts (frequencies), not percentages or means.
- Each subject is counted in exactly one cell.
- Chi-square needs expected counts of about 5 or more in most cells; otherwise use Fisher’s exact test (2×2).
How to run it in DATAJIN
- Enter the contingency table: each column is a category of one variable, each row a category of the other, and each cell a count.
- Open Analyze and choose Chi-square (contingency).
- Select the count columns, choose whether to apply the Yates correction for 2×2 tables, and click Run.
What you get
- Chi-square statistic, degrees of freedom, p-value, Cramér's V and N
- For 2×2 tables: Fisher's exact p-value (two-tailed), odds ratio, relative risk and risk difference
How to interpret the result
A p-value below 0.05 means the variables are associated. Cramér's V gives the strength of the association from 0 (none) to 1 (perfect); roughly 0.1 is weak, 0.3 moderate and 0.5 strong. For 2×2 tables with small counts, report Fisher's exact p-value.
Frequently asked questions
When should I use Fisher's exact test instead of chi-square?
When the table is 2×2 and any expected count is below 5, which is common with small samples. Fisher’s test is exact and does not rely on a large-sample approximation.
Should I use the Yates correction?
Yates’ continuity correction makes the 2×2 chi-square test more conservative. Many statisticians now prefer no correction for large samples and Fisher’s exact test for small ones.
Can I enter raw data instead of counts?
The test needs a table of counts. Count how many observations fall in each combination first (a pivot table in Excel does this).