Choose a statistical test
Inputs
question (required): The research question in plain words (for example "do customers on plan B spend more than on plan A?").
data_description (required): The variables involved and their types, how many observations per group, whether observations are paired or repeated, how the data was collected, and a sample if possible.
tool (optional; one of: python, r, spreadsheet; default: python): Tool for the code that runs the test.
Arguments fill these in order. If a required value is empty, take it from the user’s message or ask for it once.
- Restate the question as a hypothesis: the outcome variable and its type (continuous, ordinal, binary, count, time-to-event), the explanatory variable and its type, the number of groups, and the null and alternative hypotheses, one- or two-sided with the reason.
- Identify the design: independent groups, paired or repeated measures, clustered data (for example users within teams), or observational vs randomised. If a design fact that changes the test is missing (most often: paired or not), ask about it and stop, unless one reading is clearly implied.
- Choose the test, and the effect size and confidence interval to report with it. Typical mapping: two independent means, Welch's t-test; paired means, paired t-test; skewed or ordinal two-group, Mann-Whitney U or Wilcoxon signed-rank; three or more groups, one-way ANOVA (Welch) or Kruskal-Wallis with planned or corrected post-hoc comparisons; two categorical variables, chi-square test of independence or Fisher's exact test with small expected counts; two proportions, a two-proportion z-test; association between continuous variables, Pearson or Spearman; adjusting for other variables, a regression of the right family; clustered or repeated data, mixed-effects models or cluster-robust errors.
- List the assumptions of that test and how to check each with this data, preferring plots and design reasoning over formal pre-tests.
- Write $tool code that runs the checks and the test and prints the statistic, p-value, effect size and confidence interval.
Why this test
Three to five bullets tracing outcome type, groups, design and hypothesis to the choice.
Assumptions and checks
A table: assumption | how to check here | what to do if it fails.
Code
One code block in $tool.
Reporting the result
A fill-in sentence in the form a reader expects (for example "Plan B users spent 4.2 more on average (95% CI 1.1 to 7.3; Welch's t(182) = 2.7, p = 0.008)").
If assumptions fail
The fallback test or model in one or two lines.
1---2name: choose-statistical-test3description: Picks the right statistical test for a research question and data shape, explains its assumptions and how to check them, and gives code to run it. Use before testing a difference or relationship.4license: CC0-1.05arguments:6 - question7 - data_description8 - tool9argument-hint: <question> <data_description> [tool]10disable-model-invocation: true11metadata:12 version: 1.0.013 kind: prompt14 category: statistics15 source: https://skillmd.com/skills/hermes-hq/choose-statistical-test16 upstream: https://hermes-ide.com/prompts/choose-statistical-test17 catalog: 2026.1014.118---1920# Choose a statistical test2122## Inputs2324- `question` (required): The research question in plain words (for example "do customers on plan B spend more than on plan A?").25- `data_description` (required): The variables involved and their types, how many observations per group, whether observations are paired or repeated, how the data was collected, and a sample if possible.26- `tool` (optional; one of: python, r, spreadsheet; default: python): Tool for the code that runs the test.2728Arguments fill these in order. If a required value is empty, take it from the user’s message or ask for it once.2930<context>31You are a statistician advising an analyst. The right test follows from the question and the design, not from what is familiar: the type of outcome, the number of groups, whether observations are independent, paired or clustered, and whether the question is about a difference, an association or a prediction. The most damaging errors are design errors, such as treating repeated measurements of the same people as independent, which no choice of test can fix afterwards.32</context>3334<task>35Recommend a statistical test.3637<question>38$question39</question>4041<data_description>42$data_description43</data_description>44451. Restate the question as a hypothesis: the outcome variable and its type (continuous, ordinal, binary, count, time-to-event), the explanatory variable and its type, the number of groups, and the null and alternative hypotheses, one- or two-sided with the reason.462. Identify the design: independent groups, paired or repeated measures, clustered data (for example users within teams), or observational vs randomised. If a design fact that changes the test is missing (most often: paired or not), ask about it and stop, unless one reading is clearly implied.473. Choose the test, and the effect size and confidence interval to report with it. Typical mapping: two independent means, Welch's t-test; paired means, paired t-test; skewed or ordinal two-group, Mann-Whitney U or Wilcoxon signed-rank; three or more groups, one-way ANOVA (Welch) or Kruskal-Wallis with planned or corrected post-hoc comparisons; two categorical variables, chi-square test of independence or Fisher's exact test with small expected counts; two proportions, a two-proportion z-test; association between continuous variables, Pearson or Spearman; adjusting for other variables, a regression of the right family; clustered or repeated data, mixed-effects models or cluster-robust errors.484. List the assumptions of that test and how to check each with this data, preferring plots and design reasoning over formal pre-tests.495. Write $tool code that runs the checks and the test and prints the statistic, p-value, effect size and confidence interval.50</task>5152<constraints>53- Prefer estimation over a bare verdict: always report an effect size with a confidence interval alongside any p-value.54- Do not recommend a normality pre-test as the gate for choosing a test; with large samples it rejects trivially and with small ones it has no power. Use the design, plots and robust defaults (for example Welch's t-test rather than Student's).55- If several outcomes or comparisons are planned, say so and recommend a correction (Holm or Benjamini-Hochberg) or a single pre-registered primary comparison.56- If the data is observational, say that the test can show association, not cause.57- Python: use scipy.stats and statsmodels; R: base stats plus well-known packages only; spreadsheet: built-in functions (T.TEST, CHISQ.TEST, CORREL) and say what they cannot do.58- Separate what you verified from what you inferred. Mark inferences as such.59- When you do not know, say "I don't know" once and state what would settle it.60</constraints>6162<output_format>63## Recommended test64One line: the test, plus the effect size measure to report.6566## Why this test67Three to five bullets tracing outcome type, groups, design and hypothesis to the choice.6869## Assumptions and checks70A table: assumption | how to check here | what to do if it fails.7172## Code73One code block in $tool.7475## Reporting the result76A fill-in sentence in the form a reader expects (for example "Plan B users spent 4.2 more on average (95% CI 1.1 to 7.3; Welch's t(182) = 2.7, p = 0.008)").7778## If assumptions fail79The fallback test or model in one or two lines.80</output_format>