关于 stat-hypothesis-testing
面向分析人员和研究者的统计假设检验指南,涵盖检验选择与结果报告,并强调效应量、前提条件和先于数据分析设定假设。
主要功能
- 01定义零假设与备择假设
- 02按数据和组别选择检验
- 03设定显著性水平并解读 p 值
- 04报告效应量和置信区间
- 05处理检验效能与多重比较
适用场景
- 01在分析研究数据前规划检验
- 02为配对或独立组选择检验
- 03解读结果,避免将显著性等同于重要性
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ asgard-ai-platform/ skills --skill stat-hypothesis-testing安装后在 Claude Code 中输入/stat-hypothesis-testing确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
examples/sample_scenario.mdreferences/nonparametric-tests.mdsample-size.md详细介绍
假设检验
框架
IRON LAW: Statistical Significance ≠ Practical Significance
A p-value < 0.05 means the result is unlikely under the null hypothesis.
It does NOT mean the result is important, large, or practically meaningful.
With a large enough sample, a 0.1% conversion rate difference becomes
"statistically significant" but is practically worthless.
ALWAYS report effect size alongside p-value.
IRON LAW: State Hypotheses BEFORE Looking at Data
H₀ (null) and H₁ (alternative) must be defined before data analysis.
Choosing hypotheses after seeing the data = p-hacking = scientific fraud.
"We found an interesting pattern, let's test it on the same data" is invalid.
核心概念
| 概念 | 定义 |
|---|---|
| H₀(零假设) | 默认假设:没有效应、没有差异 |
| H₁(备择假设) | 你想要证明的内容:确实存在效应/差异 |
| p-value | 在 H₀ 为真的前提下,观察到该结果(或更极端结果)的概率 |
| α(显著性水平) | 拒绝 H₀ 的阈值(通常为 0.05) |
| I 类错误(α) | H₀ 实际为真时却拒绝 H₀(假阳性) |
| II 类错误(β) | H₁ 为真时未能拒绝 H₀(假阴性) |
| 检验效能(1-β) | 检测到真实效应的概率(目标:≥ 0.8) |
| 效应量 | 差异的大小(Cohen's d、优势比、R²) |
检验选择指南
| 数据类型 | 组数 | 检验 |
|---|---|---|
| 连续型、正态、2 组 | 独立 | 独立样本 t 检验 |
| 连续型、正态、2 组 | 配对/前后测 | 配对 t 检验 |
| 连续型、正态、3 组以上 | 独立 | 单因素 ANOVA |
| 连续型、非正态 | 2 组 | Mann-Whitney U 检验 |
| 分类数据 | 2 组以上 | 卡方检验 |
| 连续型、关系 | 2 个变量 | Pearson 相关(正态)/Spearman 相关(非正态) |
| 二元结果 | 预测变量 | 逻辑回归 |
检验流程
- 陈述假设:给出包含具体参数的 H₀ 和 H₁
- 选择检验:依据数据类型、分布和组数(使用上方指南)
- 设定 α:通常为 0.05(若采用其他值,请说明理由)
- 计算:运行检验,得到检验统计量和 p-value
- 作出判断:p < α → 拒绝 H₀;p ≥ α → 未能拒绝 H₀
- 报告:效应量 + 置信区间 + p-value(不只报告“显著”)
输出格式
# Hypothesis Test: {Research Question}
## Hypotheses
- H₀: {null — no effect/difference}
- H₁: {alternative — there IS an effect/difference}
- α = {0.05 or other}
## Test Selection
- Test: {name}
- Rationale: {why this test fits the data}
- Assumptions checked: {normality, independence, equal variance}
## Results
- Test statistic: {value}
- p-value: {value}
- Effect size: {value and interpretation}
- 95% CI: [{lower}, {upper}]
## Decision
{Reject / Fail to reject H₀}
## Interpretation
{What this means in practical terms, with effect size context}
注意事项
- “未能拒绝 H₀” ≠ “H₀ 为真”:没有证据不代表证据表明不存在。你可能缺乏检测真实效应所需的检验效能。
- 多重比较会增加 I 类错误:在 α=0.05 下检验 20 个假设,预计会偶然出现 1 个假阳性。应用 Bonferroni 或 FDR 校正。
- 检验前检查假设条件:t 检验假设数据服从正态分布且方差相等。违反假设条件会导致结果无效。假设条件不满足时,使用非参数替代方法。
- 样本量决定检验效能:小样本可能漏掉真实效应(II 类错误)。收集数据前计算所需样本量。
- p-value 不是 H₀ 为真的概率:它是在 H₀ 成立的前提下观察到这些数据的概率。这两者本质上不同(基准率谬误)。
参考资料
- 样本量计算参见
references/sample-size.md - 非参数检验的替代方法参见
references/nonparametric-tests.md
评论
支持 Markdown