# 随机化推断

随机化推断是一种统计方法，用于检验实验中的处理效应，其做法是在所有可能的随机分配上计算检验统计量的分布，而非依赖对数据的参数假设。当处理是随机分配时，该方法也称为置换推断，此时“没有任何单元受到影响”这一假设可以被精确检验，无需任何进一步假设，只需将观测到的统计量与其在替代分配下的分布进行比较。<sup>[1](https://export.arxiv.org/pdf/2101.09195v2.pdf)</sup> 这种检验不依赖于对样本量、数据生成过程模型的准确性或模型噪声项分布的假设；受试者被视为固定的，只有处理分配是随机的。<sup>[2](https://hesss.org/ritest.pdf)</sup> 随机化检验在有限样本中精确控制名义第一类错误率，且不依赖任何分布假设。<sup>[3](https://www.tandfonline.com/doi/pdf/10.1080/01621459.2023.2199814)</sup>

| 关键事实 | 内容 |
|---|---|
| 通常检验的零假设 | 每个单元效应为零的尖锐零假设，即对所有 \( i \) 有 \( y_{i}(D=1) = y_{i}(D=0) \)，这不同于渐近分析中使用的平均效应为零的零假设<sup>[2](https://hesss.org/ritest.pdf)</sup> |
| 错误控制 | 在随机化假设下精确的有限样本第一类错误控制，无需分布假设<sup>[3](https://www.tandfonline.com/doi/pdf/10.1080/01621459.2023.2199814)</sup> |
| 最小可达 p 值 | \( 1/N_{\mathrm{randomizations}} \)<sup>[4](https://pmc.ncbi.nlm.nih.gov/articles/PMC7431075/)</sup> |
| 分配空间的大小 | 平衡完全随机设计中，10 个单元时有 252 种排列，100 个单元时有 \( 10^{29} \) 种<sup>[5](https://academic.oup.com/jrsssb/article/83/4/777/7056013)</sup> |
| 蒙特卡洛实践 | 1000 或 5000 次置换较为常见<sup>[5](https://academic.oup.com/jrsssb/article/83/4/777/7056013)</sup>；也有建议使用数千到数万次模拟分配<sup>[6](https://methods.egap.org/guides/analysis-procedures/randomization-inference_en.html)</sup> |
| 蒙特卡洛 p 值 | \( \hat{p} = \left(1 + \sum_{r=1}^{R} \mathbf{1}\{T_{r} \geq T_{\mathrm{obs}}\}\right)/(R+1) \)，其中 +1 避免出现零 p 值<sup>[7](https://tabarecapitan.com/projects/ritest/technical-notes/ri.html)</sup> |
| 软件 | Stata 的 ritest<sup>[2](https://hesss.org/ritest.pdf)</sup>；R 包 ri2<sup>[8](https://cran.r-project.org/web/packages/ri2/refman/ri2.html)</sup> 和 randomizationInference<sup>[9](https://cran.r-universe.dev/randomizationInference)</sup> |

## 工作原理

该方法建立在费雪（Fisher）的尖锐零假设之上，即接受处理与接受对照对结果的影响完全没有差异。在该零假设下，处理对任何单元都毫无影响，因此每个单元在每种分配下的结果就是观测到的结果，任何检验统计量的分布在所有随机化上都是已知的。<sup>[10](https://ar5iv.labs.arxiv.org/html/1809.07419)</sup> 分析者对观测结果的所有可能随机分配重新计算统计量，得到费雪精确零随机化分布；费雪精确 p 值就是与观测值同样极端或更极端的取值所占的比例，最小可达 p 值为 \( 1/N_{\mathrm{randomizations}} \)。<sup>[4](https://pmc.ncbi.nlm.nih.gov/articles/PMC7431075/)</sup>

精确性由构造保证，而非近似。更一般地说，只要在零假设下存在保持数据分布的变换，从而可以构造零分布，就可以进行随机化检验；这一条件称为随机化假设。<sup>[11](https://arxiv.org/abs/2406.09521)</sup>

## 操作方式

一般程序包括三步：提出无处理效应的尖锐零假设，选择检验统计量 \( S = f(\{Y_i, T_i, \tau_{0i}\}_{i=1}^{n}) \)，并据此计算参照分布和 p 值，在枚举不可行时使用蒙特卡洛近似。<sup>[12](https://imai.fas.harvard.edu/teaching/files/permutation_test.pdf)</sup> 任何检验统计量都可以使用，但选择很重要：简单的均值差通常表现良好，不过也有人主张使用稳健的 t 比率。<sup>[6](https://methods.egap.org/guides/analysis-procedures/randomization-inference_en.html)</sup>

枚举往往不可行。在平衡完全随机设计中，随着单元数从 10 增至 100，可能的排列数从 252 增加到 \( 10^{29} \)。<sup>[5](https://academic.oup.com/jrsssb/article/83/4/777/7056013)</sup> 当参照分布是分配的全量普查时，p 值是精确的；否则通过抽样近似，建议使用数千到数万次模拟随机分配。<sup>[6](https://methods.egap.org/guides/analysis-procedures/randomization-inference_en.html)</sup> 在 \( R \) 次抽取下，p 值估计为 \( \hat{p} = \left(1 + \sum_{r=1}^{R} \mathbf{1}\{T_{r} \geq T_{\mathrm{obs}}\}\right)/(R+1) \)，其中 +1 修正在有限 \( R \) 下避免返回 0。<sup>[7](https://tabarecapitan.com/projects/ritest/technical-notes/ri.html)</sup> 当完全枚举不可行时，用随机选取的分配来近似随机化零分布被认为优于渐近近似。<sup>[4](https://pmc.ncbi.nlm.nih.gov/articles/PMC7431075/)</sup>

## 起源

随机化检验在正态性不成立时替代学生 t 检验，并恢复随机化作为“统计检验有效性的物理基础”的地位；这一思想随即被皮特曼（Pitman，1937）、韦尔奇（Welch，1937）、威尔科克森（Wilcoxon，1945）和肯普索恩（Kempthorne，1952）推广。<sup>[3](https://www.tandfonline.com/doi/pdf/10.1080/01621459.2023.2199814)</sup> 在品茶女士实验中，将八杯茶分成两组各四杯有 70 种分法，因此在“判断完全不受配料添加顺序影响”的零假设下，完美区分的概率为 1/70。<sup>[13](https://www.jhanley.biostat.mcgill.ca/c607/ch06/lady_tasting_tea.pdf)</sup>

潜在结果框架用于因果推断和检验平均因果效应为零的零假设，而费雪（1935）提出用费雪随机化检验（FRT）来检验个体效应为零的尖锐零假设。<sup>[14](https://ar5iv.labs.arxiv.org/html/1402.0142)</sup> 由此产生的争议是一个真实的逻辑缺口：费雪的零假设蕴含奈曼（Neyman）的零假设，但在完全随机实验中，拒绝奈曼的零假设在许多现实情形下（包括常数因果效应）并不蕴含拒绝费雪的零假设，而且在非零常数效应下奈曼的方法总是更具功效。<sup>[14](https://ar5iv.labs.arxiv.org/html/1402.0142)</sup> 基于设计的视角区分了奈曼式的基于随机化的推断——通过方差公式和大样本近似来针对平均效应——与费雪对尖锐零假设和有限样本精确 p 值的关注。<sup>[15](https://www.degruyterbrill.com/document/doi/10.1515/jci-2023-0067/html)</sup>

## 变体

随机化检验与置换检验密切相关但并不相同。随机化检验建立在实验随机化（随机化模型）之上，而置换检验建立在随机抽样（总体模型）之上；随机化检验的有效性不基于可交换性假设。<sup>[3](https://www.tandfonline.com/doi/pdf/10.1080/01621459.2023.2199814)</sup> 在尖锐零假设下，FRT 退化为经典置换检验，两者在数值上相同，但一般而言 FRT 容许更广泛的零假设类和实验设计。<sup>[10](https://ar5iv.labs.arxiv.org/html/1809.07419)</sup> 与自助法的对比更为鲜明：随机化推断对处理分配向量进行重抽样并保持结果固定，检验尖锐零假设；而自助法对观测数据进行重抽样，检验平均效应为零的弱零假设，并依赖渐近理论。<sup>[16](https://methodatlas.vercel.app/practices/randomization-inference)</sup> 自助法本身由埃夫隆（Efron）在《自助法：刀切法的另一种视角》（《统计年鉴》，1979）中提出。<sup>[17](https://doi.org/10.1214/aos/1176344552)</sup> 相对于自助法，FRT 的额外优势是在尖锐零假设下具有有限样本精确性。<sup>[10](https://ar5iv.labs.arxiv.org/html/1809.07419)</sup>

对于弱零假设，即处理平均而言不影响单元，一种方法是在相容的尖锐零假设下插补缺失的潜在结果，并使用学生化检验统计量，从而保守地控制大样本第一类错误；若不进行学生化，FRT 即使在渐近意义下也可能无法控制第一类错误。<sup>[10](https://ar5iv.labs.arxiv.org/html/1809.07419)</sup> 在存在干扰的情况下，FRT 在无干扰假设下于有限样本中完全有效，但当潜在结果无法完全插补时变得不可行；条件随机化检验因过度条件化而遭受严重的功效损失，部分零假设随机化检验则通过成对比较提高功效。<sup>[18](https://arxiv.org/html/2411.08352)</sup>

## 应用

在整群随机设计中，当群数少于十二个时，随机化推断通过在可能整群分配的集合上计算参照分布，避开了向下偏倚的稳健整群标准误。<sup>[6](https://methods.egap.org/guides/analysis-procedures/randomization-inference_en.html)</sup> 也有研究提出了基于随机化的框架，用于阶梯楔形整群随机试验中边际处理效应的 p 值和置信区间。<sup>[19](https://pmc.ncbi.nlm.nih.gov/articles/PMC9014477/)</sup>

Stata 命令 ritest 实现了随机化推断。<sup>[2](https://hesss.org/ritest.pdf)</sup> 在 R 中，ri2 使用均值差或协变量调整的平均处理效应估计、方差分析式 F 统计量检验以及任意标量检验统计量进行尖锐零假设检验，并提供整群、置换矩阵、IPW 和学生化等选项。<sup>[8](https://cran.r-project.org/web/packages/ri2/refman/ri2.html)</sup> randomizationInference 包支持自定义随机化方案，并输出基于随机化的 p 值和任意待估参数的零区间。<sup>[9](https://cran.r-universe.dev/randomizationInference)</sup>

## 局限与替代方案

主要的解释局限在于零假设本身。尖锐零假设不容忍对处理的异质性反应，因而具有很强的限制性。<sup>[1](https://export.arxiv.org/pdf/2101.09195v2.pdf)</sup> 推导可解释的置信区间通常需要假设单元间效应恒定或效应按已知模型变化，不过对一系列假设进行检验可以产生精确的非参数置信区间。<sup>[1](https://export.arxiv.org/pdf/2101.09195v2.pdf)</sup> 区间估计会使计算成本成倍增加，因为必须在多个处理效应取值上计算 p 值。<sup>[5](https://academic.oup.com/jrsssb/article/83/4/777/7056013)</sup>

精确的第一类错误控制仅在随机化假设下才能获得；在该假设不成立时使用随机化检验可能导致第一类错误失控，即使在大样本中也是如此。<sup>[11](https://arxiv.org/abs/2406.09521)</sup> 相对于参数替代方法，费雪精确 p 值与渐近 p 值在小样本中可能差异巨大，此时精确零随机化分布可能与近似的学生 t 分布有实质性差异；对某些结果，基于 t 的渐近 p 值比最小可达的费雪精确 p 值还小。<sup>[4](https://pmc.ncbi.nlm.nih.gov/articles/PMC7431075/)</sup>

## References

1. [Randomization inference paper (arXiv 2101.09195)](https://export.arxiv.org/pdf/2101.09195v2.pdf)
2. [Randomization Inference with Stata: A Guide and Software (Hess, Stata Journal)](https://hesss.org/ritest.pdf)
3. [What is a Randomization Test? (Journal of the American Statistical Association, 2023)](https://www.tandfonline.com/doi/pdf/10.1080/01621459.2023.2199814)
4. [When possible, report a Fisher-exact P value and display its underlying null randomization distribution (PNAS)](https://pmc.ncbi.nlm.nih.gov/articles/PMC7431075/)
5. [Leveraging the Fisher Randomization Test using Confidence Distributions (JRSS-B)](https://academic.oup.com/jrsssb/article/83/4/777/7056013)
6. [10 Things to Know About Randomization Inference – EGAP Methods Guide](https://methods.egap.org/guides/analysis-procedures/randomization-inference_en.html)
7. [Randomization inference – Tabaré Capitán, technical notes](https://tabarecapitan.com/projects/ritest/technical-notes/ri.html)
8. [ri2: R package reference manual](https://cran.r-project.org/web/packages/ri2/refman/ri2.html)
9. [randomizationInference: Flexible Randomization-Based Inference](https://cran.r-universe.dev/randomizationInference)
10. [Randomization Tests for Weak Null Hypotheses in Randomized Experiments](https://ar5iv.labs.arxiv.org/html/1809.07419)
11. [Randomization Inference: Theory and Applications](https://arxiv.org/abs/2406.09521)
12. [Permutation Test (Kosuke Imai, teaching notes)](https://imai.fas.harvard.edu/teaching/files/permutation_test.pdf)
13. [The Design of Experiments, Chapter 2 (Interpretation and its Reasoned Basis), R. A. Fisher](https://www.jhanley.biostat.mcgill.ca/c607/ch06/lady_tasting_tea.pdf)
14. [A Paradox From Randomization-Based Causal Inference](https://ar5iv.labs.arxiv.org/html/1402.0142)
15. [Some theoretical foundations for the design and analysis (Journal of Causal Inference)](https://www.degruyterbrill.com/document/doi/10.1515/jci-2023-0067/html)
16. [Randomization Inference | Method Atlas](https://methodatlas.vercel.app/practices/randomization-inference)
17. [B. Efron (1979). Bootstrap Methods: Another Look at the Jackknife. The Annals of Statistics.](https://doi.org/10.1214/aos/1176344552)
18. [Imputation-based randomization tests for randomized experiments with interference](https://arxiv.org/html/2411.08352)
19. [Randomization-based inference for a marginal treatment effect in stepped wedge cluster randomized trials](https://pmc.ncbi.nlm.nih.gov/articles/PMC9014477/)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Statistical inference, estimation, sampling, and testing › Hypothesis testing

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/randomization-inference

English original: https://www.edgepedia.org/randomization-inference
