关于「多店报表强制分层与调整:实证闭环、小工具与预注册方案」,《辛普森悖论与后门调整》给出的定量结论是什么?
结论:第八章给出多店报表强制分层与调整的闭环、蒸馏小工具「分层反转检测器」与预注册的随机留出检验:只有分店一种混杂时,调整估计被留出数据推翻的比例为 0.033,存在隐藏混杂时升到 0.637。书中含 23 段可运行的 Python 程序。
数据口径:书中门店、方案与成交数均为示意;全部计算由书中程序生成。 第一章在伯克利六个最大院系上复算反转:合并后男性录取率 0.445、女性 0.304,按申请者构成标准化后男性 0.387、女性 0.430;三店示意报表中甲在每店都高 0.050,合并后却落后 0.2493,并给出反转可能的充要条件。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 0.033, 0.637
true average effect +0.0412; 300 replications world I (branch only): mean |error| 0.0227 falsified 0.033 world II (hidden trait): mean |error| 0.0720 falsified 0.637
查看完整验算程序
# Chapter 8. p83: the falsification test, a randomised holdout.
# History: 1200 customers, plan chosen by branch (as in p12) and, in
# world II, also by a hidden trait U inside branches. Holdout: 300
# per plan per branch, randomised. The pre-registered rule: the
# standardised historical gap is falsified when it differs from the
# holdout gap by more than 1.96 combined standard errors.
# World I: branch is the only confounder; world II: U confounds too.
# Fixed seed; parameters illustrative.
import math
import random
PZ = [0.37, 0.31, 0.32]
PA = [0.12, 0.57, 0.83]
BASE = [0.70, 0.36, 0.10]
EFF = [0.06, 0.02, 0.04]
TRUE = math.fsum(PZ[s] * EFF[s] for s in range(3))
REPS = 300
def buy(rng, z, a, u):
return rng.random() < BASE[z] + (EFF[z] if a else 0) + 0.15 * u
def history(rng, hidden):
c = [[[0, 0], [0, 0]] for _ in range(3)]
for _ in range(1200):
r = rng.random()
z = 0 if r < PZ[0] else (1 if r < PZ[0] + PZ[1] else 2)
u = 1 if rng.random() < 0.5 else 0
p = PA[z] + (0.15 if u else -0.15) * hidden
a = 1 if rng.random() < p else 0
c[z][a][0] = c[z][a][0] + 1
c[z][a][1] = c[z][a][1] + (1 if buy(rng, z, a, u) else 0)
return c
def holdout(rng):
c = [[[300, 0], [300, 0]] for _ in range(3)]
for z in range(3):
for a in (0, 1):
for _ in range(300):
u = 1 if rng.random() < 0.5 else 0
c[z][a][1] = c[z][a][1] + (1 if buy(rng, z, a, u) else 0)
return c
def standardised(c):
n = math.fsum(c[z][a][0] for z in range(3) for a in (0, 1))
d, v = [], []
for z in range(3):
(n0, y0), (n1, y1) = c[z][0], c[z][1]
p0, p1 = y0 / n0, y1 / n1
w = (n0 + n1) / n
d.append(w * (p1 - p0))
v.append(w * w * (p1 * (1 - p1) / n1 + p0 * (1 - p0) / n0))
return math.fsum(d), math.fsum(v)
def run(rng, hidden):
err, fals = [], 0
for _ in range(REPS):
h, hv = standardised(history(rng, hidden))
o, ov = standardised(holdout(rng))
err.append(abs(h - TRUE))
if abs(h - o) > 1.96 * math.sqrt(hv + ov):
fals = fals + 1
return math.fsum(err) / REPS, fals / REPS
def main():
rng = random.Random(20261113)
print("true average effect {:+.4f}; {} replications".format(
TRUE, REPS))
for hidden, name in ((0, "world I (branch only)"),
(1, "world II (hidden trait)")):
e, f = run(rng, hidden)
print("{}: mean |error| {:.4f} falsified {:.3f}".format(
name, e, f))
if __name__ == "__main__":
main()唯一数据源与引用
范雅福(Fan, Y.). (2026). 《辛普森悖论与后门调整准则、多分店数据合并结论反转与因果图去混杂母典》第 8 章「多店报表强制分层与调整:实证闭环、小工具与预注册方案」(版本 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}
}