Chi-Square Test of Independence

Decision-First Design

Test whether two categorical variables are associated using a contingency table. Get instant decision guidance with traffic light indicators, effect sizes, and business-ready interpretations.

👨‍🏫 Professor Mode: Guided Learning Experience

New to chi-square tests? Enable Professor Mode for step-by-step guidance through testing independence between categorical variables!

QUICK START: Choose Your Path

DATA SOURCE

📚

Use a Case Study

💼 Real Marketing Chi-Square Tests

Select a preset scenario to explore real-world independence tests with authentic marketing data and business context.

📤

Load Data

Upload a contingency table

Provide a CSV/TSV where the first row lists column headers, the first column lists row labels, and every other cell contains observed counts.

Drag & Drop raw data file (.csv, .tsv, .txt, .xls, .xlsx)

Contingency table format: first row = column headers, first column = row labels, remaining cells = counts.

No contingency table uploaded yet.

Upload raw data

Upload row-level observations with exactly two columns (category for variable A, category for variable B). We will aggregate them into a contingency table.

Drag & Drop raw data file (.csv, .tsv, .txt, .xls, .xlsx)

Two categorical columns with headers (Variable A, Variable B); up to 5,000 rows.

No raw file uploaded yet.

INPUTS & SETTINGS

Design your table

Observed Counts

Shows a small label under each input.

Confidence Level & Advanced Settings

Advanced settings
Options for special cases and small samples.
Use for small-sample 2×2 tables to reduce bias.

YOUR DECISION

⏳

Enter data to see your result

We'll calculate whether the variables are independent or associated

VISUAL OUTPUT

Stacked 100% Bar Chart

Visualization Settings
Bars show 100% stacked proportions by the chosen X variable.

Reverse the stacking so the bottom segment moves to the top.

TEST RESULTS

Chi-square (χ²): –
Degrees of freedom: –
p-value (upper tail): –
Effect size (Cramér's V): –
Decision (α): –
Interpretation: –

APA-Style Statistical Reporting

Managerial Interpretation

OVERVIEW & WHAT THIS TOOL SOLVES

When you cross-tabulate two categorical variables—such as Acquisition Channel × Checkout Outcome or Customer Tier × Plan Choice—some cells always look higher or lower than average. Eyeballing row percentages cannot tell you whether the pattern is real association or random sampling chatter. The Chi-Square Test of Independence compares your observed cell counts against the counts expected if the two variables were completely unrelated, pinpointing exactly which cells drive the relationship.

🎯 Questions It Answers

  • Are two categorical variables statistically independent, or does knowing a customer's row category shift their column probabilities?
  • How strong is the overall association on a 0-to-1 scale (Cramér's V)?
  • Which specific cells in the table are significantly over- or under-indexing (standardized Pearson residuals)?

📂 What Data You Need

  • Contingency Table Mode: Raw observed frequency counts (O_{ij}) across R rows and C columns
  • Raw CSV Upload: Individual customer records with two categorical columns (automatically cross-tabulated)
  • Sample Adequacy: Mutually exclusive categories with expected counts ideally E_{ij} ≥ 5

💡 What You'll Discover

  • Omnibus Chi-Square Test: Pearson's χ² statistic, degrees of freedom (R−1)(C−1), and exact p-value
  • Cramér's V Effect Size: Sample-size-normalized association strength with clear business benchmarks
  • Cell-Level Diagnostics: Expected counts table, cell contributions to χ², and standardized residuals
🔍 Key Nuances & Common Traps to Watch For
  • Always Enter Raw Counts, Never Percentages: Rescaling a table to 100% hides whether your data came from 50 shoppers or 50,000 shoppers. Enter raw headcounts and let the tool compute row/column proportions.
  • Check Expected Counts, Not Just Observed Counts: The chi-square distribution approximation relies on expected cell counts (E_{ij} ≥ 5 in at least 80% of cells). When cells are sparse, merge rare categories.
  • Inspect Cell Residuals After a Significant Result: An omnibus p < 0.05 tells you somewhere in the table departs from independence; cells with standardized residuals beyond ±1.96 reveal which specific segment × outcome pairings are driving the effect.
📐 Under the Hood: Model Equations & Variable Definitions

1. Independence Expected Counts & Pearson Chi-Square Statistic

\[ E_{ij} = \frac{R_i \cdot C_j}{N}, \qquad \chi^2 = \sum_{i=1}^{R}\sum_{j=1}^{C} \frac{(O_{ij} - E_{ij})^2}{E_{ij}}, \qquad df = (R - 1)(C - 1) \]

💬 Read it in plain English: For every cell, we calculate the count expected if row and column traits were independent (row total × column total ÷ grand total), then sum the squared gaps between observed and expected counts relative to expected size.

Oij
Observed Cell CountYOUR DATA ⓘ
Actual number of observations falling in row i and column j.
Ri, Cj, N
Row, Column & Grand TotalsYOUR DATA ⓘ
Marginal row sum R_i, column sum C_j, and total table sample size N.
Eij
Expected Cell Count under H₀ESTIMATED ⓘ
Count predicted in cell (i, j) if the row and column variables were independent.
χ2
Pearson Chi-Square StatisticINFERENCE ⓘ
Total scaled discrepancy across all R × C cells, evaluated at df = (R − 1)(C − 1).

2. Cramér's V Effect Size & Standardized Cell Residual

\[ V = \sqrt{\frac{\chi^2}{N \cdot \min(R - 1,\, C - 1)}}, \qquad r_{ij} = \frac{O_{ij} - E_{ij}}{\sqrt{E_{ij}(1 - R_i/N)(1 - C_j/N)}} \]

💬 Read it in plain English: Cramér's V scales the chi-square statistic by sample size N and table dimensions onto a 0-to-1 scale, while the standardized residual r_{ij} acts like a cell-level z-score showing which cells over- or under-perform.

R, C
Table DimensionsYOUR DATA ⓘ
Number of row categories R and column categories C in the contingency table.
V
Cramér’s V Effect SizeOUTPUT ⓘ
Normalized strength of association from 0 (independent) to 1 (perfectly associated).
rij
Adjusted Standardized ResidualINFERENCE ⓘ
Cell-specific z-score; values beyond ±1.96 flag significant departure at α = 0.05.

DIAGNOSTICS & ASSUMPTIONS

Diagnostics & Assumption Tests

Enter observed counts to check sample size, expected counts, and leverage diagnostics.

Expected Counts

What are expected counts?

Under the null hypothesis (independence), the expected count for each cell is what we would anticipate from the row and column totals alone. These expected values are used in the chi-square statistic by comparing observed and expected counts and summing the squared differences scaled by the expected value: χ² = Σi,j (Oij − Eij)²Eij. When many expected counts are small (e.g., < 5), results should be interpreted with caution.