关于「带宽选择:偏差与方差的交换、蒙特卡洛最优与边界交叉验证」,《会员门槛的断点回归》给出的定量结论是什么?
结论:带宽为 2 时只用了 1801 人,估计 2.723,标准误 0.479,区间从 1.784 到 3.662,很宽。带宽从 4 到 16,估计在 2.676 到 2.954 之间摆动,区间全部包住真值,标准误从 0.345 降到 0.180。带宽放到 24,估计掉到 2.217,区间上限 2.519 已经够不到真值;放到 40,几乎用上了全部 19581 人,估计只剩 0.873,区间从 0.604 到 1.142,离真值很远。
数据口径:落笔前本书核对原文并作蓝图修正:1960 年的论文研究的是奖学金荣誉证书而非会员体系,2008 年的指南是方法论文,二者都没有给出任何会员权益的效应量,书中的高估倍数全部来自固定种子的示意数据;命题也必须带边界陈述:只识别门槛处的局部效应,客人能精确凑单时设计失效,估计对带宽敏感,不宜用全局高阶多项式。 书中参数为示意;全部计算由书中程序生成。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 0.180, 0.345, 0.479, 0.604, 0.873, 1.142
| h | estimate | se | n | 95% interval | |
| 2 | 2.723 | 0.479 | 1801 | [ 1.784, | 3.662] |
| 4 | 2.954 | 0.345 | 3533 | [ 2.279, | 3.630] |
| 6 | 2.830 | 0.281 | 5260 | [ 2.279, | 3.382] |
| 8 | 2.764 | 0.245 | 6888 | [ 2.284, | 3.244] |
| 12 | 2.805 | 0.203 | 9885 | [ 2.407, | 3.203] |
| 16 | 2.676 | 0.180 | 12549 | [ 2.324, | 3.028] |
| 24 | 2.217 | 0.154 | 16505 | [ 1.914, | 2.519] |
| 40 | 0.873 | 0.137 | 19581 | [ 0.604, | 1.142] |
| true local effect 2.5769 |
查看完整验算程序
# Chapter 3. p31: one data set, many bandwidths.
# Data as in p11 (seed 20261113, 20000 customers, line c = 60, true
# local effect 2.5769). Local linear RD with a triangular kernel for
# bandwidths from 2 to 40 units; for each we print the estimate, the
# sandwich standard error, the customers used and the 95% interval.
# Narrow windows are noisy; wide windows lean on the curvature of
# E[y | x] (the cubic term) far from the line and drift.
import math
import random
C = 60.0
LOCAL = 2.0 + 12.0 / 208.0 * (C - 50.0)
def draw(rng, n, sel=1.0, 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)
d = 1 if x >= c else 0
g = 0.15 * (x - c) + 0.0003 * (x - c) ** 3
y = 20.0 + 6.0 * sel * u + g + (2.0 + u) * d
rows.append((x, y + rng.gauss(0.0, 3.0), u))
return rows
def wls_line(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, len(xs)
if __name__ == "__main__":
rows = draw(random.Random(20261113), 20000)
left = [(r[0], r[1]) for r in rows if r[0] < C]
right = [(r[0], r[1]) for r in rows if r[0] >= C]
print(" h estimate se n 95% interval")
for h in (2.0, 4.0, 6.0, 8.0, 12.0, 16.0, 24.0, 40.0):
al, vl, nl = wls_line(left, C, h)
ar, vr, nr = wls_line(right, C, h)
tau, se = ar - al, math.sqrt(vl + vr)
print("{:4.0f} {:8.3f} {:6.3f} {:6d} [{:6.3f}, {:6.3f}]".format(
h, tau, se, nl + nr, tau - 1.96 * se, tau + 1.96 * se))
print("true local effect {:.4f}".format(LOCAL))唯一数据源与引用
范雅福(Fan, Y.). (2026). 《断点回归设计与会员等级门槛、消费满额升级线两侧的局部因果识别母典》第 3 章「带宽选择:偏差与方差的交换、蒙特卡洛最优与边界交叉验证」(版本 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}
}