Causal Inference: What If 第 4-6 章中英对照¶
原书: Causal Inference: What If
作者: Miguel A. Hernán, James M. Robins
出版社: Chapman & Hall/CRC (2020)
ISBN: 978-1-4398-8662-5
官方链接: https://www.hsph.harvard.edu/miguel-hernan/causal-inference-book/
翻译时间: 2026-06-01
状态: 中英对照编译版
前续: 第 1-3 章
📚 目录 (Table of Contents)¶
第一部分:因果推断的基本概念 (Chapters 1-10)¶
- Chapter 4: Confounding (混杂)
- Chapter 5: Standardization (标准化)
- Chapter 6: Inverse Probability Weighting (逆概率加权)
Chapter 4: Confounding¶
第 4 章:混杂¶
4.1 什么是混杂?(What is Confounding?)¶
English:
Confounding occurs when the association between an exposure and an outcome is distorted by the presence of another variable that is associated with both the exposure and the outcome. Confounding can lead to biased estimates of causal effects.
中文:
当暴露与结局之间的关联被另一个与暴露和结局都相关的变量的存在所扭曲时,就会发生混杂。混杂可能导致因果效应估计的偏倚。
混杂的三个条件 (Three Conditions for Confounding):
| 条件 | 英文 | 中文 |
|---|---|---|
| 1 | The confounder is associated with the exposure | 混杂因素与暴露相关 |
| 2 | The confounder is a cause of the outcome | 混杂因素是结局的原因 |
| 3 | The confounder is not on the causal pathway | 混杂因素不在因果路径上 |
示例 (Example):
研究问题:咖啡饮用 (A) 是否导致肺癌 (Y)?
观察到的关联:咖啡饮用者肺癌风险更高
混杂因素:吸烟 (L)
- 吸烟与咖啡饮用相关 ✓
- 吸烟导致肺癌 ✓
- 吸烟不在咖啡→肺癌的因果路径上 ✓
结论:观察到的关联可能是由吸烟混杂造成的
4.2 混杂的图形表示 (Graphical Representation of Confounding)¶
English:
Causal diagrams (DAGs) can help identify confounding. A confounder L creates a backdoor path from exposure A to outcome Y:
中文:
因果图 (DAG) 可以帮助识别混杂。混杂因素 L 创建了一条从暴露 A 到结局 Y 的后门路径:
DAG 示例:
阻断后门路径 (Blocking Backdoor Paths):
4.3 选择偏倚 vs 混杂 (Selection Bias vs Confounding)¶
English:
Selection bias occurs when the association between exposure and outcome is distorted due to the way participants are selected into the study. Unlike confounding, selection bias cannot be controlled by adjusting for pre-exposure variables.
中文:
当暴露与结局之间的关联由于参与者被选入研究的方式而被扭曲时,就会发生选择偏倚。与混杂不同,选择偏倚不能通过调整暴露前变量来控制。
对比表 (Comparison):
| 特征 | 混杂 (Confounding) | 选择偏倚 (Selection Bias) |
|---|---|---|
| 来源 | 暴露前因素 | 选择过程 |
| 控制方法 | 调整混杂因素 | 改进研究设计 |
| DAG 特征 | 后门路径 | 对撞子激活 |
| 例子 | 吸烟混杂咖啡 - 肺癌 | 志愿者偏倚、失访偏倚 |
4.4 效应修饰 (Effect Modification)¶
English:
Effect modification occurs when the magnitude or direction of the causal effect of exposure A on outcome Y differs across levels of a third variable M. The variable M is called an effect modifier.
中文:
当暴露 A 对结局 Y 的因果效应的大小或方向在第三个变量 M 的不同水平上不同时,就会发生效应修饰。变量 M 称为效应修饰因子。
示例 (Example):
研究:药物 (A) 对死亡率 (Y) 的效果
按性别 (M) 分层:
- 男性:RR = 0.5 (药物降低 50% 风险)
- 女性:RR = 0.9 (药物降低 10% 风险)
结论:性别是效应修饰因子
药物效果在男性和女性中不同
混杂 vs 效应修饰 (Confounding vs Effect Modification):
| 方面 | 混杂 | 效应修饰 |
|---|---|---|
| 本质 | 偏倚来源 | 真实现象 |
| 处理 | 需要控制 | 需要报告 |
| 分层后 | 层间效应相同 | 层间效应不同 |
| 目标 | 消除 | 描述 |
Chapter 5: Standardization¶
第 5 章:标准化¶
5.1 标准化的目的 (Purpose of Standardization)¶
English:
Standardization is a method to control for confounding by creating a pseudo-population in which the distribution of the confounder is the same in both exposure groups. This allows for an unbiased estimate of the causal effect.
中文:
标准化是一种通过创建一个伪总体来控制混杂的方法,在这个伪总体中,混杂因素的分布在两个暴露组中是相同的。这允许对因果效应进行无偏估计。
标准化思想 (Standardization Concept):
原始数据:
┌────────────┬───────────────┬───────────────┐
│ 年龄组 │ 治疗组死亡率 │ 对照组死亡率 │
├────────────┼───────────────┼───────────────┤
│ <50 岁 │ 5% │ 10% │
│ ≥50 岁 │ 20% │ 40% │
└────────────┴───────────────┴───────────────┘
问题:治疗组年轻人更多,直接比较有混杂
标准化后:
使用标准人口权重计算加权平均
→ 消除年龄分布差异
5.2 直接标准化 (Direct Standardization)¶
English:
In direct standardization, we calculate the weighted average of stratum-specific effects, using the distribution of the confounder in a standard population as weights.
中文:
在直接标准化中,我们计算层特异性效应的加权平均,使用标准总体中混杂因素的分布作为权重。
公式 (Formula):
其中: - \(E[Y^a]\): 暴露水平为 a 时的标准化结局 - \(E[Y|A=a, L=l]\): 层 l 中暴露为 a 的条件结局 - \(P(L=l)\): 标准总体中 L=l 的比例
计算示例 (Calculation Example):
数据:
┌────────────┬───────────────┬───────────────┬──────────────┐
│ 年龄组 │ 治疗组死亡率 │ 对照组死亡率 │ 标准人口权重 │
├────────────┼───────────────┼───────────────┼──────────────┤
│ <50 岁 │ 5% │ 10% │ 60% │
│ ≥50 岁 │ 20% │ 40% │ 40% │
└────────────┴───────────────┴───────────────┴──────────────┘
标准化死亡率:
治疗组:0.05×0.6 + 0.20×0.4 = 0.11 (11%)
对照组:0.10×0.6 + 0.40×0.4 = 0.22 (22%)
标准化风险差:0.11 - 0.22 = -0.11
标准化风险比:0.11 / 0.22 = 0.50
5.3 间接标准化 (Indirect Standardization)¶
English:
In indirect standardization, we apply the stratum-specific rates from a standard population to the study population to calculate expected events, then compare observed to expected events.
中文:
在间接标准化中,我们将标准总体的层特异性率应用于研究人群以计算预期事件,然后比较观察事件与预期事件。
应用场景 (Applications):
| 方法 | 适用场景 | 优点 | 缺点 |
|---|---|---|---|
| 直接标准化 | 各层样本量充足 | 直观、可解释 | 小样本不稳定 |
| 间接标准化 | 某些层样本量小 | 稳定 | 需要标准率 |
5.4 可交换性与标准化 (Exchangeability and Standardization)¶
English:
Standardization works because it creates conditional exchangeability. Within each stratum of the confounder L, the exposed and unexposed are exchangeable:
中文:
标准化有效是因为它创造了条件可交换性。在混杂因素 L 的每个层内,暴露组和未暴露组是可交换的:
条件可交换性 (Conditional Exchangeability):
这意味着: - 在 L 的每个水平内,暴露分配与潜在结果独立 - 层内比较是无偏的 - 标准化组合层内估计得到边际效应
Chapter 6: Inverse Probability Weighting¶
第 6 章:逆概率加权¶
6.1 IPW 的基本思想 (Basic Idea of IPW)¶
English:
Inverse probability weighting (IPW) is a method to control for confounding by creating a pseudo-population in which each individual is weighted by the inverse of the probability of receiving the treatment they actually received.
中文:
逆概率加权 (IPW) 是一种通过创建一个伪总体来控制混杂的方法,在这个伪总体中,每个个体的权重是他们实际接受处理的概率的倒数。
IPW 权重 (IPW Weights):
其中: - \(W^A\): 逆概率权重 - \(P(A|L)\): 给定协变量 L 时接受处理 A 的条件概率(倾向评分)
直观解释 (Intuitive Explanation):
示例:
- 个体 i 的倾向评分:P(A=1|L) = 0.2 (20% 概率接受治疗)
- 个体 i 实际接受了治疗 (A=1)
- 个体 i 的权重:W = 1/0.2 = 5
解释:
这个个体代表了 5 个类似特征的人
因为像他这样特征的人只有 20% 接受治疗
6.2 倾向评分 (Propensity Score)¶
English:
The propensity score is the probability of receiving the treatment given the observed covariates. It is typically estimated using logistic regression.
中文:
倾向评分是在给定观察协变量的情况下接受处理的概率。它通常使用逻辑回归来估计。
倾向评分模型 (Propensity Score Model):
# Python 示例
import pandas as pd
from sklearn.linear_model import LogisticRegression
# 数据
X = df[covariates] # 协变量
A = df['treatment'] # 处理
# 拟合倾向评分模型
propensity_model = LogisticRegression()
propensity_model.fit(X, A)
# 获取倾向评分
df['propensity_score'] = propensity_model.predict_proba(X)[:, 1]
# 计算 IPW 权重
df['weight'] = df['treatment'] / df['propensity_score'] + \
(1 - df['treatment']) / (1 - df['propensity_score'])
倾向评分的性质 (Properties):
| 性质 | 说明 |
|---|---|
| 平衡性 | 倾向评分相同的个体,协变量分布相似 |
| 降维 | 将多个协变量压缩为一个分数 |
| 重叠性 | 需要共同支撑 (common support) |
6.3 稳定化权重 (Stabilized Weights)¶
English:
Stabilized weights incorporate the marginal probability of treatment to reduce variability:
中文:
稳定化权重纳入处理的边际概率以减少变异性:
稳定化权重公式 (Stabilized Weight Formula):
对于治疗组 (A = 1): $$ SW^A = \frac{P(A=1)}{P(A=1|L)} $$
对于对照组 (A = 0): $$ SW^A = \frac{P(A=0)}{P(A=0|L)} $$
优势 (Advantages):
| 权重类型 | 方差 | 解释 | 推荐度 |
|---|---|---|---|
| 非稳定化权重 | 较大 | 创造伪总体 | ⭐⭐⭐ |
| 稳定化权重 | 较小 | 保持样本量 | ⭐⭐⭐⭐⭐ |
6.4 IPW 的假设 (Assumptions of IPW)¶
English:
IPW requires several assumptions to provide unbiased causal effect estimates:
中文:
IPW 需要几个假设才能提供无偏的因果效应估计:
核心假设 (Core Assumptions):
- 可交换性 (Exchangeability)
- \(Y^a \perp A | L\)
-
所有混杂因素都已测量并纳入模型
-
正值性 (Positivity)
- \(P(A=a|L=l) > 0\) for all l
-
每个协变量组合都有机会接受所有处理水平
-
一致性 (Consistency)
- 观察到的结局等于对应潜在结果
-
处理定义明确
-
模型正确指定 (Correct Model Specification)
- 倾向评分模型正确指定
- 包含所有相关协变量和交互项
正值性 violations (Positivity Violations):
违反正值性的情况:
L (年龄) P(A=1|L)
<18 岁 0.0 ✗ (确定性治疗)
18-65 岁 0.3 ✓
>65 岁 1.0 ✗ (确定性不治疗)
解决方案:
- 限制分析范围 (如仅 18-65 岁)
- 合并稀疏层
- 使用截断权重
6.5 IPW vs 标准化 (IPW vs Standardization)¶
English:
Both IPW and standardization are methods to control for confounding, but they have different properties:
中文:
IPW 和标准化都是控制混杂的方法,但它们有不同的性质:
对比表 (Comparison):
| 特征 | 标准化 | IPW |
|---|---|---|
| 权重 | 标准人口分布 | 倾向评分倒数 |
| 方差 | 通常较小 | 可能较大 |
| 外推 | 需要 | 不需要 |
| 多处理 | 复杂 | 相对简单 |
| 时间变化暴露 | 复杂 | 可扩展 |
| 模型依赖 | 结局模型 | 倾向评分模型 |
何时使用 (When to Use):
| 场景 | 推荐方法 | 理由 |
|---|---|---|
| 混杂因素少 | 标准化 | 简单直观 |
| 混杂因素多 | IPW | 避免高维分层 |
| 时间变化暴露 | IPW | 可扩展到 MSM |
| 倾向评分重叠差 | 标准化 | IPW 权重不稳定 |
6.6 实践示例 (Practical Example)¶
English:
Let's walk through a complete IPW analysis:
中文:
让我们完成一个完整的 IPW 分析:
完整代码示例 (Complete Code Example):
import pandas as pd
import numpy as np
from sklearn.linear_model import LogisticRegression
import statsmodels.api as sm
# 1. 加载数据
df = pd.read_csv('observational_data.csv')
# 2. 估计倾向评分
covariates = ['age', 'sex', 'comorbidity', 'severity']
X = df[covariates]
A = df['treatment']
propensity_model = LogisticRegression(max_iter=1000)
propensity_model.fit(X, A)
df['ps'] = propensity_model.predict_proba(X)[:, 1]
# 3. 计算稳定化权重
p_treatment = A.mean()
df['sw'] = np.where(
A == 1,
p_treatment / df['ps'],
(1 - p_treatment) / (1 - df['ps'])
)
# 4. 检查权重分布
print(df['sw'].describe())
# 5. 检查平衡性
for cov in covariates:
weighted_diff = np.average(
df.groupby('treatment')[cov].mean(),
weights=df.groupby('treatment')['sw'].sum()
)
print(f"{cov}: weighted difference = {weighted_diff:.3f}")
# 6. 加权结局分析
outcome_model = sm.WLS(
df['outcome'],
sm.add_constant(df['treatment']),
weights=df['sw']
)
result = outcome_model.fit()
print(result.summary())
# 因果效应估计
causal_effect = result.params['treatment']
print(f"Estimated causal effect: {causal_effect:.3f}")
6.7 本章小结 (Chapter Summary)¶
核心概念 (Core Concepts):
- 混杂 (Confounding)
- 扭曲暴露 - 结局关联的第三变量
- 通过 DAG 识别后门路径
-
需要与效应修饰区分
-
标准化 (Standardization)
- 创建伪总体消除混杂
- 直接标准化使用标准人口权重
-
需要条件可交换性
-
逆概率加权 (IPW)
- 使用倾向评分倒数作为权重
- 稳定化权重减少变异性
- 需要可交换性、正值性、一致性
关键术语表 (Glossary):
| English | 中文 | 定义 |
|---|---|---|
| Confounding | 混杂 | 第三变量扭曲暴露 - 结局关联 |
| Confounder | 混杂因素 | 引起混杂的变量 |
| Effect modification | 效应修饰 | 效应在不同亚组中不同 |
| Standardization | 标准化 | 加权平均消除混杂 |
| Propensity score | 倾向评分 | 接受处理的概率 |
| IPW | 逆概率加权 | 使用权重控制混杂 |
| Stabilized weights | 稳定化权重 | 纳入边际概率的权重 |
| Positivity | 正值性 | 所有处理都有一定概率 |
| Backdoor path | 后门路径 | 通过混杂因素的关联路径 |
| Conditional exchangeability | 条件可交换性 | 层内暴露组可比较 |
📖 学习建议 (Study Recommendations)¶
理解检查 (Comprehension Check)¶
问题 1: 混杂的三个条件是什么?
点击查看答案
1. 混杂因素与暴露相关 2. 混杂因素是结局的原因 3. 混杂因素不在因果路径上问题 2: 标准化和 IPW 的主要区别是什么?
点击查看答案
标准化使用标准人口分布作为权重,IPW 使用倾向评分倒数作为权重。标准化更稳定但难以处理高维混杂,IPW 可扩展但权重可能不稳定。问题 3: 什么是正值性假设?为什么它很重要?
点击查看答案
正值性假设要求每个协变量组合都有一定的概率接受所有处理水平。如果违反,某些亚组完全没有对照或治疗,无法估计因果效应。延伸阅读 (Further Reading)¶
- 混杂与 DAG:
- Greenland, S., Pearl, J., & Robins, J. M. (1999). Causal diagrams for epidemiologic research. Epidemiology.
-
Hernán, M. A., & Robins, J. M. (2006). Estimating causal effects from epidemiological data. JECH.
-
倾向评分方法:
- Rosenbaum, P. R., & Rubin, D. B. (1983). The central role of the propensity score in observational studies for causal effects. Biometrika.
-
Austin, P. C. (2011). An introduction to propensity score methods for reducing the effects of confounding in observational studies. Multivariate Behavioral Research.
-
IPW 与 MSM:
- Robins, J. M., Hernán, M. A., & Brumback, B. (2000). Marginal structural models and causal inference in epidemiology. Epidemiology.
翻译完成时间: 2026-06-01
原书章节: Chapter 4-6
前续: 第 1-3 章
后续: 第 7-9 章 (待创建)