domains / research / statistical-analysis / statistical-analysis
The K-Dense-AI copy is the most complete and current procedure, but it contains specific, version-dependent constraints (e.g., Pingouin 0.7.0 API changes, PyMC 6.3.2 xarray output, and a specific `uv` installation workflow) that the other copies lack. The other copies (zLanqing, foryourhealth111, aipoch) provide a more generic, version-agnostic workflow and include a full end-to-end Python example (aipoch) that the K-Dense copy omits. Crowning the K-Dense copy would hide the generic alternative and the runnable example, while crowning the others would hide the critical version-specific warnings.
| Repository | Path |
|---|---|
| zLanqing/codex-claude-academic-skills | scientific-toolkit-skill/references/scientific-skills/statistical-analysis/SKILL.md |
| K-Dense-AI/scientific-agent-skills | skills/statistical-analysis/SKILL.md |
| foryourhealth111-pixel/Vibe-Skills | bundled/skills/statistical-analysis/SKILL.md |
| aipoch/medical-research-skills | scientific-skills/Data Analysis/statistical-analysis/SKILL.md |
| Role | Repository | Path |
|---|---|---|
| peer | zLanqing/codex-claude-academic-skills | scientific-toolkit-skill/references/scientific-skills/statistical-analysis/SKILL.md |
| peer | K-Dense-AI/scientific-agent-skills | skills/statistical-analysis/SKILL.md |
| peer | foryourhealth111-pixel/Vibe-Skills | bundled/skills/statistical-analysis/SKILL.md |
| peer | aipoch/medical-research-skills | scientific-skills/Data Analysis/statistical-analysis/SKILL.md |
| inferior | FreedomIntelligence/OpenClaw-Medical-Skills | skills/statistical-analysis/SKILL.md |
| inferior | GPTomics/bioSkills | metabolomics/statistical-analysis/SKILL.md |
# Statistical Analysis
## Overview
Conduct hypothesis tests, regression, correlation, and Bayesian analyses with systematic assumption checking, effect sizes, and APA-style reporting. Define the estimand and sampling units, diagnose model limitations, and report effect estimates with uncertainty.
## When to Use
- Conducting statistical hypothesis tests (t-tests, ANOVA, chi-square, non-parametric)
- Performing regression or correlation analyses
- Running Bayesian statistical analyses
- Checking statistical assumptions and diagnostics
- Calculating effect sizes and conducting power analyses
- Reporting statistical results in APA format
## Installation
Create a separate environment to avoid conflicts. Recommended versions (as of 2026):
- Python 3.12+
- `pingouin==0.7.0` (fixes mixed/repeated-measures corrections)
- `scipy==1.18.1`
- `statsmodels==0.15.0`
- `pymc==6.3.2` (optional, for Bayesian)
- `arviz==1.3.0` (optional, for Bayesian)
**Version Notes:**
- Pingouin 0.6+ uses `p_val`, `cohen_d`, `CI95`. `ttest` reports **absolute** Cohen's d; calculate signed estimates explicitly.
- `correction='auto'` in Pingouin chooses Welch based on sample size, not variance. Use `correction=True` for prespecified Welch inference.
- PyMC 6 returns an xarray `DataTree`. ArviZ 1 uses `ci_prob` in `summary`.
## Analysis Workflow
1. **Frame the question:** State hypothesis, outcome, predictors, and design (independent vs. paired). Specify target effect and multiplicity family.
2. **Inspect data:** Check n, mean, SD, missing values, and plot raw data (histograms/box plots) per group.
3. **Select the test:**
- **Independent continuous means:** Prespecified Welch's t-test or Welch's ANOVA. Use Student's t-test/ANOVA only if equal variance is justified.
- **Paired means:** Paired t-test on within-person differences.
- **Non-normal/Rank:** Mann-Whitney U or Kruskal-Wallis (note: these test distribution/rank contrasts, not just medians).
- **Binary:** Chi-square or Fisher's exact test.
- **Regression:** Linear (continuous outcome) or Logistic (binary outcome).
4. **Check assumptions:** Use `scripts/assumption_checks.py` for normality, homogeneity of variance, and outliers. Interpret plots alongside the design; do not switch tests automatically at a p-value threshold.
5. **Run the test:** Always compute the effect size (e.g., Cohen's d, r) and confidence interval alongside the p-value.
6. **Report:** Use APA format including descriptives, exact statistics, effect sizes with CIs, and assumption checks.
## Example Usage
```python
import numpy as np
import pandas as pd
import pingouin as pg
from statsmodels.stats.power import tt_ind_solve_power
# 1) Create example dataset
rng = np.random.default_rng(7)
n_a, n_b = 50, 52
group_a = rng.normal(loc=75, scale=9, size=n_a)
group_b = rng.normal(loc=69, scale=9, size=n_b)
df = pd.DataFrame({"score": np.r_[group_a, group_b], "group": ["A"] * n_a + ["B"] * n_b})
# 2) Assumption checks (if scripts/assumption_checks.py is available)
# from scripts.assumption_checks import comprehensive_assumption_check
# assump = comprehensive_assumption_check(data=df, value_col="score", group_col="group", alpha=0.05)
# 3) Run test + effect size (Welch's t-test)
res = pg.ttest(group_a, group_b, correction=True)
t_stat = float(res["T"].iloc[0])
dfree = float(res["dof"].iloc[0])
pval = float(res["p_val"].iloc[0])
d = float(res["cohen_d"].iloc[0])
ci_low, ci_high = res["CI95"].iloc[0]
# 4) Power analysis
n_required = tt_ind_solve_power(effect_size=0.5, alpha=0.05, power=0.80, ratio=1.0, alternative="two-sided")
# 5) APA-style reporting
m_a, sd_a = group_a.mean(), group_a.std(ddof=1)
m_b, sd_b = group_b.mean(), group_b.std(ddof=1)
apa = (f"Group A (n = {n_a}, M = {m_a:.2f}, SD = {sd_a:.2f}) and "
f"Group B (n = {n_b}, M = {m_b:.2f}, SD = {sd_b:.2f}) differed, "
f"t({dfree:.0f}) = {t_stat:.2f}, p = {pval:.3f}, d = {d:.2f}, "
f"95% CI [{ci_low:.2f}, {ci_high:.2f}].")
print(apa)
```
## Conflicts
- **K-Dense-AI/scientific-agent-skills** specifies strict version pins and API changes (e.g., `p_val` vs `p-val`) that other copies do not mention. If using older versions, API calls may differ.
- **K-Dense-AI/scientific-agent-skills** recommends prespecified Welch's t-test as the default for independent means, whereas other copies present a simpler normality-based decision tree (Normal -> Student's t-test).