Contingency Table Calculator for Chi-Square

Contingency Table Calculator

Enter a 2x2 or RxC frequency table to calculate row totals, column totals, expected counts, chi-square, degrees of freedom, p-value, and association strength.

📌 Presets

Table Setup

For 2x2 ratios, row 1 is the exposed or treatment group.
For 2x2 ratios, column 1 is the event or positive outcome.
Use spaces, tabs, commas, or semicolons between counts. The paste box fills the grid when you click Apply pasted counts.
Chi-square
0.000
df = 1
p-value
0.0000
Compare with alpha
Association
0.000
Phi or Cramer's V
2x2 Ratios
OR 0.00
RR 0.00

🧮 Diagnostic Grid

-
Total N
-
Rows
-
Columns
-
DF
-
Min Expected
-
Low Expected
-
Top Cell
-
Correction

📋 Observed Counts and Totals

🔢 Expected Counts

🔍 Chi-Square Contributions

📐 Method Reference

OutputFormulaUseApplies ToNull Value
Expected count(row total × column total) / NIndependence model cell countAny RxC tableObserved = expected
Chi-squareSum (O - E)² / EOverall departure from independenceAny RxC table0
Degrees of freedom(rows - 1)(columns - 1)Reference distribution shapeAny RxC tableNot a test value
Phi(ad - bc) / sqrt(r1 r2 c1 c2)Signed association direction2x2 only0
Cramer's Vsqrt(chi-square / (N × min(r - 1, c - 1)))Association strength from 0 to 12x2 or RxC0
Odds ratio(a × d) / (b × c)Odds comparison between rows2x2 only1
Risk ratio[a / (a + b)] / [c / (c + d)]Risk comparison between rows2x2 only1

Practical Checks

Count data only: Chi-square contingency tests use observed frequencies. Do not enter percentages, means, rates, or already-normalized values.
Expected counts: A common screening rule is to inspect expected cells below 5 and especially below 1 before relying on the large-sample chi-square approximation.
2x2 coding: The OR, RR, and phi direction depend on which row is treated as exposed and which column is treated as the event.
Report clearly: For publication-style notes, include N, table dimensions, chi-square, df, p-value, and phi or Cramer's V.
JSCalc-Blog.com: This contingency table calculator uses Pearson chi-square statistics, standard expected counts, a chi-square right-tail p-value approximation, and log-scale confidence intervals for 2x2 odds and risk ratios.

Is there a relationship between two things? That’s the basic question you begin with. Did a medical treatment improve outcomes? Was a marketing email responsible for driving sales? This is the type of question researchers and product managers asks to separate their findings from their hunches.

That separation comes in the form of a contingency table, which is where the chi-square test for independence works. A count table is just a grid of counts. On one axis it has your categories (e.g., control vs. Treatment group) while the other axis shows your outcomes (e.g., recovered vs. Not recovered).

What Is a Chi-Square Test?

The table of raw numbers appear straightforward, yet they’re easily misleading. More is always better… And thus bigger groups has more events simply by virtue of being bigger. Absolute counts don’t help you compare groups. Instead, you need to adjust them to what you’d expect based off the absence of any relationship.

This is something many do not do. They only look at the observed data, ignoring expected data. The calculator does that math for us. It creates the grid and computes the marginal totals. And it determine what the count in each cell ought to be based on idea of independence. Where the observed count is way off from the expected count, you’ve got something. Where they’re close, you’ve got silence.

All those differences are summed into the chi-square statistic. The higher the number, the more the data don’t match the independence model; so, the lower the number, the more they does.

What’s driving the test? Degrees of freedom act as an engine. These factors determine how much variation can occurs in the data. They also determine what distribution we use to evaluate your chi-square score. For example, a two-by-two table has only one degree of freedom. As you add more columns and/or rows, you increase degrees of freedom. Each additional degree of freedom require a higher chi-square score to be significant. You cannot compare scores across tables with varying numbers of degrees of freedom.

To do so, you must look at the p-value. That will tell you probability of randomly encountering the pattern. When it is lower than your pre-set threshold (typically five percent). You’ll call it a relationship.

That is important because strength is not significance. It is a fundamental distinction. If your sample size is large enough, even a small association can be statistically significant. To understand the connection, you require effect size measures. For two-by-two tables, phi and odds ratios indicates both the magnitude and direction. For larger tables, Cramer’s V normalizes the association on a scale from zero to one. The closer it gets to one, the more perfect the prediction; at zero, there is no link. Reporting a p-value without an effect size is like reporting speed without units; you have the number, but you lack the context.

You’ve got the number. But what does it mean?

There are pitfalls with this procedure. Insufficent amounts of data in any one cell will lead to problems using the chi-square approximation. Typically you should of had at least five observations per cell. When it’s less than that, the test isn’t reliable. The calculator notes this and offers an adjustment.

Alternatively, if some cells contain zero, it prevents calculation of the odds ratio because you cannot divide by zero. In such cases, a small constant is added to make the math smooth. Analysis continue even though the data may be sparse.

The key to understanding what happened are the contributions. Which cells is driving that chi-square? Is there a huge overrepresentation of something in one category, or a slight change all around? This is the diagnostic piece that converts a yes/no response to a story. It points you to the action.

Statistics follows a common sense structure: statistics is just structured common sense. You have a hunch about whether something is random or real. And the contingency table provide an unbiased way for you to ask that question. Define your categories. Count up your observations. Let the math do the work.

What’s the verdict? Is there an association or not? You begin with a hunch; you conclude with a finding. The numbers tell you truth.

Contingency Table Calculator for Chi-Square