Statistics

Chi-square Test of Independence from a CSV or Excel File

Test whether two categorical columns are related. Contingency table, p-value, Cramér's V and Fisher's exact test — no manual counting.

Drag & Drop your file here

or browse files | paste raw data


Example
TreatmentOutcome
DrugCured
PlaceboNot cured
DrugCured
PlaceboCured
……
TreatmentCuredNot cured
Drug3010
Placebo1822
χ²(1) = 6.30p = 0.012empty

Raw rows are counted into a contingency table and tested.

Learn More

How to Run a Chi-square Test

A complete guide to configuring your data pipeline.

Step 1: Upload Raw Observations

The chi-square test works on one row per observation, with two categorical columns — for example Treatment (drug / placebo) and Outcome (cured / not cured). You do not need to build the contingency table yourself: flowingTable counts the combinations for you.

Step 2: Choose the Two Columns

Open the Chi-square Test tool, select the two category columns and click Run test. Columns with more than 30 different values are rejected, since they are almost certainly not categories.

Step 3: Read the Contingency Table

The result shows the χ² statistic, degrees of freedom, p-value and Cramér's V (the strength of the association), followed by the observed counts with row and column totals. For a 2 × 2 table with small expected counts, Fisher's exact test is added automatically.

Technical Specifications & FAQ

The chi-square test of independence compares the observed counts in each combination of categories with the counts expected if the two variables were unrelated. A small p-value means the distribution of one variable differs across the levels of the other — for example, that the cure rate differs between drug and placebo.

flowingTable uses SciPy's chi2_contingency, with Yates' continuity correction for 2 × 2 tables, matching R's chisq.test(). The approximation behind the test becomes unreliable when expected counts are small, so the result warns you when more than 20% of the cells have an expected count below 5 and, for 2 × 2 tables, also reports fisher_exact.


Frequently Asked Questions

Do I need to create a contingency table first?

No. Upload the raw data with one row per observation and select the two category columns. flowingTable builds the contingency table, including totals, and shows it in the result. If you only want the table of counts, the Pivot Table tool can produce it as a new step.

When should I use Fisher's exact test instead?

When the sample is small and some expected counts are below 5, the chi-square approximation can be inaccurate. For 2 × 2 tables flowingTable then adds Fisher's exact test automatically. For larger tables, consider merging rare categories with the Find & Replace tool.

What does Cramér's V measure?

Cramér's V is the strength of the association, from 0 (no association) to 1 (perfect association), and does not depend on the sample size. As a rough guide, values around 0.1 are weak, 0.3 moderate and 0.5 or more strong. With very large samples even a tiny V can be significant, so look at both numbers.

Can I use the chi-square test on numeric data?

Only if the numbers are codes for categories (such as 1 = male, 2 = female) or have been grouped into bins. For continuous measurements, use a t-test, ANOVA or correlation instead.