5D Library › 双人相位耦合、双线性相容张量与时空网格博弈 · English
第八章 四步核查与一项预注册的合盘检验
相信一个合盘结论之前的四个问题
本章把全书变成四个问题,可以向任何合盘、择日或方位规则——包括作者自己的软件——提出。它们不是婚恋或择日建议。
一、分数是哪个方向的? 如果评分矩阵不对称,「A 适合 B」与「B 适合 A」是两个不同的数,「最佳对象」也有两个答案(第一章)。要问清楚系统报告的是哪一个,以及它所依据的数据是否对两个人分别测量过——只有共有结局的数据看不见单向性。
二、「高危窗口」是假设还是发现? 只有噪声的模型不产生窗口,窗口来自假设的固定日期冲击(第四章)。要问窗口规则是否在看到结果之前写定,以及有多少带确切日期的分离支持它。
三、择时的价值从哪里来? 在九宫模型中,方向自由时择时不增加任何价值(第六章)。要问建议是否同时限定了方向与时间,以及输入的门值是测量还是约定。
四、口径是事先定的吗? 同一份数据可以用许多种口径评分。下面的程序说明,在没有任何效应的数据上,事后挑选口径能制造出什么。
推导
# Chapter 8. Twenty ways to score a match, and no real effect.
# 200 couples are followed for five years; each stays together with
# probability 0.75, independent of everything else (no effect exists).
# An analyst may score compatibility by 20 different conventions (house
# weights, which stars or trigrams count, which tensor entries...). The
# conventions are correlated with one another (each is 0.6 x a common part
# + 0.8 x its own part). For each, a two-sided test of the correlation
# between score and outcome at alpha = 0.05 (normal approximation,
# |r| sqrt(n) > 1.96). 5,000 simulated studies: how often at least one
# convention is "significant", and how often the best one keeps its sign
# and significance in a fresh sample of 200.
import math
import random
def corr(x, y):
n = len(x)
mx, my = sum(x) / n, sum(y) / n
sxy = sum((a - mx) * (b - my) for a, b in zip(x, y))
sxx = sum((a - mx) ** 2 for a in x)
syy = sum((b - my) ** 2 for b in y)
return sxy / math.sqrt(sxx * syy)
def study(rng, n=200, k=20):
common = [rng.gauss(0, 1) for _ in range(n)]
scores = [[0.6 * c + 0.8 * rng.gauss(0, 1) for c in common]
for _ in range(k)]
out = [1.0 if rng.random() < 0.75 else 0.0 for _ in range(n)]
rs = [corr(s, out) for s in scores]
return rs
if __name__ == "__main__":
rng = random.Random(62015)
n, studies, any_sig, rep = 200, 5000, 0, 0
for _ in range(studies):
rs = study(rng)
best = max(range(len(rs)), key=lambda i: abs(rs[i]))
if abs(rs[best]) * math.sqrt(n) > 1.96:
any_sig += 1
fresh = study(rng)[best]
if fresh * rs[best] > 0 and abs(fresh) * math.sqrt(n) > 1.96:
rep += 1
print(" one convention fixed in advance: false-positive rate 0.05")
print(" best of 20 chosen afterwards: false-positive rate"
" {:.3f}".format(any_sig / studies))
print(" of those 'findings', replicated in a fresh sample:"
" {:.3f}".format(rep / max(any_sig, 1)))
print("\nReading: with no effect at all, picking the best of twenty")
print("scoring conventions after seeing the data yields a 'significant'")
print("compatibility effect in about half of all studies, and almost")
print("none survives a fresh sample. Only a convention fixed before the")
print("data are seen can be tested.")
# one convention fixed in advance: false-positive rate 0.05
# best of 20 chosen afterwards: false-positive rate 0.517
# of those 'findings', replicated in a fresh sample: 0.024
#
# Reading: with no effect at all, picking the best of twenty
# scoring conventions after seeing the data yields a 'significant'
# compatibility effect in about half of all studies, and almost
# none survives a fresh sample. Only a convention fixed before the
# data are seen can be tested.二十种彼此相关的评分口径,一个真实效应都没有;事后挑出最好的一种,有 0.517 的研究会得到「显著」的合盘效应。这些「发现」在新样本中能以同样方向、同样显著性重复的只有 0.024——与纯粹的巧合无异。第 33 本详细讨论过这种「分岔路径」问题 (Simmons et al. 2011; Gelman and Loken 2014);第 37 本引用过卡尔森的双盲占星检验,占星师的命中率与随机的三分之一没有差别 (Carlson 1985)。
一项预注册的检验
本书指出的问题——合盘评分是否与关系的结局有关——可以用一项事先写定的观察研究检验。下面的方案在任何数据出现之前写成。
假说 · 尚未验证
研究方案。 一种评分口径(编码 、矩阵 的全部元素与计算代码)在招募前公开登记,此后不再改动。招募新近开始交往的伴侣,在基线时记录双方的出生资料并由软件自动计算评分,研究人员与伴侣都不知道评分。按评分中位数把伴侣分为高、低两半。主要结局:五年内分离的时间,用考克斯模型比较两半,双侧 。次要结局:每位伴侣分别报告的满意度,按行动者—伴侣相互依赖模型分析,用以估计第一章的反对称部分 。判定:风险比的 95% 置信区间不含 1、方向与登记一致,才算支持;同时报告效应大小。由与作者无经济关系、不知道评分含义的独立分析者按登记的代码执行,结果不论正负都发表。
推导
# Chapter 8. Sizing a pre-registered test of a compatibility score.
# Design: one scoring convention, fixed and published before any data;
# couples split at the median score into a high and a low half; primary
# outcome the time to separation over five years, compared with a Cox
# model. Schoenfeld's formula gives the number of separations needed:
# d = (z_(1 - alpha/2) + z_power)^2 / (p (1 - p) ln(HR)^2), p = 0.5.
# Couples needed = d / (share separating within five years). Secondary
# outcome, from p02: EACH partner's own satisfaction, measured separately,
# so that a one-sided (antisymmetric) part can be estimated at all.
# The program also checks the formula by simulation for HR = 1.5:
# exponential times, 25 % five-year separation in the low half, 2,000
# simulated trials, a log-rank test at 0.05.
import math
import random
from statistics import NormalDist
Z = NormalDist()
def events_needed(hr, alpha=0.05, power=0.8):
z = Z.inv_cdf(1 - alpha / 2) + Z.inv_cdf(power)
return math.ceil(z * z / (0.25 * math.log(hr) ** 2))
def logrank(times, groups, horizon=5.0):
data = sorted(zip(times, groups))
at = [groups.count(0), groups.count(1)]
o1 = e1 = v = 0.0
for t, g in data:
if t > horizon:
break
n = at[0] + at[1]
e = at[1] / n
o1 += g
e1 += e
v += e * (1 - e)
at[g] -= 1
return (o1 - e1) / math.sqrt(v)
if __name__ == "__main__":
print(" hazard ratio separations needed couples (25 % separate)")
for hr in (1.2, 1.3, 1.5, 2.0):
d = events_needed(hr)
print(" {:3.1f} {:5d} {:6,d}".format(
hr, d, math.ceil(d / 0.25)))
rng = random.Random(62016)
hr, n_per = 1.5, math.ceil(events_needed(1.5) / 0.25 / 2)
lam0 = -math.log(0.75) / 5.0
hits = 0
for _ in range(2000):
times, groups = [], []
for g in (0, 1):
lam = lam0 * (hr if g else 1.0)
for _ in range(n_per):
times.append(rng.expovariate(lam))
groups.append(g)
if abs(logrank(times, groups)) > 1.96:
hits += 1
print("\n simulated power at HR 1.5 with {} couples per half:"
" {:.3f}".format(n_per, hits / 2000))
print("\nReading: even a large effect (hazard ratio 1.5) needs about")
print("190 separations and some 760 couples; a modest one needs several")
print("thousand. The simulation gives a little more than the planned")
print("80 %, because the high-risk half separates more often than 25 %")
print("and so supplies extra events.")
# hazard ratio separations needed couples (25 % separate)
# 1.2 945 3,780
# 1.3 457 1,828
# 1.5 191 764
# 2.0 66 264
#
# simulated power at HR 1.5 with 382 couples per half: 0.853
#
# Reading: even a large effect (hazard ratio 1.5) needs about
# 190 separations and some 760 couples; a modest one needs several
# thousand. The simulation gives a little more than the planned
# 80 %, because the high-risk half separates more often than 25 %
# and so supplies extra events.舍恩菲尔德公式给出所需的分离次数 (Schoenfeld 1983):风险比为 2.0 时需要 66 次,1.5 时 191 次,1.3 时 457 次,1.2 时 945 次。如果五年内有四分之一的伴侣分开,对应的伴侣数分别为 264、764、1,828 与 3,780。模拟在风险比 1.5、每半 382 对时得到 0.853 的把握度,略高于计划的 80%,因为高风险的一半分离得更多,提供了额外的事件。
注
结果意味着什么、不意味着什么。 阴性结果说明的是这一种登记的口径在这一人群中没有可检测的效应,不说明其他口径;阳性结果说明的是关联,不说明机制,也不说明评分可以用来为任何具体的两个人作决定。无论哪种结果,都不能事后换一种口径重新分析而仍称为本检验的结果。
小结
四个问题概括了全书:分数是哪个方向的、依据的数据能否看见单向性;高危窗口是假设还是在事先写定的规则下被数据发现;择时的价值是否只来自方向被固定;评分口径是否在看数据之前确定。事后在二十种口径中挑选,可以在 0.517 的无效应研究中制造「显著」效应。一项预注册的检验——一种口径、盲法计算、五年分离时间为主要结局、每人分别测量满意度——在效应较大时需要约 190 次分离,在效应中等时需要几千对伴侣。
参考文献
Fan, Y. (2026). Dyadic Phase Coupling, Bilinear Compatibility Tensors and Spatiotemporal Grid Games: Asymmetric Kuramoto Locking, Stopping-Time Separation Hazards and Magic-Square Permutation Operators [双人相位耦合、双线性相容张量与时空网格博弈] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090172 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).