5D Library › 自主神经交感迷走平衡、六经辨证状态空间与多模态标志物反演 · English

第八章 实践:准确性研究、重测信度与预先登记

准确性研究需要多大

要说一个筛查的灵敏度「约 0.80」,先要回答:误差范围多大?只有真正有问题的人才能用来估计灵敏度,因此在连续入组的研究中,所需的总人数要除以患病率 (Buderer 1996)。

推导

# Chapter 8. p14: How large must a diagnostic accuracy study be? To pin
# sensitivity near 0.80 within +/- d (95%), n_pos = 1.96^2 p (1 - p) / d^2
# people who truly have the condition are needed; likewise n_neg for
# specificity near 0.85. Total enrolment = n_pos / prevalence when the
# study samples consecutive people.
from math import ceil

def n_for(p, d):
    return ceil(1.96 ** 2 * p * (1 - p) / d ** 2)

if __name__ == "__main__":
    print("   half-width  positives  negatives  enrol at 10%  enrol at 20%")
    for d in (0.10, 0.05, 0.03):
        npos, nneg = n_for(0.80, d), n_for(0.85, d)
        e10 = max(ceil(npos / 0.10), ceil(nneg / 0.90))
        e20 = max(ceil(npos / 0.20), ceil(nneg / 0.80))
        print("   {:10.2f}  {:9,d}  {:9,d}  {:12,d}  {:12,d}".format(
            d, npos, nneg, e10, e20))
#    half-width  positives  negatives  enrol at 10%  enrol at 20%
#          0.10         62         49           620           310
#          0.05        246        196         2,460         1,230
#          0.03        683        545         6,830         3,415

要把灵敏度钉在正负 0.05 之内,需要 246 名真正有问题的人;患病率 10% 时,总共要入组 2,460 人。要缩到正负 0.03,总人数升到 6,830。准确性研究应按 STARD 清单报告入组方式、参照标准与盲法 (Bossuyt et al. 2015)。

三分钟读数能重复吗

一个指标如果同一个人隔天再测就差很多,它对个人就几乎没有意义。组内相关系数(ICC)衡量人与人之间的差异在总变异中所占的比例 (Shrout and Fleiss 1979)。

推导

# Chapter 8. p15: Do three-minute readings repeat? Each person has a
# stable true value; each recording adds its own error. Illustrative
# spreads on the log scale (between people / between recordings):
# heart rate 0.12 / 0.05, RMSSD 0.45 / 0.30, LF/HF 0.50 / 0.60. The
# intraclass correlation ICC = between^2 / (between^2 + within^2) is
# estimated from 60 people x 2 recordings (one-way ANOVA), 400 repeats,
# seed 86; averaging k recordings raises it to k ICC / (1 + (k-1) ICC).
import random

MEASURES = (("heart rate", 0.12, 0.05), ("RMSSD", 0.45, 0.30),
            ("LF/HF", 0.50, 0.60))

def icc_hat(rng, b, w, n=60):
    rows = []
    for _ in range(n):
        t = rng.gauss(0, b)
        rows.append((t + rng.gauss(0, w), t + rng.gauss(0, w)))
    grand = sum(a + c for a, c in rows) / (2 * n)
    msb = 2 * sum(((a + c) / 2 - grand) ** 2 for a, c in rows) / (n - 1)
    msw = sum((a - c) ** 2 / 2 for a, c in rows) / n
    return (msb - msw) / (msb + msw)

if __name__ == "__main__":
    rng = random.Random(86)
    print("   measure      true ICC  estimated  90% range      ICC of 3")
    for name, b, w in MEASURES:
        true = b * b / (b * b + w * w)
        est = sorted(icc_hat(rng, b, w) for _ in range(400))
        k3 = 3 * true / (1 + 2 * true)
        print("   {:<11}  {:8.3f}  {:9.3f}  {:.3f}-{:.3f}  {:8.3f}".format(
            name, true, sum(est) / 400, est[20], est[379], k3))
#    measure      true ICC  estimated  90% range      ICC of 3
#    heart rate      0.852      0.850  0.783-0.901     0.945
#    RMSSD           0.692      0.692  0.579-0.797     0.871
#    LF/HF           0.410      0.405  0.213-0.578     0.676

心率的 ICC 约 0.852,相当可靠;RMSSD 是 0.692;LF/HF 只有 0.410,90% 区间从 0.213 到 0.578。平均三次记录可以把 LF/HF 的 ICC 提高到 0.676,但仍不如单次的心率。第一章已经说明,LF/HF 本身强烈依赖呼吸;这里再加上一条:它的重测信度也最差。

