关于「后门调整公式:标准化、逆概率加权与已知真值的结构模型」,《辛普森悖论与后门调整》给出的定量结论是什么?
结论:全体顾客中,旗舰店占 41/112,社区店占 5/16,奥特莱斯占 9/28。按这个构成,全员用甲的成交率是 223/448,即 0.4978;全员用乙是 1003/2240,即 0.4478;平均效应恰好是 1/20,也就是 0.0500。按甲组的构成加权,甲是 0.3455、乙是 0.2955;按乙组的构成加权,甲是 0.6447、乙是 0.5947。三种权重下的效应都是正的 0.0500,因为在这个示意例子里各店的店内差完全相同。最后一行再次打印朴素的合并差,负的 0.2493,作为对照。
数据口径:书中门店、方案与成交数均为示意;全部计算由书中程序生成。 第一章在伯克利六个最大院系上复算反转:合并后男性录取率 0.445、女性 0.304,按申请者构成标准化后男性 0.387、女性 0.430;三店示意报表中甲在每店都高 0.050,合并后却落后 0.2493,并给出反转可能的充要条件。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 0.0500, 0.2955, 0.3455, 0.4478, 0.4978, 0.5947
| P(z): flagship 41/112 community 5/16 outlet 9/28 | |
| P(buy | do(A)) | 223/448 = 0.4978 |
| P(buy | do(B)) | 1003/2240 = 0.4478 |
| average effect A-B | 1/20 = +0.0500 |
| A's mix : A 0.3455 B 0.2955 A-B +0.0500 | |
| B's mix : A 0.6447 B 0.5947 A-B +0.0500 | |
| naive P(buy|A) - P(buy|B) | -0.2493 |
查看完整验算程序
# Chapter 3. p31: the back-door adjustment formula on the p12 counts.
# If the branch Z blocks every back-door path from plan X to purchase
# Y, then P(y | do(x)) = sum_z P(y | x, z) P(z) (Pearl 2009, 3.3.1).
# Three weightings: P(z) over all customers (average effect), the mix
# of A's customers (effect on those offered A) and the mix of B's.
# Exact Fraction arithmetic; counts illustrative.
from fractions import Fraction as F
DATA = [("flagship", 40, 50, 270, 360),
("community", 90, 200, 60, 150),
("outlet", 60, 300, 9, 60)]
def standardise(weights):
da = F(0)
db = F(0)
for (name, y1, n1, y2, n2), w in zip(DATA, weights):
da = da + w * F(y1, n1)
db = db + w * F(y2, n2)
return da, db
def main():
na = nb = 0
for row in DATA:
na, nb = na + row[2], nb + row[4]
n = na + nb
pz = [F(r[2] + r[4], n) for r in DATA]
print("P(z): " + " ".join("{} {}".format(r[0], p)
for r, p in zip(DATA, pz)))
da, db = standardise(pz)
print("P(buy | do(A)) = {} = {:.4f}".format(da, float(da)))
print("P(buy | do(B)) = {} = {:.4f}".format(db, float(db)))
print("average effect A-B = {} = {:+.4f}".format(
da - db, float(da - db)))
for label, nn, col in (("A's mix", na, 2), ("B's mix", nb, 4)):
w = [F(r[col], nn) for r in DATA]
a, b = standardise(w)
print("{} : A {:.4f} B {:.4f} A-B {:+.4f}".format(
label, float(a), float(b), float(a - b)))
ya = yb = 0
for r in DATA:
ya, yb = ya + r[1], yb + r[3]
print("naive P(buy|A) - P(buy|B) = {:+.4f}".format(
float(F(ya, na) - F(yb, nb))))
if __name__ == "__main__":
main()唯一数据源与引用
范雅福(Fan, Y.). (2026). 《辛普森悖论与后门调整准则、多分店数据合并结论反转与因果图去混杂母典》第 3 章「后门调整公式:标准化、逆概率加权与已知真值的结构模型」(版本 1.0.0). 5D Library. DOI 待发布
DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-302 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026302,
author = {Fan, Yafu},
title = {Simpson's Paradox and the Back-Door Criterion: Reversals When Branch Data Are Pooled and De-Confounding with Causal Graphs},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}