Chi-Square and Crosstab Calculator

Crosstabs with Pearson chi-square, Fisher exact tests, Cramér V, odds ratios, and Rao-Scott corrections for survey data, in your browser.

What this calculator does

Crosstabs and Tests of Association is Module 2 of Analysis Studio, and it is a free module. It cross-tabulates a row variable against a column variable, with an optional layer variable, and reports:

  • The table with counts and the percentages you choose: row, column, or total
  • Pearson chi-square and the likelihood-ratio G squared
  • Fisher exact test, added automatically for two by two tables with small expected counts
  • Linear-by-linear association for ordinal pairs
  • Effect sizes: Cramér V, phi for two by two tables, odds ratio, relative risk, and risk difference
  • Adjusted residuals, so the cells driving an association are visible
  • Layered analysis with Cochran-Mantel-Haenszel tests and a Breslow-Day homogeneity check

The survey behavior is the point of difference. On weighted survey data, a Pearson chi-square computed on weighted counts gets the uncertainty badly wrong. Under a declared design, this module estimates cell proportions as domain estimates and tests association with the Rao-Scott second-order corrected F test, the standard survey treatment.

The method, in plain terms

The chi-square statistic compares each cell count with the count expected if the two variables were independent, given the margins:

chi-square = sum over cells of (observed − expected)² ÷ expected.

Expected counts are the row total times the column total divided by the grand total. The test asks whether the departures from independence, taken together, exceed what sampling variation explains. Effect sizes then answer the follow-up: Cramér V scales the association between zero and one, and for two by two tables the odds ratio and relative risk put it in the units of the subject.

Worked example

Two groups answer a yes or no question. Group A: fourteen yes, six no. Group B: eight yes, twelve no.

  • Yes rates: 70.0 percent in group A, 40.0 percent in group B
  • Expected counts under independence: eleven yes and nine no in each group
  • Pearson chi-square: 3.636 on one degree of freedom, p = 0.057
  • Cramér V: 0.302
  • Odds ratio: (14 × 12) ÷ (6 × 8) = 3.500

The association is moderate in size and just short of the conventional significance line at this sample size, forty cases. Both facts belong in the report: the effect size says the difference is worth attention, and the p value says forty cases cannot settle it. Doubling the sample at the same rates would settle it, which is a planning statement the sample size planner in Module 7 can price exactly.

When the calculator fits, and when it does not

It fits when:

  • Both variables are categorical and the question is association, not causation.
  • Expected counts are adequate, or the table is two by two, where the Fisher exact test covers the small-count case.
  • The data carry a survey design, where this module applies the Rao-Scott correction instead of pretending weighted counts are raw counts.

It does not fit when:

  • The same cases appear in both groups, as in before-and-after responses. Paired categorical data belong to McNemar and its relatives in Module 8.
  • The variables are continuous. Binning them to force a crosstab discards information; correlation or regression answers the real question.
  • The table is large and sparse. Collapsing categories on subject-matter grounds, or an exact approach where available, beats a chi-square whose expected counts are mostly under one.

Run it

Module 2: Crosstabs and Tests of AssociationOpen in Analysis Studio →

Load your data, pick the row and column variables, choose the percentages the report needs, and read the effect sizes next to the test.

Questions

When does Fisher exact replace chi-square? When expected counts run small, the chi-square approximation coarsens. For two by two tables the module adds the Fisher exact test automatically when expected counts are small, and reports it alongside so the reader sees both.

What does Cramér V of 0.30 mean? A moderate association. The rough conventions for a two by two table are 0.10 small, 0.30 medium, and 0.50 large. Conventions are starting points; a V of 0.30 on a treatment uptake question and the same value on a brand preference question carry different weight, and the report should argue the subject, not just cite the band.

Why not run chi-square on my weighted counts? Because weighted counts are not counts. A sample of 400 weighted to 40,000 would produce a chi-square scaled to a fictional sample of 40,000 and significance to match. The Rao-Scott correction rescales the test to the design that produced the data, which is the only version of the answer worth reporting.

Odds ratio or relative risk? Relative risk compares probabilities directly and reads naturally, where both risks are estimable, as in cohort and experimental data. The odds ratio is the available measure in case-control designs and the natural output of logistic models. The module reports both where both are defined, plus the risk difference, so the report can use the measure its audience reads correctly.

Can I control for a third variable? Yes, through the layer variable. The module builds the table within each layer and adds the Cochran-Mantel-Haenszel test for the common association, with the Breslow-Day test checking whether one common value is a fair summary across layers.

More Analysis Studio Modules