0

我对因果推理很陌生,想尝试一些治疗效果估计的方法。为此,我在 Python 中创建了以下数据生成过程:

import numpy as np

n = 10000
X3 = np.random.randint(1,4, n)
X2 = np.random.randint(1,11, n)

X1 = 5 * X2 + 3 * X3 + np.random.randint(-1,3, n)
X4 = 10 * X2 + np.random.randint(-2,5, n)

#treatment probability
propensity = np.where(X1 > 30, 0.8, 0.2)
T = np.random.binomial(1, propensity)

#treatment effect
tau = np.where(X2 > 5, 10,0) * T * (-1)

#define outcome
Y = 50 * X2 - 5 * np.sqrt(X1) + T*tau + np.random.randint(10,21, n)

对于生成的数据,将创建以下图表:

有向无环图

我的问题是:由于X2(根据数据生成)不影响T的分配,但对治疗效果本身有影响,X2和T(X2->T)之间是否需要边缘?

非常感谢!

4

0 回答 0