文章目录
- 基本的概念
- 重要的结果
- *若:* ( r 0 , r 1 ) ⊥ Z ∣ X , 0 < P ( Z = z ∣ X ) < 1 , (r_0, r_1) \perp Z | X, \quad 0 < P(Z=z|X) < 1, (r0,r1)⊥Z∣X,0<P(Z=z∣X)<1, *且:* P ( Z = z ∣ X = x ) = P ( Z = z ∣ X = x ′ ) = p ( z ; b ) , ∀ x , x ′ ∈ { b ( x ) = b } . P(Z=z|X=x) = P(Z=z|X=x') = p(z;b), \quad \forall x, x' \in \{b(x)=b\}. P(Z=z∣X=x)=P(Z=z∣X=x′)=p(z;b),∀x,x′∈{b(x)=b}. *则:* ( r 0 , r 1 ) ⊥ Z ∣ b ( X ) , 0 < P ( Z = z ∣ b ( X ) ) < 1. (r_0, r_1) \perp Z | b(X), \quad 0 < P(Z=z|b(X)) < 1. (r0,r1)⊥Z∣b(X),0<P(Z=z∣b(X))<1.
- 应用
- 评估
基本的概念
符号 | 说明 |
---|---|
X | covariate, 用于决策何种treatment |
Z ∈ { 0 , 1 } Z \in \{0, 1 \} Z∈{0,1} | Treatment |
r n i r_{ni} rni | 第 n n n个实例, z n = i z_n=i zn=i 下的反应(outcome) |
Strongly ignorable treatment assignment:
即满足条件可交换性:
(
r
0
,
r
1
)
⊥
Z
∣
X
.
(r_0, r_1) \perp Z | X.
(r0,r1)⊥Z∣X.
Balancing Score:
一个关于随机变量
X
X
X的函数
b
(
X
)
b(X)
b(X)被称为balancing score, 若:
X
⊥
Z
∣
b
(
X
)
.
X \perp Z | b(X).
X⊥Z∣b(X).
Propensity Score:
e ( x ) : = P ( Z = 1 ∣ X = x ) . e(x) := P(Z=1|X=x). e(x):=P(Z=1∣X=x).
重要的结果
X ⊥ Z ∣ b ( X ) X \perp Z | b(X) X⊥Z∣b(X)
一个函数 b ( X ) b(X) b(X)是balancing score, 当且仅当存在一个映射 f f f使得 e ( X ) = f ( ( b ( X ) ) e(X) = f((b(X)) e(X)=f((b(X)).
⇐ \Leftarrow ⇐
当,
b
(
x
)
≠
b
b(x) \not= b
b(x)=b的时候, 显然
P
(
Z
=
z
,
X
=
x
∣
b
(
X
)
=
b
)
=
0
P(Z=z, X=x|b(X)=b)=0
P(Z=z,X=x∣b(X)=b)=0, 此时满足条件独立性, 故只需考虑
b
(
x
)
=
b
b(x) = b
b(x)=b的情况.
P
(
Z
=
z
,
X
=
x
∣
b
(
X
)
=
b
)
=
P
(
Z
=
z
∣
X
=
x
,
b
(
X
)
=
b
)
P
(
X
=
x
∣
b
(
X
)
=
b
)
=
P
(
Z
=
z
∣
X
=
x
)
P
(
X
=
x
∣
b
(
X
)
=
b
)
=
?
P
(
Z
=
z
∣
b
(
X
)
=
b
)
P
(
X
=
x
∣
b
(
X
)
=
b
)
.
\begin{array}{ll} P(Z=z, X=x|b(X)=b) &= P(Z=z| X=x, b(X) = b) \: P(X=x|b(X)=b) \\ &= P(Z=z| X=x) \: P(X=x|b(X)=b) \\ &\mathop{=}\limits^{?}P(Z=z|b(X)=b) \: P(X=x|b(X)=b). \end{array}
P(Z=z,X=x∣b(X)=b)=P(Z=z∣X=x,b(X)=b)P(X=x∣b(X)=b)=P(Z=z∣X=x)P(X=x∣b(X)=b)=?P(Z=z∣b(X)=b)P(X=x∣b(X)=b).
显然最后一个等式成立, 只需满足:
P
(
Z
=
z
∣
b
(
X
)
=
b
)
=
P
(
Z
=
z
∣
X
=
x
)
=
e
(
x
′
)
z
⋅
(
1
−
e
(
x
′
)
)
1
−
z
,
∀
x
′
∈
{
x
∣
b
(
X
)
=
b
}
P(Z=z|b(X)=b) = P(Z=z|X=x) = e(x')^z \cdot (1 - e(x'))^{1-z}, \quad \forall x' \in \{x| b(X) = b\}
P(Z=z∣b(X)=b)=P(Z=z∣X=x)=e(x′)z⋅(1−e(x′))1−z,∀x′∈{x∣b(X)=b}
注: 最后一个等式成立, 是因为 e ( x ′ ) = f ( b ( x ′ ) ) = f ( b ) e(x') = f(b(x')) = f(b) e(x′)=f(b(x′))=f(b).
又
P
(
Z
=
z
∣
b
(
X
)
=
b
)
=
∑
x
′
∈
{
b
(
X
)
=
b
}
P
(
Z
=
z
∣
X
=
x
′
,
b
(
X
)
=
b
)
P
(
X
=
x
′
∣
b
(
X
)
=
b
)
=
∑
x
′
∈
{
b
(
X
)
=
b
}
P
(
Z
=
z
∣
X
=
x
′
)
P
(
X
=
x
′
∣
b
(
X
)
=
b
)
=
∑
x
′
∈
{
b
(
X
)
=
b
}
e
(
x
′
)
z
⋅
(
1
−
e
(
x
′
)
)
1
−
z
P
(
X
=
x
′
∣
b
(
X
)
=
b
)
=
e
(
x
′
)
z
⋅
(
1
−
e
(
x
′
)
)
1
−
z
=
P
(
Z
=
z
∣
X
=
x
)
.
\begin{array}{ll} P(Z=z|b(X)=b) &= \sum_{x' \in \{b(X) = b\}}P(Z=z|X=x', b(X)=b)\: P(X=x'|b(X)=b) \\ &= \sum_{x' \in \{b(X) = b\}}P(Z=z|X=x')\: P(X=x'|b(X)=b) \\ &= \sum_{x' \in \{b(X) = b\}} e(x')^z \cdot (1 - e(x'))^{1-z} \: P(X=x'|b(X)=b) \\ &= e(x')^z \cdot (1 - e(x'))^{1-z}\\ &= P(Z=z|X=x). \end{array}
P(Z=z∣b(X)=b)=∑x′∈{b(X)=b}P(Z=z∣X=x′,b(X)=b)P(X=x′∣b(X)=b)=∑x′∈{b(X)=b}P(Z=z∣X=x′)P(X=x′∣b(X)=b)=∑x′∈{b(X)=b}e(x′)z⋅(1−e(x′))1−zP(X=x′∣b(X)=b)=e(x′)z⋅(1−e(x′))1−z=P(Z=z∣X=x).
注: 显然上面的证明是要求
Z
∈
{
0
,
1
}
Z \in \{0, 1\}
Z∈{0,1}的, 即二元的treatment.
除非有额外的条件, 比如:
P
(
Z
=
z
∣
X
=
x
)
=
P
(
Z
=
z
∣
X
=
x
′
)
=
p
(
z
,
b
)
P(Z=z|X=x) = P(Z=z|X=x') = p(z, b)
P(Z=z∣X=x)=P(Z=z∣X=x′)=p(z,b)
对所有的
x
,
x
′
∈
{
x
∣
b
(
X
)
=
b
}
x, x' \in \{x| b(X) = b\}
x,x′∈{x∣b(X)=b}.
⇒ \Rightarrow ⇒
首先, 如果
b
(
X
)
b(X)
b(X)本身从
X
X
X的一个单射, 那么显然存在这样的
f
f
f.
若
b
(
)
b()
b()不是单射, 且不存在
f
f
f使得
e
(
X
)
=
f
(
b
(
X
)
)
e(X) = f(b(X))
e(X)=f(b(X)), 则一定存在
x
,
x
′
x, x'
x,x′使得
e
(
x
)
≠
e
(
x
′
)
,
b
(
x
)
=
b
(
x
′
)
.
e(x) \not= e(x'), \quad b(x) = b(x').
e(x)=e(x′),b(x)=b(x′).
此时:
P
(
Z
=
1
∣
X
=
x
)
≠
P
(
Z
=
z
∣
X
=
x
′
)
→
P
(
Z
=
1
∣
X
=
x
,
b
(
x
)
)
≠
P
(
Z
=
z
∣
X
=
x
′
,
b
(
x
′
)
)
.
P(Z=1|X=x) \not= P(Z=z|X=x') \rightarrow P(Z=1|X=x, b(x)) \not= P(Z=z|X=x', b(x')).
P(Z=1∣X=x)=P(Z=z∣X=x′)→P(Z=1∣X=x,b(x))=P(Z=z∣X=x′,b(x′)).
故
b
(
X
)
b(X)
b(X)不是balancing score, 矛盾.
注: 显然 e ( X ) e(X) e(X)以及 b ( X ) = X b(X) = X b(X)=X均为balancing score.
( r 0 , r 1 ) ⊥ Z ∣ b ( X ) (r_0, r_1) \perp Z | b(X) (r0,r1)⊥Z∣b(X)
若:
(
r
0
,
r
1
)
⊥
Z
∣
X
,
0
<
P
(
Z
=
1
∣
X
)
<
1
,
(r_0, r_1) \perp Z | X, \quad 0 < P(Z=1|X) < 1,
(r0,r1)⊥Z∣X,0<P(Z=1∣X)<1,
则:
(
r
0
,
r
1
)
⊥
Z
∣
b
(
X
)
,
0
<
P
(
Z
=
1
∣
b
(
X
)
)
<
1.
(r_0, r_1) \perp Z | b(X), \quad 0 < P(Z=1|b(X)) < 1.
(r0,r1)⊥Z∣b(X),0<P(Z=1∣b(X))<1.
不等式的证明是显然的.
只需证明:
P
(
Z
=
1
∣
r
0
,
r
1
,
b
(
X
)
=
b
)
=
P
(
Z
=
1
∣
b
(
X
)
=
b
)
=
e
(
X
)
.
P(Z=1|r_0, r_1, b(X)=b) = P(Z=1|b(X)=b) = e(X).
P(Z=1∣r0,r1,b(X)=b)=P(Z=1∣b(X)=b)=e(X).
P
(
Z
=
1
∣
r
0
,
r
1
,
b
(
X
)
=
b
)
=
E
x
E
z
[
[
Z
∣
X
=
x
,
r
0
,
r
1
,
b
(
X
)
=
b
)
]
∣
r
0
,
r
1
,
b
(
X
)
=
b
]
=
E
x
E
z
[
[
Z
∣
X
=
x
)
]
∣
r
0
,
r
1
,
b
(
X
)
=
b
]
=
E
x
[
e
(
X
)
∣
r
0
,
r
1
,
b
(
X
)
=
b
]
=
e
(
X
)
\begin{array}{ll} P(Z=1|r_0, r_1, b(X)=b) &= \mathbb{E}_{x} \mathbb{E}_{z} [[Z|X=x, r_0, r_1,b(X)=b)] |r_0, r_1,b(X)=b] \\ &= \mathbb{E}_{x} \mathbb{E}_{z} [[Z|X=x)] |r_0, r_1,b(X)=b] \\ &= \mathbb{E}_{x} [e(X) |r_0, r_1,b(X)=b] \\ &= e(X) \end{array}
P(Z=1∣r0,r1,b(X)=b)=ExEz[[Z∣X=x,r0,r1,b(X)=b)]∣r0,r1,b(X)=b]=ExEz[[Z∣X=x)]∣r0,r1,b(X)=b]=Ex[e(X)∣r0,r1,b(X)=b]=e(X)
最后一个等式成立, 是因为,
b
(
X
)
=
b
→
e
(
X
)
=
f
(
b
)
b(X)=b \rightarrow e(X) = f(b)
b(X)=b→e(X)=f(b).
倘若上面的额外的条件成立, 即
P
(
Z
=
z
∣
X
=
x
)
=
P
(
Z
=
z
∣
X
=
x
′
)
=
p
(
z
)
.
P(Z=z|X=x) = P(Z=z|X=x') = p(z).
P(Z=z∣X=x)=P(Z=z∣X=x′)=p(z).
则有:
P
(
Z
=
z
∣
r
0
,
r
1
,
b
(
X
)
=
b
)
=
∑
x
′
∈
{
b
(
X
)
=
b
}
P
(
Z
=
z
,
X
=
x
′
∣
r
0
,
r
1
,
b
(
X
)
=
b
)
=
∑
x
′
P
(
Z
=
z
∣
r
0
,
r
1
,
X
=
x
′
,
b
(
X
)
=
b
)
P
(
X
=
x
′
∣
r
0
,
r
1
,
b
(
X
)
=
b
)
=
∑
x
′
P
(
Z
=
z
∣
X
=
x
′
)
P
(
X
=
x
′
∣
r
0
,
r
1
,
b
(
X
)
=
b
)
=
∑
x
′
p
(
z
)
P
(
X
=
x
′
∣
r
0
,
r
1
,
b
(
X
)
=
b
)
=
p
(
z
)
=
P
(
Z
=
z
∣
X
=
x
)
=
P
(
Z
=
z
∣
b
(
X
)
=
b
)
.
\begin{array}{ll} P(Z=z|r_0, r_1, b(X)=b) &= \sum_{x' \in \{b(X) = b\}} P(Z=z, X=x'|r_0, r_1, b(X)=b) \\ &= \sum_{x'} P(Z=z|r_0, r_1, X=x', b(X)=b)\: P(X=x'|r_0, r_1, b(X)=b) \\ &= \sum_{x'} P(Z=z|X=x')\: P(X=x'|r_0, r_1, b(X)=b) \\ &= \sum_{x'} p(z)\: P(X=x'|r_0, r_1, b(X)=b) \\ &= p(z) = P(Z=z|X=x) = P(Z=z|b(X)=b). \end{array}
P(Z=z∣r0,r1,b(X)=b)=∑x′∈{b(X)=b}P(Z=z,X=x′∣r0,r1,b(X)=b)=∑x′P(Z=z∣r0,r1,X=x′,b(X)=b)P(X=x′∣r0,r1,b(X)=b)=∑x′P(Z=z∣X=x′)P(X=x′∣r0,r1,b(X)=b)=∑x′p(z)P(X=x′∣r0,r1,b(X)=b)=p(z)=P(Z=z∣X=x)=P(Z=z∣b(X)=b).
总结为:
若:
(
r
0
,
r
1
)
⊥
Z
∣
X
,
0
<
P
(
Z
=
z
∣
X
)
<
1
,
(r_0, r_1) \perp Z | X, \quad 0 < P(Z=z|X) < 1,
(r0,r1)⊥Z∣X,0<P(Z=z∣X)<1,
且:
P
(
Z
=
z
∣
X
=
x
)
=
P
(
Z
=
z
∣
X
=
x
′
)
=
p
(
z
;
b
)
,
∀
x
,
x
′
∈
{
b
(
x
)
=
b
}
.
P(Z=z|X=x) = P(Z=z|X=x') = p(z;b), \quad \forall x, x' \in \{b(x)=b\}.
P(Z=z∣X=x)=P(Z=z∣X=x′)=p(z;b),∀x,x′∈{b(x)=b}.
则:
(
r
0
,
r
1
)
⊥
Z
∣
b
(
X
)
,
0
<
P
(
Z
=
z
∣
b
(
X
)
)
<
1.
(r_0, r_1) \perp Z | b(X), \quad 0 < P(Z=z|b(X)) < 1.
(r0,r1)⊥Z∣b(X),0<P(Z=z∣b(X))<1.
应用
假设
X
X
X包含所有地confounders, 即
r
⊥
Z
∣
X
.
r \perp Z | X.
r⊥Z∣X.
Propensity Score Matching
既然, 在
e
(
x
)
e(x)
e(x)下:
r
⊥
Z
∣
e
(
x
)
,
r \perp Z | e(x),
r⊥Z∣e(x),
那么:
E
[
r
1
−
r
0
]
=
E
e
(
x
)
{
E
[
r
∣
e
(
x
)
,
Z
=
1
]
−
E
[
r
∣
e
(
x
)
,
Z
=
0
]
}
.
\mathbb{E}[r_1 - r_0] = \mathbb{E}_{e(x)} \: \{\mathbb{E} [r|e(x), Z=1] - \mathbb{E}[r|e(x), Z=0]\}.
E[r1−r0]=Ee(x){E[r∣e(x),Z=1]−E[r∣e(x),Z=0]}.
这个期望的过程可以分解为:
- 随机采样 e ( x ) e(x) e(x);
- 在所有 e ( X ) = e ( x ) e(X)=e(x) e(X)=e(x)的样本中, 随机选择 Z = 0 Z=0 Z=0和 Z = 1 Z=1 Z=1的样本;
通过此过程构造的新的数据集, 显然只需要将treated group中的群体对 r r r取平均减去control group中的平均就能得到最后的treatment effect的估计了.
通过 propensity score matching 重采样构造的数据集满足:
Z
⊥
e
(
X
)
.
Z \perp e(X).
Z⊥e(X).
因为对于每一个treated group 中有一个样本 e ( x ) = e e(x) = e e(x)=e, 在control group中就有一个对应的 e ( x ′ ) = e e(x') = e e(x′)=e.
propensity score matching 重采样的实际方式可以简化为:
- 从treated group 中随机采样一个样本 ( x , z , r ) (x,z,r) (x,z,r);
- 计算其propensity score e ( x ) e(x) e(x);
- 从control group 中找到一个对应的 ( x ′ , z ′ , r ′ ) (x',z',r') (x′,z′,r′) 满足 e ( x ′ ) = e ( x ) e(x')=e(x) e(x′)=e(x);
- 若存在多个 x ′ x' x′, 在其中随机采样一个.
上述采样过程中, 会遇到的问题:
-
不存在 x ′ x' x′, 这种情况是很容易遇到的, 一般, 我们可以选取 x ′ x' x′使得 e ( x ′ ) e(x') e(x′)最接近 e ( x ) e(x) e(x), 这种方式一般称为greedy matching; 或者, 我们可以指定一个threshold, 在threshold内的 { x ′ } \{x'\} {x′}中采样, 若一个都没有, 则舍弃 x x x.
-
x , x ′ x, x' x,x′被选中之后, 是否仍有机会被采样, 这是俩种策略;
Stratification on the Propensity Score
即将
e
(
X
)
e(X)
e(X)的值域分割成互斥的K个部分, 每个部分所包含的样本数量相近.
然后对每一个部分计算treatment effect, 最后再平均(加权平均, 权重为样本数量).
一般情况下,
K
=
5
K=5
K=5, 就能使得每一个stratum内的
e
(
X
)
e(X)
e(X)的值非常接近, 这就能够近似保证:
X
⊥
Z
X \perp Z
X⊥Z
在每一个stratum内成立.
那么, 此时我们只需通过取平均就能直接计算出每一个stratum的treatment effect.
Inverse Probability of Treatment Weighting Using the Propensity Score
这个实际上就是普通的 IP weighting.
评估
显然, 我们多半需要从已有的数据中估计出 propensity score, 比如用常见的逻辑斯蒂回归模型. 自然地, 我们需要判断我们拟合的模型是否正确.
既然propensity score 也是一个 balancing score, 那么如果拟合的比较正确, 就应该有:
X
⊥
Z
∣
e
(
X
)
.
X \perp Z | e(X).
X⊥Z∣e(X).
也就是说, 我们需要判断, 在每一个 e ( x ) e(x) e(x)下, X , Z X, Z X,Z是否独立.
对于matching, 若条件独立满足, 则有:
E
e
(
x
)
{
E
[
X
∣
Z
=
1
,
e
(
x
)
]
∣
Z
=
1
}
=
E
e
(
x
)
{
E
[
X
∣
Z
=
0
,
e
(
x
)
]
∣
Z
=
0
}
\mathbb{E}_{e(x)}\{\mathbb{E}[X|Z=1, e(x)] | Z=1 \} =\mathbb{E}_{e(x)}\{\mathbb{E}[X|Z=0, e(x)] | Z=0 \}
Ee(x){E[X∣Z=1,e(x)]∣Z=1}=Ee(x){E[X∣Z=0,e(x)]∣Z=0}
一个期望里用了条件独立, 第二个条件期望相等是因为matching 保证:
e
(
X
)
∣
Z
.
e(X) | Z.
e(X)∣Z.
故, 我们只需要比较treated group 和 control group的一阶矩的差别:
E
[
X
∣
Z
=
1
]
−
E
[
X
∣
Z
=
0
]
.
\mathbb{E}[X|Z=1] - \mathbb{E}[X|Z=0].
E[X∣Z=1]−E[X∣Z=0].
在实际中, 比较的是如下的标准化的:
d
=
∣
x
ˉ
t
r
e
a
t
e
d
−
x
ˉ
c
o
n
t
r
o
l
∣
(
s
t
r
e
a
t
e
d
2
+
s
c
o
n
t
r
o
l
2
)
/
2
.
d = \frac{|\bar{x}_{treated} - \bar{x}_{control}|}{\sqrt{(s_{treated}^2 + s_{control}^2) / 2}}.
d=(streated2+scontrol2)/2∣xˉtreated−xˉcontrol∣.
一般
d
<
0.1
d < 0.1
d<0.1就可以认为这个propensity score拟合的不错.
对于stratification, 我们只需对每一个strata判断上面的结果.
对于IP weighing, 说实话没读懂:
For IPTW this assessment involves comparing treated and untreated subjects in the sample weighted by the inverse probability of treatment.