Binary Outcome --- Class Balance Diagnostics & Association Testing
Table of Contents
Open-source skill.
Scope Boundary
Use this skill when:
- The outcome is a single binary endpoint and the first need is a defensible descriptive / inferential baseline.
- The main question is a cross-sectional association or simple group comparison, not a full prediction workflow.
Do not use this skill when:
- The design is paired, matched, or otherwise within-subject; use
vera-data-repeated-reviewing.
- The target is ordinal, nominal, count, survival, or time-to-event rather than binary.
Workflow
Read each step file in workflow/ before executing that step.
| Step |
Responsibility |
Executor |
Document |
Input |
Output |
| Collect |
Collect Inputs |
Main Agent |
workflow/step01-collect-inputs.md |
User input |
Structured input summary |
| Diagnose |
Check Distribution |
Main Agent |
workflow/step02-check-distribution.md |
Prior step output |
PART 1 code block |
| Test |
Run Primary Test |
Main Agent |
workflow/step03-run-primary-test.md |
Prior step output |
PART 2-3 code blocks |
Decision Tree
1. CHECK CLASS BALANCE
├── Balanced (minority ≥ 10%) → standard tests
└── Imbalanced (minority < 10%) → rare event warning, note power limits
2. PRIMARY ASSOCIATION TEST
├── All cells ≥ 5 → Chi-square + Cramer's V + OR
└── Any cell < 5 → Fisher's exact + OR
Required Inputs
| Role |
What to collect |
| Outcome (Y) |
Variable name, what 0/1 represents |
| Primary group variable |
What defines groups, how many levels |
| Predictors |
For recommendation block (not executed) |
| Covariates |
For recommendation block (not executed) |
Code Structure
PART 0: Setup & Data Loading
PART 1: Class Balance Diagnostics → plot_01_class_balance.png
PART 2: Primary Association Test → plot_02_mosaic_[var].png
PART 3: Recommendation Block → text listing additional analyses available
Reporting Standards
- p-values: "< .001" not "0.000"; exact to 3 decimals otherwise
- Effect sizes: Cramer's V (chi-square), odds ratio with 95% CI
- Odds ratios: always as "OR = X.XX, 95% CI [X.XX, X.XX]"
- Proportions: report as percentages with 1 decimal
- Chi-square: chi-sq(df) = X.XX, p = .XXX, Cramer's V = .XXX
- Degrees of freedom: always with chi-square statistic
- Sample size: final analytic N
- Decimal places: 1 for proportions, 2 for OR, 3 for p and effect sizes
- Non-significance: "not statistically significant at alpha = .05" --- never "no association"
Hypothesis Tests
| Scenario |
Expected cells all >= 5 |
Any expected cell < 5 |
| 2x2 or 2xK |
Chi-square + Cramer's V |
Fisher's exact test |
Paired/matched binary designs -> vera-data-repeated-reviewing (handles within-subject comparisons including paired binary data via McNemar's test).
Example Dataset
R built-in Titanic (convert to data frame): outcome = Survived (0/1), predictors = Class, Sex, Age.
Python: sm.datasets.get_rdataset("Titanic").data or reconstruct from counts (offline fallback uses base R Titanic dataset).
Method Status
| Status |
Methods |
| Implemented in this skill |
Class-balance diagnostics, chi-square / Fisher's exact testing, Cramer's V, odds ratio with 95% CI |
Implemented downstream in vera-data-binary-generating |
Additional association tests, stratified odds ratios, logistic regression, ROC/AUC summaries, exploratory tree-based models |
| Out of scope in this open-source baseline |
Matched binary workflows, causal estimands, and any binary method not named above |
Minimal Smoke Test
- Smoke-test prompt: "Run
vera-data-binary-reviewing on Titanic, treating Survived as the outcome and Sex as the primary grouping variable. Produce the standard baseline artifacts."
Cross-Skill Interface
Output:
├── code_r → .R script
├── code_python → .py script
├── figures/ → 2 PNGs (class balance + mosaic/grouped bar)
└── recommendations → text block (additional analyses available)
Next step: Invoke vera-data-binary-generating from this skillset to run the full pipeline (additional tests, subgroup analysis, modeling, manuscript generation). See ../../CROSS-SKILL-INTERFACE.md for the shared handoff contract.
1---2name: vera-data-binary-reviewing3description: Runs class balance diagnostics and primary association tests for binary outcome variables (0/1, yes/no, survived/died, pass/fail). Produces proportion tables, class balance check with rare-event warning, descriptives by outcome level, chi-square test of independence with Cramer's V, Fisher's exact test when cell counts are small, odds ratio with 95% CI, and a mosaic or grouped bar chart. Outputs .R and .py scripts with 2 publication-quality plots. Triggered when user has a binary/dichotomous outcome and says "binary outcome," "survived or died," "yes or no," "pass or fail," "0/1," "classification," "binary DV," or names a binary variable like survived, admitted, defaulted, churned, diagnosed. Does not handle continuous, count, survival time, ordinal, repeated measures, or SEM.4---56# Binary Outcome --- Class Balance Diagnostics & Association Testing78## Table of Contents910- [Scope Boundary](#scope-boundary)11- [Workflow](#workflow)12- [Decision Tree](#decision-tree)13- [Required Inputs](#required-inputs)14- [Code Structure](#code-structure)15- [Reporting Standards](#reporting-standards)16- [Hypothesis Tests](#hypothesis-tests)17- [Example Dataset](#example-dataset)18- [Method Status](#method-status)19- [Minimal Smoke Test](#minimal-smoke-test)20- [Cross-Skill Interface](#cross-skill-interface)212223Open-source skill.2425## Scope Boundary2627Use this skill when:28- The outcome is a single binary endpoint and the first need is a defensible descriptive / inferential baseline.29- The main question is a cross-sectional association or simple group comparison, not a full prediction workflow.3031Do not use this skill when:32- The design is paired, matched, or otherwise within-subject; use `vera-data-repeated-reviewing`.33- The target is ordinal, nominal, count, survival, or time-to-event rather than binary.3435## Workflow3637Read each step file in `workflow/` before executing that step.3839| Step | Responsibility | Executor | Document | Input | Output |40|---|---|---|---|---|---|41| Collect | Collect Inputs | Main Agent | `workflow/step01-collect-inputs.md` | User input | Structured input summary |42| Diagnose | Check Distribution | Main Agent | `workflow/step02-check-distribution.md` | Prior step output | PART 1 code block |43| Test | Run Primary Test | Main Agent | `workflow/step03-run-primary-test.md` | Prior step output | PART 2-3 code blocks |4445## Decision Tree4647```481. CHECK CLASS BALANCE49 ├── Balanced (minority ≥ 10%) → standard tests50 └── Imbalanced (minority < 10%) → rare event warning, note power limits51522. PRIMARY ASSOCIATION TEST53 ├── All cells ≥ 5 → Chi-square + Cramer's V + OR54 └── Any cell < 5 → Fisher's exact + OR55```5657## Required Inputs5859| Role | What to collect |60|---|---|61| **Outcome (Y)** | Variable name, what 0/1 represents |62| **Primary group variable** | What defines groups, how many levels |63| **Predictors** | For recommendation block (not executed) |64| **Covariates** | For recommendation block (not executed) |6566## Code Structure6768```69PART 0: Setup & Data Loading70PART 1: Class Balance Diagnostics → plot_01_class_balance.png71PART 2: Primary Association Test → plot_02_mosaic_[var].png72PART 3: Recommendation Block → text listing additional analyses available73```7475## Reporting Standards76771. p-values: "< .001" not "0.000"; exact to 3 decimals otherwise782. Effect sizes: Cramer's V (chi-square), odds ratio with 95% CI793. Odds ratios: always as "OR = X.XX, 95% CI [X.XX, X.XX]"804. Proportions: report as percentages with 1 decimal815. Chi-square: chi-sq(df) = X.XX, p = .XXX, Cramer's V = .XXX826. Degrees of freedom: always with chi-square statistic837. Sample size: final analytic N848. Decimal places: 1 for proportions, 2 for OR, 3 for p and effect sizes859. Non-significance: "not statistically significant at alpha = .05" --- never "no association"8687## Hypothesis Tests8889| Scenario | Expected cells all >= 5 | Any expected cell < 5 |90|---|---|---|91| 2x2 or 2xK | Chi-square + Cramer's V | Fisher's exact test |9293Paired/matched binary designs -> `vera-data-repeated-reviewing` (handles within-subject comparisons including paired binary data via McNemar's test).9495## Example Dataset9697R built-in `Titanic` (convert to data frame): outcome = Survived (0/1), predictors = Class, Sex, Age.98Python: `sm.datasets.get_rdataset("Titanic").data` or reconstruct from counts (offline fallback uses base R `Titanic` dataset).99100## Method Status101102| Status | Methods |103|---|---|104| Implemented in this skill | Class-balance diagnostics, chi-square / Fisher's exact testing, Cramer's V, odds ratio with 95% CI |105| Implemented downstream in `vera-data-binary-generating` | Additional association tests, stratified odds ratios, logistic regression, ROC/AUC summaries, exploratory tree-based models |106| Out of scope in this open-source baseline | Matched binary workflows, causal estimands, and any binary method not named above |107108## Minimal Smoke Test109110- Smoke-test prompt: "Run `vera-data-binary-reviewing` on `Titanic`, treating `Survived` as the outcome and `Sex` as the primary grouping variable. Produce the standard baseline artifacts."111112## Cross-Skill Interface113114```115Output:116├── code_r → .R script117├── code_python → .py script118├── figures/ → 2 PNGs (class balance + mosaic/grouped bar)119└── recommendations → text block (additional analyses available)120```121122Next step: Invoke `vera-data-binary-generating` from this skillset to run the full pipeline (additional tests, subgroup analysis, modeling, manuscript generation). See `../../CROSS-SKILL-INTERFACE.md` for the shared handoff contract.