预先登记的配对比较

最后,设计一项检验第五章假说的研究:每一位参加者同时接受单用问卷与三模态筛查,并由不知道筛查结果的临床评估作为参照。两种方法的准确性用 McNemar 检验比较,它只取决于两种方法判断不一致的人 (McNemar 1947)。

推导

# Chapter 8. p16: A pre-registered paired comparison. Every participant
# gets both the questionnaire alone and the three-modality screen of p09;
# the reference is a blinded clinical assessment. Accuracy is compared
# with McNemar's test, which depends only on the discordant pairs:
# p10 = questionnaire wrong and screen right, p01 = the reverse. Their
# shares are taken from p09's simulated people; then
# n = (1.96 sqrt(pd) + 0.84 sqrt(pd - dl^2))^2 / dl^2, pd = p10 + p01,
# dl = p10 - p01 (two-sided alpha 0.05, power 0.80).
import importlib.util
import random
from math import ceil, sqrt

def load(name):
    spec = importlib.util.spec_from_file_location(name, name + ".py")
    m = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(m)
    return m

p09 = load("p09_three_modes")

def top(x, use):
    p = p09.post(x, use)
    return max(p, key=p.get)

if __name__ == "__main__":
    rng = random.Random(86)
    a = b = n = 0
    for _ in range(10000):
        for c in "ABC":
            x = p09.draw(rng, c)
            q_ok, s_ok = top(x, (0,)) == c, top(x, (0, 1, 2)) == c
            a += (not q_ok) and s_ok
            b += q_ok and not s_ok
            n += 1
    p10, p01 = a / n, b / n
    pd, dl = p10 + p01, p10 - p01
    need = ceil((1.96 * sqrt(pd) + 0.84 * sqrt(pd - dl * dl)) ** 2
                / dl ** 2)
    print("   discordant: questionnaire wrong, screen right {:.3f}".format(
        p10))
    print("               questionnaire right, screen wrong {:.3f}".format(
        p01))
    print("   participants needed: {}".format(need))
#    discordant: questionnaire wrong, screen right 0.319
#                questionnaire right, screen wrong 0.084
#    participants needed: 55

在第五章的示意参数下,问卷错而筛查对的比例是 0.319,反过来是 0.084,只需要 55 名参加者就有八成的把握看出差别。真实的差别很可能小得多,因此登记方案时应以更保守的不一致比例计算样本量。

注

预先登记的要点: 在收集数据之前公开登记主要终点(三模态与单用问卷的准确性之差)、参照标准、样本量计算、排除标准与分析方法;无论结果是正是负都发表;第四章与第七章的两个假说各自另行登记。

假说 · 尚未验证

作者的诠释(尚未验证): 一项预先登记、以盲法临床评估为参照的配对研究会显示,三模态筛查的准确性高于单用问卷。什么会证明它错: 该研究的 McNemar 检验不显著,或不一致对中问卷对而筛查错的比例不低于相反方向。

小结

一项可信的准确性研究需要数百到数千名参加者;三分钟读数中心率最稳定,LF/HF 最不稳定;用预先登记的配对设计检验多模态筛查,样本量取决于两种方法不一致的程度。本书的所有数字都是示意设定下的模拟,在这些研究完成之前,书中的映射都只是假说。

参考文献

Bossuyt, Patrick M., Johannes B. Reitsma, David E. Bruns, et al. 2015. “STARD 2015: An Updated List of Essential Items for Reporting Diagnostic Accuracy Studies.” BMJ 351: h5527.
Buderer, Nancy M. Fisher. 1996. “Statistical Methodology: I. Incorporating the Prevalence of Disease into the Sample Size Calculation for Sensitivity and Specificity.” Academic Emergency Medicine 3 (9): 895 to 900.
McNemar, Quinn. 1947. “Note on the Sampling Error of the Difference between Correlated Proportions or Percentages.” Psychometrika 12 (2): 153 to 157.
Shrout, Patrick E., and Joseph L. Fleiss. 1979. “Intraclass Correlations: Uses in Assessing Rater Reliability.” Psychological Bulletin 86 (2): 420 to 428.

Fan, Y. (2026). Autonomic Sympathovagal Balance, Six-Meridian State-Space Models and Multimodal Biomarker Inversion: Heart-Rate Variability Spectral Decomposition, Thermoregulatory Phase Drift and Bayesian Syndrome Classification [自主神经交感迷走平衡、六经辨证状态空间与多模态标志物反演] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090227 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).