Statistical Analysis (Workflow & Test Selection)
Path: /skills/databrain-analysis/statistical/SKILL.md
对齐 host statistical-analysis。在 sandbox 内用 execute_sandbox_code 实现;用 read_file 加载 references。
Workflow
- 已读
../SKILL.md 与本文件
- Data cleaning:
read_file → references/data_cleaning.md;清洗后再检验
- 选型 — 下表选定 reference 文件名
- Load reference:
read_file → statistical/references/<name>.md(如 stat-t-test.md)
- 实验设计:
read_file → references/experimental_design.md;先 print 研究问题、DV/IV、H0/H1、设计类型、选型依据、假设、α、样本量
- Implement in
execute_sandbox_code(遵循 reference 代码模式)
- Report in stdout: 检验统计量、精确 p、效应量、CI(格式见
../../databrain-summarize/report.md BI Quick Report)
选型 (Test Selection)
By question / data type
| Question |
Data |
Reference file |
| Compare 2 groups (continuous) |
2 groups, normal or n>30 |
stat-t-test.md |
| Compare 2 groups (continuous) |
skewed / small n |
stat-nonparametric.md |
| Compare 3+ groups |
3+ groups, continuous |
stat-anova.md or stat-nonparametric.md |
| Categorical × categorical |
2 categorical |
stat-chi-square.md |
| Y continuous, X predictors |
Continuous outcome |
stat-regression.md |
| Y binary |
Binary outcome |
stat-logistic.md |
| Y count |
Count outcome |
stat-glm.md |
| Time series / forecast |
Time-ordered |
stat-time-series.md |
| Regression diagnostics |
Residuals / VIF |
stat-diagnostics.md |
Quick decision tree
- 2 groups, continuous →
stat-t-test.md (or stat-nonparametric.md if skewed)
- 3+ groups, continuous →
stat-anova.md or stat-nonparametric.md
- Categorical × categorical →
stat-chi-square.md
- Y continuous, X →
stat-regression.md
- Y binary →
stat-logistic.md
- Y count →
stat-glm.md
- Time series →
stat-time-series.md
Available references
| File |
Content |
data_cleaning.md |
Missing, duplicates, invalid values |
stat-t-test.md |
Independent/paired t-test, Welch |
stat-anova.md |
One-way ANOVA, Welch, Tukey |
stat-chi-square.md |
Chi-square, Fisher |
stat-nonparametric.md |
Mann-Whitney, Wilcoxon, Kruskal-Wallis |
stat-regression.md |
OLS, VIF (statsmodels) |
stat-logistic.md |
Logit, Probit |
stat-glm.md |
Poisson, NB |
stat-time-series.md |
ARIMA, stationarity |
stat-diagnostics.md |
Breusch-Pagan, DW, VIF |
assumptions_and_diagnostics.md |
Normality, homogeneity |
effect_sizes_and_power.md |
Effect sizes, power |
experimental_design.md |
实验设计输出模板 |
reporting_standards.md |
完整报告规范(终稿优先用 summarize report.md) |
bayesian_statistics.md |
Bayesian (optional) |
code_examples.md |
示例 |
Assumption checking
BI 指标常右偏。可参考 scripts/assumption_checks.py 逻辑在 sandbox 中实现,或各 stat-* reference 内检查。
Effect sizes
须报告:Cohen's d (t-test)、η² (ANOVA)、Cramér's V (chi-square)、R² (regression)。见 effect_sizes_and_power.md。
Best practices
- 先 实验设计 再 跑检验
- 先 清洗 再 选型
- 区分统计显著 vs 业务意义;偏态优先 Welch / 非参
- 与 drilldown 配合:下钻定位切片后,再对子集做 formal test
1---2name: statistical3description: Statistical Analysis (Workflow & Test Selection)4---5# Statistical Analysis (Workflow & Test Selection)67**Path:** `/skills/databrain-analysis/statistical/SKILL.md`89对齐 host `statistical-analysis`。在 sandbox 内用 `execute_sandbox_code` 实现;用 `read_file` 加载 references。1011## Workflow12131. **已读** [`../SKILL.md`](../SKILL.md) 与本文件142. **Data cleaning**: `read_file` → [`references/data_cleaning.md`](references/data_cleaning.md);清洗后再检验153. **选型** — 下表选定 reference 文件名164. **Load reference**: `read_file` → `statistical/references/<name>.md`(如 `stat-t-test.md`)175. **实验设计**: `read_file` → [`references/experimental_design.md`](references/experimental_design.md);**先** `print` 研究问题、DV/IV、H0/H1、设计类型、选型依据、假设、α、样本量186. **Implement** in `execute_sandbox_code`(遵循 reference 代码模式)197. **Report in stdout**: 检验统计量、精确 p、效应量、CI(格式见 [`../../databrain-summarize/report.md`](../../databrain-summarize/report.md) BI Quick Report)2021## 选型 (Test Selection)2223### By question / data type2425| Question | Data | Reference file |26|----------|------|----------------|27| Compare 2 groups (continuous) | 2 groups, normal or n>30 | `stat-t-test.md` |28| Compare 2 groups (continuous) | skewed / small n | `stat-nonparametric.md` |29| Compare 3+ groups | 3+ groups, continuous | `stat-anova.md` or `stat-nonparametric.md` |30| Categorical × categorical | 2 categorical | `stat-chi-square.md` |31| Y continuous, X predictors | Continuous outcome | `stat-regression.md` |32| Y binary | Binary outcome | `stat-logistic.md` |33| Y count | Count outcome | `stat-glm.md` |34| Time series / forecast | Time-ordered | `stat-time-series.md` |35| Regression diagnostics | Residuals / VIF | `stat-diagnostics.md` |3637### Quick decision tree3839- **2 groups, continuous** → `stat-t-test.md` (or `stat-nonparametric.md` if skewed)40- **3+ groups, continuous** → `stat-anova.md` or `stat-nonparametric.md`41- **Categorical × categorical** → `stat-chi-square.md`42- **Y continuous, X** → `stat-regression.md`43- **Y binary** → `stat-logistic.md`44- **Y count** → `stat-glm.md`45- **Time series** → `stat-time-series.md`4647## Available references4849| File | Content |50|------|---------|51| `data_cleaning.md` | Missing, duplicates, invalid values |52| `stat-t-test.md` | Independent/paired t-test, Welch |53| `stat-anova.md` | One-way ANOVA, Welch, Tukey |54| `stat-chi-square.md` | Chi-square, Fisher |55| `stat-nonparametric.md` | Mann-Whitney, Wilcoxon, Kruskal-Wallis |56| `stat-regression.md` | OLS, VIF (statsmodels) |57| `stat-logistic.md` | Logit, Probit |58| `stat-glm.md` | Poisson, NB |59| `stat-time-series.md` | ARIMA, stationarity |60| `stat-diagnostics.md` | Breusch-Pagan, DW, VIF |61| `assumptions_and_diagnostics.md` | Normality, homogeneity |62| `effect_sizes_and_power.md` | Effect sizes, power |63| `experimental_design.md` | 实验设计输出模板 |64| `reporting_standards.md` | 完整报告规范(终稿优先用 summarize `report.md`) |65| `bayesian_statistics.md` | Bayesian (optional) |66| `code_examples.md` | 示例 |6768## Assumption checking6970BI 指标常右偏。可参考 `scripts/assumption_checks.py` 逻辑在 sandbox 中实现,或各 `stat-*` reference 内检查。7172## Effect sizes7374须报告:Cohen's d (t-test)、η² (ANOVA)、Cramér's V (chi-square)、R² (regression)。见 `effect_sizes_and_power.md`。7576## Best practices7778- **先** 实验设计 **再** 跑检验79- **先** 清洗 **再** 选型80- 区分统计显著 vs 业务意义;偏态优先 Welch / 非参81- 与 **drilldown** 配合:下钻定位切片后,再对子集做 formal test