What this is for: Tests of independence for 2×2 tables (with odds ratio and relative risk + 95% CIs) and tables up to 4×4, with expected counts shown.
The formula: χ² = Σ (observed − expected)² ÷ expected; expected = row total × column total ÷ grand total
How to use:
- For a 2×2 comparison, enter the four observed counts a, b, c and d in Section A as labelled.
- Read the expected counts, χ², df and p-value, then the odds ratio and relative risk with their 95% CIs and the row proportions.
- For a larger table, paste the counts in Section B, one row per line with counts separated by spaces or commas (up to 4 rows × 4 columns), leaving unused rows and columns blank.
- Read that table's χ², df and p-value; if any expected count is below 5, prefer Fisher's exact test instead, as the workbook notes.
A. 2×2 Table — with odds ratio & relative risk (95% CI)
Observed counts. Expected counts, chi-square, df and p are computed from the table.
Row totals (Treated / Control) /
Column totals (YES / NO) /
Expected (Treated YES / NO) /
Expected (Control YES / NO) /
Chi-square statistic
df
p-value
Significance
Odds ratio (OR)
OR 95% CI –
Relative risk (RR)
RR 95% CI –
Treated proportion YES / NO /
Control proportion YES / NO /
B. Up to 4×4 Table
One row per line, counts separated by spaces or commas (up to 4 rows × 4 columns). Leave unused rows/columns blank — as in the workbook, the worked example is a 3×3 table inside the 4×4 grid.
Chi-square statistic (table)
df
p-value
Significance
Grand total
Prefer to work offline or keep a copy? The download link is right below.
Download the Chi-Square Contingency Tables workbook (.xlsx)
Download the Chi-Square Contingency Tables workbook (.xlsx)
Notes & limits (from the workbook): For any expected count < 5, prefer Fisher's exact test. The chi-square here is the uncorrected Pearson statistic (Excel CHIDIST p-value), exactly as in the workbook. The 4×4 section's df counts only rows and columns with a positive total, matching the workbook formulas.