Contingency (Ctrl+Alt+C)¶

When to use it¶
2-D contingency table analysis for two categorical columns: row/column proportion chart, counts/expected table, and test statistics. Use for Nominal or Ordinal modeling type; continuous columns are not expected (the table uses text/int/float labels).
GUI workflow¶
- Press
Contingency (Ctrl+Alt+C)— Launch Dialog opens with Contingency active. - Roles:
Y, Response *(single, required),X, Factor *(single, required),By(multiple, optional),Weight,Freq(optional). - Assign Y and X via the picker. Both columns are treated as categories.
- Run opens the floating report window.
Floating report window¶
- Proportion Chart — stacked-horizontal bars (one bar per row-level, segmented by column-level proportions, color-coded by column).
- Contingency Table — counts with per-row totals (
x_levelsas rows,y_levelsas columns, "Total" column). - Test Statistics — n, table dimensions (e.g.
3 x 4), Chi² statistic / df / p-value.
Header ... menu: Toggle CI/PI, Save Residuals, Save Script to Table, Export SVG, Export JSON. Hidden rows are omitted before the table is built.
Mathematical formulation¶
Contingency table \(n_{ij}\) with row totals \(r_i\), column totals \(c_j\), grand total \(N = \sum_{i,j} n_{ij}\). Expected counts:
Pearson chi-square:
with \(p\) from the chi-square \((r-1)(c-1)\) distribution.
Likelihood-ratio (G-test) statistic:
Proportions: row proportion \(n_{ij}/r_i\) and column proportion \(n_{ij}/c_j\). Cramér's \(V\):
For 2×2 tables only, Fisher's exact test and the odds ratio with a 95% (configurable via CLI --confidence) interval are reported by the CLI; Haldane-Anscombe correction is applied when any expected count is below 5.
CLI parity — exact flags¶
Contingency (Ctrl+Alt+C) — Launch Dialog → Run.
leap contingency data.csv --rows <col> --cols <col> [--confidence <c>]
Default --confidence is 0.95. JSON output: row_labels, col_labels, counts, expected, row_totals, col_totals, grand_total, chi_square (statistic / df / p_value), likelihood_ratio (statistic / df / p_value), cramer_v, and — only for 2×2 tables — fisher_exact (p_value) and odds_ratio (odds_ratio, log_odds_se, confidence_interval, haldane_anscombe_applied).