test_categorical
Test categorical data with chi-square independence, goodness-of-fit, or McNemar, including effect sizes and plots. Automatically switches to Fisher's exact for small samples.
Instructions
Tests for categorical data. With x and y: a chi-square test of independence with the contingency table, expected counts, standardised residuals, Cramer's V, and - for 2x2 tables - the odds ratio, risk ratio and phi. Fisher's exact test is added automatically when expected counts are too small. With x only: a goodness-of-fit test against expected_probs (uniform by default). Set test='mcnemar' for paired binary data.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | First categorical column. | |
| y | No | Second categorical column; omit for a goodness-of-fit test. | |
| data | Yes | Dataset name in the session. | |
| test | No | auto, chisq, fisher or mcnemar. | auto |
| plots | No | Include a mosaic or bar plot. | |
| digits | No | Decimal places. | |
| correct | No | Apply Yates' continuity correction to 2x2 tables. | |
| expected_probs | No | Expected proportions per level for a goodness-of-fit test; one value per level. |