Chi-Square Test Calculator

Build contingency tables, compare distributions, and quantify deviations. Automatic degrees of freedom, exact p-values, and interpretations helpful. Import or edit data, preview results, and export records. Download CSV, generate printable PDFs, or share summary links. Accessible layout with white theme for clean, focused work.

Go to Calculator Formulas Used How to Use Example Data

Calculator


×
For independence tables
For goodness-of-fit

Contingency Table (Observed)

Enter non-negative counts. Row/column totals computed automatically.

Observed Counts

Expected Counts

Provide expected counts or set uniform expectations.

Formulas Used

Chi-square statistic: χ² = Σ (Oᵢ − Eᵢ)² / Eᵢ, summing over cells or categories.

  • Independence: Eᵢⱼ = (rowᵢ total × colⱼ total) / N, df = (r−1)(c−1), optional Yates correction for 2×2.
  • Goodness-of-fit: user-provided expectations, df = k − 1 − m, where m is parameters estimated from data.
  • p-value: P(Χ² ≥ χ² | df) from the chi-square distribution via regularized gamma functions.
  • Residuals: Pearson (O−E)/√E; adjusted for independence (O−E)/√(E(1−rᵢ)(1−cⱼ)).
  • Effect sizes: φ = √(χ²/N) for 2×2; V = √(χ²/(N·min(r−1,c−1))); C = √(χ²/(χ²+N)).
Rule of thumb: expected counts should generally be ≥ 5 for validity.

How to Use This Calculator

  1. Select the test type and adjust alpha, precision, and options.
  2. Set table size or categories, then enter observed counts.
  3. For independence, optionally enter row/column labels.
  4. For goodness-of-fit, enter expected counts or choose uniform.
  5. Click Calculate to view χ², df, p-value, and details.
  6. Export results as CSV or PDF, or save/load your JSON setup.

Example Data Table

Try these to verify calculations quickly.

Independence example (2×2)
A/B vs Yes/No:
YesNo
A1020
B3040
Goodness-of-fit example (k=4)
Observed [18, 22, 20, 40], Expected uniform:

FAQs

When should I use the test of independence?

Use it to check association between two categorical variables in a contingency table. Counts, not percentages. Adequate expected counts (ideally ≥5). Null states variables are independent; alternative states association exists.

When should I use goodness‑of‑fit?

Use it to compare one categorical distribution to a specified target distribution. Provide expected counts or proportions scaled to the observed total. Degrees of freedom are categories minus one minus parameters estimated from data.

What if expected counts are small?

If many expected counts are below five, combine sparse categories if substantively reasonable. For 2×2 tables, you may enable Yates continuity correction or consider Fisher’s exact test. Report limitations clearly and interpret results cautiously.

How do I interpret residuals?

Pearson residuals show standardized cell deviations from expectation. Adjusted residuals account for row and column proportions; values beyond about ±2 often flag influential cells. Use them to locate categories contributing most to the overall chi‑square statistic.

Which effect size should I report?

For general r×c tables, report Cramér’s V. For 2×2 tables, Phi is common; you may also show the contingency coefficient. Interpret magnitudes using discipline‑specific conventions rather than fixed universal thresholds.

Can I paste percentages instead of counts?

Please enter raw counts. If you only have percentages, multiply each percentage by a common base total to obtain integer or fractional counts, ensuring the scaled expected counts align with the observed total.

Reference & Insights

Assumptions and Conditions

  • Independent observations; each subject appears in one cell only.
  • Expected counts ideally ≥ 5 in at least 80% of cells; none extremely small.
  • Data are frequencies (counts), not percentages or continuous values.
  • For 2×2 with small expectations, consider Yates correction or exact tests.

Quick Interpretation Guide

p-valueDecision at α=0.05Effect size cue*
< 0.001Strong evidence against nullOften noticeable association
0.001–0.01Moderate–strong evidenceCheck residuals for drivers
0.01–0.05Some evidenceInterpret with domain context
> 0.05Insufficient evidenceEffect may be small/absent
*Use Cramér’s V for general r×c; Phi for 2×2.

Typical Use Cases

  • Independence: Marketing channel vs conversion; Treatment group vs outcome.
  • Goodness-of-fit: Quality control category frequencies vs targets; Survey response distribution vs uniform.
  • Diagnostics: Examine large adjusted residuals to identify influential cells.

Related Calculators

Inverse Function Finder CalculatorPolynomial Long Division Calculatorroots of cubic equation calculatorquadratic function from 3 points calculatorWeighted linear regression calculatorremainder and factor theorem calculatordivide using long division calculatorsynthetic division remainder calculatorLCM fraction Calculatorfactor polynomials by grouping calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.