Skill: choose-statistical-test
Invoked by: applied-statistician (primary). Also consulted by experiment-analysis and statistical-qa-of-metrics when they need to name the underlying test.
When to invoke: "which test should I use?"; "is the difference between these groups significant?"; any comparison of 2+ groups or relationship between 2 variables.
Output: the recommended test + the assumption checks that gate it + the nonparametric fallback + a short runnable snippet (method-before-library) + the effect-size/CI to report alongside.
Procedure
- Restate the question in the tree's terms: is it a group difference, a relationship, or a prediction?
- Traverse the decision tree in
../../knowledge/test-selection-decision-tree.md against:
- outcome data type (continuous / categorical / ordinal / count / time-to-event),
- number of groups (1 / 2 / 3+),
- paired vs independent,
- the assumption gate (normality, equal variance, independence).
- Name the method first, the library second. Resolve to the parametric leaf only if the assumption gate passes; otherwise take the nonparametric fallback.
- Emit a ≤10-line snippet (Tier-1 tooling —
scipy.stats / pingouin / statsmodels; see ../../knowledge/statistics-tooling-2026.md) that (a) checks the assumption, (b) runs the test, (c) reports effect size + CI, not just p.
- State the fallback explicitly: "if normality fails, switch to ."
Worked example
User: "I have conversion counts for two landing pages. Which test?"
- Question type: group difference. Outcome: the per-user binary "converted?" → two independent groups, categorical outcome → chi-square test of independence (Fisher's exact if any expected cell < 5).
- If instead the outcome were a continuous per-user value (e.g., revenue) and roughly normal → independent t-test (Welch if variances differ); non-normal → Mann-Whitney U.
- Report: the effect (e.g., difference in conversion rate or odds ratio) with a confidence interval, not just the p-value.
# two landing pages, conversion counts — chi-square of independence
import numpy as np
from scipy.stats import chi2_contingency
# rows = page A / page B; cols = converted / not
table = np.array([[120, 1880], [150, 1850]])
chi2, p, dof, expected = chi2_contingency(table)
if (expected < 5).any():
from scipy.stats import fisher_exact # small expected cells → exact test
_, p = fisher_exact(table)
# report the effect (rate difference + CI), not just p — see experiment-analysis skill
Guardrails
- Never return a parametric test without naming its assumption check and its fallback.
- 3+ groups → ANOVA/Kruskal-Wallis + a multiplicity-correcting post-hoc, never a stack of pairwise t-tests (pitfall #2).
- Always pair the result with an effect size + CI (pitfall #6). See
../../knowledge/statistical-pitfalls.md.
1---2name: choose-statistical-test3description: 'Pick the right hypothesis test for a described scenario by traversing the test-selection decision tree (data type → #groups → paired? → assumption gate → test), then return the recommended test, its assumption checks, its nonparametric fallback, and a ≤10-line runnable snippet. Reach for this when the user asks "which test do I use?" or hands over two-or-more groups/variables to compare. Used by `applied-statistician` (primary).'4metadata:5 source: https://skillmd.com/skills/mcorbett51090/choose-statistical-test6---78# Skill: choose-statistical-test910> **Invoked by:** `applied-statistician` (primary). Also consulted by `experiment-analysis` and `statistical-qa-of-metrics` when they need to name the underlying test.11>12> **When to invoke:** "which test should I use?"; "is the difference between these groups significant?"; any comparison of 2+ groups or relationship between 2 variables.13>14> **Output:** the recommended test + the assumption checks that gate it + the nonparametric fallback + a short runnable snippet (method-before-library) + the effect-size/CI to report alongside.1516## Procedure17181. **Restate the question** in the tree's terms: is it a *group difference*, a *relationship*, or a *prediction*?192. **Traverse the decision tree** in [`../../knowledge/test-selection-decision-tree.md`](../../knowledge/test-selection-decision-tree.md) against:20 - outcome **data type** (continuous / categorical / ordinal / count / time-to-event),21 - **number of groups** (1 / 2 / 3+),22 - **paired vs independent**,23 - the **assumption gate** (normality, equal variance, independence).243. **Name the method first, the library second.** Resolve to the parametric leaf only if the assumption gate passes; otherwise take the nonparametric fallback.254. **Emit a ≤10-line snippet** (Tier-1 tooling — `scipy.stats` / `pingouin` / `statsmodels`; see [`../../knowledge/statistics-tooling-2026.md`](../../knowledge/statistics-tooling-2026.md)) that (a) checks the assumption, (b) runs the test, (c) reports **effect size + CI**, not just p.265. **State the fallback explicitly:** "if normality fails, switch to <nonparametric test>."2728## Worked example2930> User: "I have conversion counts for two landing pages. Which test?"3132- Question type: group difference. Outcome: the per-user binary "converted?" → **two independent groups, categorical outcome** → **chi-square test of independence** (Fisher's exact if any expected cell < 5).33- If instead the outcome were a continuous per-user value (e.g., revenue) and roughly normal → independent t-test (Welch if variances differ); non-normal → Mann-Whitney U.34- Report: the effect (e.g., difference in conversion rate or odds ratio) **with a confidence interval**, not just the p-value.3536```python37# two landing pages, conversion counts — chi-square of independence38import numpy as np39from scipy.stats import chi2_contingency40# rows = page A / page B; cols = converted / not41table = np.array([[120, 1880], [150, 1850]])42chi2, p, dof, expected = chi2_contingency(table)43if (expected < 5).any():44 from scipy.stats import fisher_exact # small expected cells → exact test45 _, p = fisher_exact(table)46# report the effect (rate difference + CI), not just p — see experiment-analysis skill47```4849## Guardrails50- Never return a parametric test without naming its assumption check **and** its fallback.51- 3+ groups → ANOVA/Kruskal-Wallis + a multiplicity-correcting post-hoc, **never** a stack of pairwise t-tests (pitfall #2).52- Always pair the result with an effect size + CI (pitfall #6). See [`../../knowledge/statistical-pitfalls.md`](../../knowledge/statistical-pitfalls.md).