# statistical-analysis

> Guided statistical analysis with test selection and reporting — use when you need help choosing appropriate tests for your data, assumption checking, power analysis, and APA-formatted results for academic research reporting.

**Use case**: Choose the right statistical test and report results in APA

**Canonical URL**: https://agentcookbooks.com/skills/statistical-analysis/

**Topics**: claude-code, skills, science, data-science

**Trigger phrases**: "what statistical test should I use", "analyze this data statistically", "check statistical assumptions", "power analysis", "report results in APA format"

**Source**: [K-Dense AI](https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/scientific-skills/statistical-analysis)

**License**: MIT

---

## What it does

`statistical-analysis` is a Claude Code skill from K-Dense AI's [scientific-agent-skills repo](https://github.com/K-Dense-AI/scientific-agent-skills). It turns Claude into a statistical consultant that guides test selection based on your data structure and research question, checks statistical assumptions, performs power analysis, runs the appropriate tests via Python (scipy, pingouin, statsmodels), and formats results in APA style.

A session produces a complete statistical reporting block: the selected test with justification, assumption check results, the test statistic and p-value, effect size, power, and an APA-formatted results sentence ready to paste into your manuscript.

## When to use it

Reach for it when:

- You know what comparison you want to make but aren't sure which test is appropriate for your data type and design
- You need assumption checks (normality, homogeneity of variance, sphericity) reported formally, not just eyeballed
- You want APA-formatted statistical reporting (e.g., "F(2, 87) = 4.32, p = .016, η² = .09") for a manuscript

When *not* to reach for it:

- You know exactly which model to fit and need the implementation — use `statsmodels`
- Bayesian inference — use `pymc`

## Install

Copy the `SKILL.md` from K-Dense AI's [statistical-analysis folder](https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/scientific-skills/statistical-analysis) into `.claude/skills/statistical-analysis/` in your project.

Trigger phrases: "what statistical test should I use", "analyze this data statistically", "report results in APA format", "power analysis".

## What a session looks like

A typical session has three phases:

1. **Research question and data structure.** Describe your outcome variable (continuous/categorical/count), predictor variables, number of groups, and study design (between-subjects, within-subjects, longitudinal). Claude selects the appropriate test from a decision tree.
2. **Assumption checking.** Claude runs the relevant assumption tests — Shapiro-Wilk for normality, Levene for homogeneity, Mauchly for sphericity — and recommends corrections (Greenhouse-Geisser, Welch's t-test) where assumptions are violated.
3. **Results and reporting.** The main test runs, effect size is computed (Cohen's d, η², r), power is estimated, and the full APA-formatted results sentence is generated alongside a plain-language interpretation.

## Receipts

**Where it works well:**
- Common between-group comparisons (t-tests, ANOVA, Mann-Whitney) where the decision tree is unambiguous — the APA output is reliable and saves significant time during manuscript preparation
- Power analysis for study planning — sample size recommendations with effect size assumptions are produced quickly

**Where it backfires:**
- Complex mixed designs with multiple levels of nesting require statsmodels or R for full model specification beyond what this skill handles
- The test selection decision tree is heuristic; edge cases (e.g., small samples with count data) may need expert judgment beyond what the skill provides

**Pattern that works:** run assumption checks before deciding on the test, not after — the skill's decision tree branches on assumption check results, and switching tests after seeing the p-value is p-hacking.

## Source and attribution

Originally authored by [K-Dense Inc.](https://github.com/K-Dense-AI). The canonical SKILL.md lives in the [`statistical-analysis` folder](https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/scientific-skills/statistical-analysis) of their public scientific-agent-skills repository.

License: MIT. Install, adapt, and redistribute with attribution preserved.

This page documents the skill from a practitioner's perspective. For the formal spec and any updates, defer to the source repo.