Crosstab Calculator
A crosstab, or contingency table, is the basic summary table that lays the joint distribution of two categorical variables out across rows and columns. Questions such as "preference by gender" in survey data or "outcome by group" in clinical data are read off this table first; it is the job done by SPSS Crosstabs, R's table(), and an Excel pivot table.
This tool does more than stack up frequencies: for every cell it computes the expected frequency, the row percentage, the column percentage, and the total percentage. It then runs the chi-square test of independence and reports χ², the degrees of freedom, the p-value, the critical value, Cramer's V as an effect size, and the adjusted residuals that show which cell produced the difference. A warning appears whenever a cell's expected frequency drops below 5.
Crosstab and Chi-Square Formulas
Expected frequency: Eᵢⱼ = (nᵢ. × n.ⱼ) / N Row percentage: %row = nᵢⱼ / nᵢ. × 100 Column percentage: %col = nᵢⱼ / n.ⱼ × 100 Total percentage: %total = nᵢⱼ / N × 100 Chi-square: χ² = Σᵢ Σⱼ (nᵢⱼ − Eᵢⱼ)² / Eᵢⱼ Degrees of freedom: df = (r − 1)(c − 1) Adjusted residual: zᵢⱼ = (nᵢⱼ − Eᵢⱼ) / √[Eᵢⱼ(1 − nᵢ./N)(1 − n.ⱼ/N)] Cramer's V: V = √[χ² / (N · min(r − 1, c − 1))]
Do not confuse the standardized residual (nᵢⱼ − Eᵢⱼ)/√Eᵢⱼ with the adjusted residual: only the adjusted residual is approximately standard normal and can be read against the ±1.96 threshold. It is the "Adjusted Residual" row in the SPSS Crosstabs output.
How to Calculate
- Write each row of your crosstab on its own line, separating the cell frequencies with commas or spaces.
- To name a row category, start the line with a label such as "Women:"; enter the column names, comma separated, in the second box.
- Choose the percentage you want to see in the table: row percentages for comparison, column percentages to show composition.
- Compare the observed and expected frequency of each cell in the results table, and read which cell produced the difference from the adjusted residual row.
- Report χ², df, p, and Cramer's V together; even with a significant p-value, a small effect size can make the association practically unimportant.
- If the expected-frequency warning appears, merge categories, enlarge the sample, or switch to Fisher's exact test in a 2×2 table.
Worked Examples
Gender × product preference (2×2)
In a 100-person sample every expected frequency is 25.00. The result is χ²(1) = 4.00, p = 0.046, and Cramer's V = 0.200 (a weak association); with a critical value of 3.841 the result is significant at α = 0.05. 60.0% of the first row category chose product A and 60.0% of the second chose product B, and every cell has an adjusted residual of ±2.00.
Table size: 2 × 2 · Total observations (N): 100 · Chi-square statistic (χ²): 4.000
Education level × smoking (3×2)
There are 50 people at each of the three education levels, for N = 150 observations. The result is χ²(2) = 9.375, p = 0.009, and Cramer's V = 0.250; with a critical value of 5.991 the association is significant. The strongest departure is in the university-by-smoker cell (adjusted residual 2.89): more people in that group smoke than expected.
Table size: 3 × 2 · Total observations (N): 150 · Chi-square statistic (χ²): 9.375
Expected-frequency warning in a small sample (3×3)
With N = 67 observations, χ²(4) = 2.381, p = 0.666, and Cramer's V = 0.133; the critical value is 9.488, so the association is not significant. Because the smallest expected frequency is 2.51 and 2 of the 9 cells (22%) fall below an expected frequency of 5, the tool issues a warning: the p-value for this table is only approximate.
Table size: 3 × 3 · Total observations (N): 67 · Chi-square statistic (χ²): 2.381