# 因果森林

[因果森林](https://www.edgepedia.org/zh/causal-forests)是一种机器学习方法，它使用决策树的集成来从观察性或实验性数据中估计异质性处理效应，即条件平均处理效应 \( \tau(X) = E[Y(1) - Y(0) \mid X = x] \)。与预测结果的随机森林不同，它针对的是处理效应如何在各个单元之间变化，使用森林导出的权重而非平均结果预测。<sup>[1](https://doi.org/10.1080/01621459.2017.1319839)</sup>

| 关键事实 | 详情 |
|---|---|
| 目标量 | 对于二值无混淆处理，为 \( \tau(X) = E[Y(1) - Y(0) \mid X = x] \)；对于连续处理，为平均偏效应 \( \mathrm{Cov}[Y,W \mid X=x] / \mathrm{Var}[W \mid X=x] \)<sup>[2](https://search.r-project.org/CRAN/refmans/grf/html/causal_forest.html)</sup> |
| 提出者 | Stefan Wager 与 Susan Athey，《美国统计协会杂志》，2017年<sup>[1](https://doi.org/10.1080/01621459.2017.1319839)</sup> |
| 分裂规则 | 最大化 \( n_L \cdot n_R (\hat{\tau}_L - \hat{\tau}_R)^2 \)，即子节点之间估计处理效应之差的平方<sup>[3](https://grf-labs.github.io/grf/articles/grf_guide.html)</sup> |
| 诚实性 | grf 中的默认设置：子样本对半分割，一半用于分裂，另一半用于填充叶节点<sup>[4](https://github.com/grf-labs/grf/blob/master/REFERENCE.md)</sup> |
| 推断保证 | 逐点一致性、渐近高斯且中心化的抽样分布、无混淆性下的渐近置信区间<sup>[1](https://doi.org/10.1080/01621459.2017.1319839)</sup> |
| 默认设置与运行时间 | 默认 2,000 棵树；1,000,000 个观测、30 个协变量在 24 核上训练约需 1 小时，占用约 25 GB<sup>[4](https://github.com/grf-labs/grf/blob/master/REFERENCE.md)</sup> |
| 软件 | R 和 C++ 中的 grf（ranger 的一个分支）；Python 中的 EconML 和 causalML<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC11966565/)</sup> |

## 工作原理

由于个体处理效应永远无法被观测到，因果森林无法直接对效应进行回归。它转而使用两步正交构造：结果 \( Y \) 对其条件均值取残差，处理 \( W \) 对倾向得分 \( e(x) = E[W_i \mid X_i = x] \) 取残差，得到 Robinson 的中心化形式 \( Y_i - m(x) = \tau \cdot (W_i - e(x)) + \varepsilon_i \)。<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC11966565/)</sup> 正交性限制了对干扰参数估计误差的一阶敏感性，而对于合适的目标——例如常数处理效应——当 \( m(x) \) 和 \( e(x) \) 被足够快地估计时，可以达到根号 \( n \) 收敛速率，得分方程是 Neyman 正交的，因此即使干扰参数估计量有些不精确，森林也能准确地瞄准 \( \tau(x) \)。<sup>[3](https://grf-labs.github.io/grf/articles/grf_guide.html)</sup><sup> • </sup><sup>[6](https://arxiv.org/pdf/2206.10323)</sup>

树的分裂是为了检测效应异质性，而非拟合结果。与回归森林中最小化均方误差不同，分裂目标惩罚增加节点内方差的分裂，奖励增加节点间处理效应方差的分裂。<sup>[7](https://papers.tinbergen.nl/21090.pdf)</sup> grf 通过残差对残差回归计算 \( n_L \cdot n_R (\hat{\tau}_L - \hat{\tau}_R)^2 \)，并且不在每个候选分裂处重新估计目标参数。<sup>[3](https://grf-labs.github.io/grf/articles/grf_guide.html)</sup>

诚实性意味着每个训练样本的响应 \( Y_i \) 要么用于放置分裂，要么用于估计叶内处理效应，但不能两者兼用；双样本树将子样本分为两半分别承担这两种角色。<sup>[1](https://doi.org/10.1080/01621459.2017.1319839)</sup> 诚实性、\( s/n \to 0 \) 且 \( s \to \infty \) 的子采样、平衡分裂以及每个特征有界的分裂概率，共同支撑了理论保证：在无混淆性的潜在结果框架下，真实处理效应的逐点一致性、渐近高斯且中心化的抽样分布，以及以森林估计为中心的实用渐近置信区间。<sup>[1](https://doi.org/10.1080/01621459.2017.1319839)</sup><sup> • </sup><sup>[8](https://arxiv.org/pdf/1610.01271)</sup>

## 实现方法

`causal_forest` 的 grf 实现遵循标准工作流程。首先，两个独立的回归森林估计 \( \hat{m}(\cdot) \) 和 \( \hat{e}(\cdot) \)；这些森林的袋外预测提供残差 \( W - e(x) \) 和 \( Y - m(x) \)，因果森林随后通过 R-learner 目标在这些残差上进行训练；grf 使用其默认设置，除非要求调参，此时通过诸如 `tune.parameters = 'all'` 之类的选项应用交叉验证。<sup>[9](https://ar5iv.labs.arxiv.org/html/1902.07409)</sup> 在随机试验中，已知的倾向得分通过 `W.hat` 参数直接提供，而非进行估计。<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC11966565/)</sup>

默认设置为 `num.trees = 2000`、`sample.fraction = 0.5`、`mtry = min(ceiling(sqrt(p) + 20), p)`、`min.node.size = 5`、`honesty = TRUE` 且 `honesty.fraction = 0.5`，以及 `tune.parameters = 'none'`；使用 `'all'` 调参会交叉验证七个参数，而准确的置信区间通常比准确的预测需要更多的树。<sup>[2](https://search.r-project.org/CRAN/refmans/grf/html/causal_forest.html)</sup> 在因果森林中，一个节点必须包含至少 `min.node.size` 个处理样本和同样数量的对照样本。<sup>[4](https://github.com/grf-labs/grf/blob/master/REFERENCE.md)</sup> [评估](https://www.edgepedia.org/zh/evaluation)使用通过增广逆倾向加权或目标最大似然估计得到的双重稳健平均处理效应得分、最佳线性投影、校准检验，以及目标算子特征曲线——该曲线将预测效应位于最高 \( q \) 分位数的单元中的 ATE 与整体 ATE 进行比较；在常数效应的零假设下，其面积期望为零。<sup>[4](https://github.com/grf-labs/grf/blob/master/REFERENCE.md)</sup><sup> • </sup><sup>[3](https://grf-labs.github.io/grf/articles/grf_guide.html)</sup>

主要实现是用于 R 和 C++ 的 grf，可从 CRAN 获取，构建在 ranger 包的分裂规则之上；该代码仓库最初是 ranger 的一个分支。<sup>[8](https://arxiv.org/pdf/1610.01271)</sup><sup> • </sup><sup>[10](https://grf-labs.github.io/grf/index.html)</sup> Python 用户可以使用 EconML 和 causalML 库。<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC11966565/)</sup>

## 起源

其谱系经过若干步骤。随机森林由 [Leo Breiman](https://www.edgepedia.org/zh/leo-breiman) 于 2001 年在《机器学习》中提出。<sup>[11](https://doi.org/10.1023/a:1010933404324)</sup> 用于异质性因果效应的递归分割——带有处理效应分裂规则和诚实数据分割——由 [Susan Athey](https://www.edgepedia.org/zh/susan-athey) 和 [Guido Imbens](https://www.edgepedia.org/zh/guido-imbens) 于 2016 年在《美国国家科学院院刊》上提出；他们的因果树是因果森林背后的一个简化形式。<sup>[12](https://doi.org/10.1073/pnas.1510489113)</sup><sup> • </sup><sup>[1](https://doi.org/10.1080/01621459.2017.1319839)</sup> 因果森林本身及其推断理论由 Stefan Wager 和 Susan Athey 于 2017 年在《美国统计协会杂志》上提出。<sup>[1](https://doi.org/10.1080/01621459.2017.1319839)</sup> 广义随机森林由 Susan Athey、Julie Tibshirani 和 Stefan Wager 于 2019 年在《统计年鉴》上提出，通过自适应森林权重拟合任何由局部矩方程识别的量。<sup>[8](https://arxiv.org/pdf/1610.01271)</sup> 森林所最小化的 R-learner 目标由 Xinkun Nie 和 Stefan Wager 于 2017 年提出。<sup>[13](https://doi.org/10.48550/arxiv.1712.04912)</sup>

## 变体

广义随机森林框架放弃了集成成员估计的平均，转而使用局部矩方程中的森林权重，支持若干命名扩展：用于由工具变量识别的处理效应的工具变量森林；用于右删失结果的因果生存森林，由 Yifan Cui、Michael R Kosorok、Erik Sverdrup、Stefan Wager 和 Ruoqing Zhu 于 2023 年提出；以及局部线性森林，由 Rina Friedberg、Julie Tibshirani、Susan Athey 和 Stefan Wager 于 2020 年提出，增加了局部线性校正。<sup>[8](https://arxiv.org/pdf/1610.01271)</sup><sup> • </sup><sup>[14](https://doi.org/10.1093/jrsssb/qkac001)</sup><sup> • </sup><sup>[15](https://doi.org/10.1080/10618600.2020.1831930)</sup><sup> • </sup><sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC11966565/)</sup> 正交随机森林变体将 Neyman 正交性与广义随机森林相结合，以降低对干扰参数估计误差的敏感性。<sup>[16](https://proceedings.mlr.press/v97/oprescu19a.html)</sup>

## 应用

在原始实验中，因果森林的效力显著高于最近邻匹配，尤其是在存在无关协变量的情况下；在二维处理效应支撑下，其表现与 50-最近邻匹配相当。<sup>[1](https://doi.org/10.1080/01621459.2017.1319839)</sup> 最多 15 个协变量的模拟表明，诚实因果森林在偏差和置信区间覆盖率方面可以优于 k-最近邻，但在高维情况下覆盖率可能不足。<sup>[17](https://academic.oup.com/aje/advance-article-abstract/doi/10.1093/aje/kwad043/7056288)</sup>

应用涵盖医学、经济学、市场营销和政治学：减肥干预对心血管死亡率的事后分析、SPRINT 试验的二次分析、美国糖尿病试验中强化血糖控制的回顾性研究、暑期青年就业项目，以及一个精神病学教程——将因果森林应用于美国陆军部署前数据以研究对战斗压力的韧性。<sup>[17](https://academic.oup.com/aje/advance-article-abstract/doi/10.1093/aje/kwad043/7056288)</sup><sup> • </sup><sup>[18](https://journals.sagepub.com/doi/full/10.1177/20531680231153080)</sup><sup> • </sup><sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC11966565/)</sup> 基于森林估计的策略学习由 policytree 包支持，该包由 Erik Sverdrup、Ayush Kanodia、Zhengyuan Zhou、Susan Athey 和 Stefan Wager 于 2020 年提出。<sup>[19](https://doi.org/10.21105/joss.02232)</sup>

## 局限性与替代方法

识别依赖于无混淆性和重叠性，而算法并不检验这两者。一项对应用研究的综述发现，大多数控制可观测变量的论文没有明确检验重叠假设或修剪倾向得分；在[蒙特卡洛](https://www.edgepedia.org/zh/monte-carlo)研究中，将倾向得分修剪至 0.01-0.99 可解决共同支撑不足的问题，在此情况下重叠加权 ATE 估计量表现更好。<sup>[20](https://arxiv.org/pdf/2404.13356)</sup><sup> • </sup><sup>[7](https://papers.tinbergen.nl/21090.pdf)</sup> 在小样本中，CATE 估计容易犯第二类错误，而变量重要性和效应图等常见输出不附带置信区间。<sup>[20](https://arxiv.org/pdf/2404.13356)</sup>

与替代方法的比较因任务而异。在蒙特卡洛研究中，贝叶斯因果森林和双重机器学习表现最佳，在某些场景下相比传统回归减少了 69-98% 的偏差，尽管所有方法对超过 150 个协变量的集合都很敏感；GRF 在 ATE 上通常略逊于 BCF 或 ps-BART，但在更高维数据上性能下降较小。<sup>[21](https://pmc.ncbi.nlm.nih.gov/articles/PMC6863230/)</sup> 2024 年的一项比较发现，当处理选择不太强时，基于 DML 的方法在 ATE 和少数组的组效应方面表现出色，而以结果为中心的森林方法在更精细的异质性方面更优，而直接最小化个体处理效应 MSE 的修正因果森林在强选择下是最稳健的估计量。<sup>[22](https://arxiv.org/pdf/2405.10198)</sup> BART 本身由 Hugh A. Chipman、Edward I. George 和 Robert E. McCulloch 于 2010 年提出，是一种贝叶斯替代方法，将 DML 与用作干扰参数估计量的 BART 相结合，在有限样本比较中位列最佳表现者之一。<sup>[23](https://doi.org/10.1214/09-aoas285)</sup><sup> • </sup><sup>[7](https://papers.tinbergen.nl/21090.pdf)</sup>

最近的两项发现对默认设置提出了限定。第一，一项覆盖 7,500 个数据集的 2025 年基准测试发现，在低信噪比设置下诚实估计优于自适应估计，在低信噪比极端情况下以少 13% 的数据达到同等性能，但在高信噪比设置下诚实森林需要多 75% 以上的数据才能赶上；作者建议在留出数据上评估两种策略，而非默认使用诚实性——后者仍是 grf 和 EconML 中的默认设置。<sup>[24](https://arxiv.org/pdf/2506.13107)</sup> 第二，2024 年的比较认为 grf 通过袋外预测进行的局部中心化违反了交叉拟合所需的训练数据与预测数据的完全分离，而 grf 文档将袋外预测呈现为一种森林原生的留一交叉拟合形式；这一分歧尚未解决。<sup>[22](https://arxiv.org/pdf/2405.10198)</sup><sup> • </sup><sup>[3](https://grf-labs.github.io/grf/articles/grf_guide.html)</sup>

## References

1. [Stefan Wager, Susan Athey (2017). Estimation and Inference of Heterogeneous Treatment Effects using Random Forests. Journal of the American Statistical Association.](https://doi.org/10.1080/01621459.2017.1319839)
2. [R: causal_forest (function reference, grf package)](https://search.r-project.org/CRAN/refmans/grf/html/causal_forest.html)
3. [An introduction to grf (official vignette)](https://grf-labs.github.io/grf/articles/grf_guide.html)
4. [grf REFERENCE.md (official algorithm reference)](https://github.com/grf-labs/grf/blob/master/REFERENCE.md)
5. [Estimating Treatment Effect Heterogeneity in Psychiatry: A Review and Tutorial With Causal Forests (Sverdrup, Petukhova & Wager, IJMPR 2025)](https://pmc.ncbi.nlm.nih.gov/articles/PMC11966565/)
6. [What Makes Forest-Based Heterogeneous Treatment Effect Estimators Work? (arXiv 2206.10323)](https://arxiv.org/pdf/2206.10323)
7. [Finite Sample Evaluation of Causal Machine Learning Methods: Guidelines for the Applied Researcher (Tinbergen Institute Discussion Paper)](https://papers.tinbergen.nl/21090.pdf)
8. [Generalized Random Forests (Athey, Tibshirani & Wager; arXiv 1610.01271; published Annals of Statistics 47(2), 2019)](https://arxiv.org/pdf/1610.01271)
9. [Estimating Treatment Effects with Causal Forests: An Application (Athey & Wager, Observational Studies, 2019)](https://ar5iv.labs.arxiv.org/html/1902.07409)
10. [Generalized Random Forests • grf (package site)](https://grf-labs.github.io/grf/index.html)
11. [Leo Breiman (2001). Random Forests. Machine Learning.](https://doi.org/10.1023/a:1010933404324)
12. [Susan Athey, Guido Imbens (2016). Recursive partitioning for heterogeneous causal effects. Proceedings of the National Academy of Sciences.](https://doi.org/10.1073/pnas.1510489113)
13. [Nie, Xinkun, Wager, Stefan (2017). Quasi-Oracle Estimation of Heterogeneous Treatment Effects. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1712.04912)
14. [Yifan Cui and colleagues (2023). Estimating heterogeneous treatment effects with right-censored data via causal survival forests. Journal of the Royal Statistical Society Series B (Statistical Methodology).](https://doi.org/10.1093/jrsssb/qkac001)
15. [Rina Friedberg and colleagues (2020). Local Linear Forests. Journal of Computational and Graphical Statistics.](https://doi.org/10.1080/10618600.2020.1831930)
16. [Orthogonal Random Forest for Causal Inference (Oprescu, Syrgkanis & Wu, ICML 2019, PMLR v97)](https://proceedings.mlr.press/v97/oprescu19a.html)
17. [Practical Guide to Honest Causal Forests for Identifying Heterogeneous Treatment Effects (American Journal of Epidemiology)](https://academic.oup.com/aje/advance-article-abstract/doi/10.1093/aje/kwad043/7056288)
18. [Estimating and evaluating treatment effect heterogeneity: A causal forests approach (Sage, political science, 2023)](https://journals.sagepub.com/doi/full/10.1177/20531680231153080)
19. [Erik Sverdrup and colleagues (2020). policytree: Policy learning via doubly robust empirical welfare maximization over trees. The Journal of Open Source Software.](https://doi.org/10.21105/joss.02232)
20. [A review of causal forest usage in control-on-observables designs (arXiv 2404.13356, 2024)](https://arxiv.org/pdf/2404.13356)
21. [Estimating treatment effects with machine learning (peer-reviewed Monte Carlo comparison, PMC)](https://pmc.ncbi.nlm.nih.gov/articles/PMC6863230/)
22. [Comprehensive Causal Machine Learning: comparing modified causal forest (mcf), generalized random forest (grf), and double machine learning (dml) (arXiv 2405.10198, 2024)](https://arxiv.org/pdf/2405.10198)
23. [Hugh A. Chipman, Edward I. George, Robert E. McCulloch (2010). BART: Bayesian additive regression trees. The Annals of Applied Statistics.](https://doi.org/10.1214/09-aoas285)
24. [Honesty in Causal Forests: When It Helps and When It Hurts (arXiv 2506.13107, 2025)](https://arxiv.org/pdf/2506.13107)

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

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Machine learning and neural computation › Machine learning methods › Ensemble, boosting, and transfer methods › Bagging, random forests, and variance-reduction ensembles

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/causal-forest

English original: https://www.edgepedia.org/causal-forest
