关于「凑单升级:可被精确操纵的消费额如何让设计失效」,《会员门槛的断点回归》给出的定量结论是什么?
结论:第五章显示凑单比例升高时偏差可达 1.709,并检验不精确控制与甜甜圈剔除。
数据口径:落笔前本书核对原文并作蓝图修正:1960 年的论文研究的是奖学金荣誉证书而非会员体系,2008 年的指南是方法论文,二者都没有给出任何会员权益的效应量,书中的高估倍数全部来自固定种子的示意数据;命题也必须带边界陈述:只识别门槛处的局部效应,客人能精确凑单时设计失效,估计对带宽敏感,不宜用全局高阶多项式。 书中参数为示意;全部计算由书中程序生成。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 1.709
| P | RD est | bias | density z | jump in v | z(v) |
|---|---|---|---|---|---|
| 0.00 | 2.555 | -0.022 | -1.38 | 0.080 | 0.82 |
| 0.10 | 2.508 | -0.069 | 8.98 | 0.010 | 0.10 |
| 0.20 | 3.044 | 0.467 | 17.20 | 0.236 | 2.40 |
| 0.30 | 3.675 | 1.098 | 24.20 | 0.372 | 3.81 |
| 0.45 | 4.286 | 1.709 | 28.44 | 0.774 | 7.12 |
| true local effect 2.5769 |
查看完整验算程序
# Chapter 5. p51: top-up orders (customers padding a basket to reach
# the VIP line) and how they break the design. Top-up model of p41:
# within 4 units below c = 60 a customer tops up with probability
# min(1, 2 P / (1 + exp(-2 u))) and lands in [c, c + 1.5). Prior-year
# visits v = 6 + 2 u + noise are predetermined. For each P (seed
# 20261151 for every P, 20000 customers, h = 8): the RD estimate and
# its bias, the density test z, and the jump in v with its z. True
# local effect 2.5769. Illustrative parameters.
import math
import random
C, N, BIN, H = 60.0, 20000, 0.5, 8.0
LOCAL = 2.0 + 12.0 / 208.0 * (C - 50.0)
def draw(rng, n, topup=0.0, land=1.5, c=C):
rows = []
for _ in range(n):
u = rng.gauss(0.0, 1.0)
x = 50.0 + 12.0 * u + 8.0 * rng.gauss(0.0, 1.0)
v = 6.0 + 2.0 * u + rng.gauss(0.0, 1.5)
q = min(1.0, 2.0 * topup / (1.0 + math.exp(-2.0 * u)))
r = rng.random()
if c - 4.0 <= x < c and r < q:
x = c + rng.uniform(0.0, land)
d = 1 if x >= c else 0
g = 0.15 * (x - c) + 0.0003 * (x - c) ** 3
y = 20.0 + 6.0 * u + g + (2.0 + u) * d + rng.gauss(0.0, 3.0)
rows.append((x, y, u, v))
return rows
def wls(pts, c, h):
xs, ys, ws = [], [], []
for x, y in pts:
t = abs(x - c) / h
if t < 1.0:
xs.append(x - c)
ys.append(y)
ws.append(1.0 - t)
s0 = math.fsum(ws)
s1 = math.fsum(w * x for w, x in zip(ws, xs))
s2 = math.fsum(w * x * x for w, x in zip(ws, xs))
t0 = math.fsum(w * y for w, y in zip(ws, ys))
t1 = math.fsum(w * x * y for w, x, y in zip(ws, xs, ys))
det = s0 * s2 - s1 * s1
a = (s2 * t0 - s1 * t1) / det
b = (s0 * t1 - s1 * t0) / det
va = math.fsum((w * (s2 - s1 * x) / det * (y - a - b * x)) ** 2
for w, x, y in zip(ws, xs, ys))
return a, va
def jump(rows, col, c, h):
al, vl = wls([(r[0], r[col]) for r in rows if r[0] < c], c, h)
ar, vr = wls([(r[0], r[col]) for r in rows if r[0] >= c], c, h)
return ar - al, math.sqrt(vl + vr)
def density_z(xs, c, b, h):
n = len(xs)
k = int(math.ceil(3 * h / b))
cnt = {j: 0 for j in range(-k, k)}
for x in xs:
j = int(math.floor((x - c) / b))
if -k <= j < k:
cnt[j] = cnt[j] + 1
left = [(c + (j + 0.5) * b, cnt[j] / (n * b)) for j in range(-k, 0)]
right = [(c + (j + 0.5) * b, cnt[j] / (n * b)) for j in range(0, k)]
fm, fp = wls(left, c, h)[0], wls(right, c, h)[0]
se = math.sqrt(24.0 / 5.0 / (n * h) * (1.0 / fp + 1.0 / fm))
return (math.log(fp) - math.log(fm)) / se
if __name__ == "__main__":
print(" P RD est bias density z jump in v z(v)")
for p in (0.0, 0.1, 0.2, 0.3, 0.45):
rows = draw(random.Random(20261151), N, topup=p)
est, _ = jump(rows, 1, C, H)
jv, sv = jump(rows, 3, C, H)
dz = density_z([r[0] for r in rows], C, BIN, H)
print("{:4.2f} {:7.3f} {:6.3f} {:9.2f} {:10.3f} {:6.2f}".format(
p, est, est - LOCAL, dz, jv, jv / sv))
print("true local effect {:.4f}".format(LOCAL))唯一数据源与引用
范雅福(Fan, Y.). (2026). 《断点回归设计与会员等级门槛、消费满额升级线两侧的局部因果识别母典》第 5 章「凑单升级:可被精确操纵的消费额如何让设计失效」(版本 1.0.0). 5D Library. DOI 待发布
DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-303 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026303,
author = {Fan, Yafu},
title = {Regression-Discontinuity Designs at Membership-Tier Thresholds: Local Causal Identification on Either Side of a Spend-Based Upgrade Line},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}