%%{init: {"theme":"base","themeVariables":{"primaryColor":"#EAF2FB","primaryBorderColor":"#2780E3","primaryTextColor":"#212529","lineColor":"#6C757D","secondaryColor":"#EAF7E6","tertiaryColor":"#FFF4E8","fontSize":"13px"},"flowchart":{"nodeSpacing":18,"rankSpacing":24,"padding":6}}}%%
flowchart LR
A["明确主要终点<br/>方向与允许误差"] --> B{"统计问题"}
B -->|连续差值一致性限| C["sample_size_bland_altman()"]
B -->|单比例区间精度| D["sample_size_proportion_ci()"]
B -->|单臂比例目标值| E["sample_size_proportion()"]
C --> F["关键参数敏感性分析"]
D --> F
E --> F
F --> G["加入失访、无效样本<br/>和分层覆盖加量"]
classDef input fill:#EAF2FB,stroke:#2780E3,color:#212529
classDef process fill:#EAF7E6,stroke:#3FB618,color:#212529
classDef decision fill:#FFF4E8,stroke:#FF7518,color:#212529
classDef output fill:#F4EEFB,stroke:#9954BB,color:#212529
class A input
class B decision
class C,D,E,F process
class G output
19 临床样本量计算
样本量不是脱离研究终点的固定常数,而是由效应大小、变异程度、置信水平、检验效能和研究设计共同决定的规划结果。本文只覆盖 ivdtools 已提供的三类计算:Bland–Altman 一致性限的精度/效能、单比例置信区间半宽,以及单臂比例目标值检验。它们不能直接替代 ROC、精密度方差分量、参考区间或多中心聚类设计的专用样本量论证。
使用前先写清主要终点、分析单位(受试者、样本还是配对结果)、预期比例或差异、允许误差、单双侧方向和无效样本加量。函数返回的是在这些输入假设成立时的理论样本量;若输入的 SD、预期比例或相关性不确定,应对关键参数做敏感性分析并取保守方案。
三个函数只覆盖三种特定统计问题,返回值不含失访、无效样本、分层最低例数、设计效应或多重终点加量。Bland–Altman 输入中的 delta 是临床可接受界限,不是观察到的 LoA;比例区间方法和单臂检验方向必须预先确定。正式方案应保存全部假设、来源和敏感性分析,而不只报告最终整数。
分析流程:先定义目标,再计算样本量
代码
library(ivdtools)19.1 主要函数
样本量计算在研究设计与性能评价方案阶段确定所需样本数或可获得的检验效能。ivdtools 提供三个独立函数,分别对应三类常见问题:
| 函数 | 主要用途 | 求解方向 |
|---|---|---|
sample_size_bland_altman() |
BA 一致性评价 | 由目标 power 求 n |
sample_size_proportion_ci() |
单比例置信区间 | 由目标 half_width 求 n |
sample_size_proportion() |
单臂目标值检验 | 由 alpha 和 power 求 n |
三个函数都由参数驱动、不需要原始数据文件,并且只计算样本量。它们返回结构化结果,样本量由 result$n 获取,print() 同时显示目标值和实际达到的统计量。示例中的参数(效能、置信水平、允许半宽等)均为教学设定,正式研究必须使用方案规定的参数。样本量向上取整、失访/无效样本加量和分层最低例数应在函数结果之外单独处理。
19.1.1 三类计算的数学目标
代码
sample_size_bland_altman(
power = 0.80, mu, sd, delta,
conf.level = 0.95, agree.level = 0.95,
method = "lu",
n.min = 3, n.max = 1e5
)
sample_size_proportion_ci(
p, half_width, conf.level = 0.95,
interval = c("two.sided", "lower", "upper"),
method = "wilson", n.max = 1e6
)
sample_size_proportion(
p0, p1, alpha = 0.05, power = 0.80,
alternative = c("greater", "less", "two.sided"),
test = "exact", power_method = "binomial", n.max = 1e6
)Bland–Altman 函数假定差值近似正态,目标 LoA 为
\[ \mu\pm z_{(1+\gamma)/2}\sigma, \]
其中 \(\gamma=\) agree.level。函数按 Lu 等方法用非中心 t 分布计算“两侧 LoA 置信界均落入临床界限 \(\pm\delta\)”的效能,再搜索达到目标效能的最小整数。必须满足 \(\delta>|\mu|+z_{(1+\gamma)/2}\sigma\);否则总体 LoA 本身已经超出临床界限,函数直接报错。
单比例区间的目标是:双侧区间控制总宽度的一半,单侧区间控制预期比例到相应置信限的距离,
\[ \frac{U-L}{2}\le d\quad\text{(双侧)},\qquad \widehat p-L\le d\ \text{或}\ U-\widehat p\le d\quad\text{(单侧)}. \]
规划宽度直接在预期比例 \(p\) 处计算,避免先把 \(np\) 四舍五入后在小样本、高比例情形产生 \(\widehat p=1\) 和零标准误。这个双侧定义与 SAS 的 HALFWIDTH 及 PASS 总宽度的一半一致;对于 Wilson、Clopper–Pearson 等非对称区间,不再把较长一侧误当成总宽度的一半。函数搜索满足半宽约束的第一个整数,并在最终 \(n\) 下枚举整数成功数,报告 actual_coverage 和 actual_alpha。
单臂函数检验 \(H_0:p=p_0\) 与由 alternative 指定的备择。test 决定拒绝域,power_method 决定样本量采用连续正态近似还是离散二项枚举。无论采用哪种规划方法,函数都会对最终整数样本量按二项分布核算 actual_alpha 和 achieved_power。二项设计还同时要求实际 α 不超过目标 α,避免近似检验因 α 膨胀而得到虚假的小样本量。
三个函数均返回结构化样本量结果;result$n 为向上取整后的样本量,并保存目标参数、实际覆盖度、实际 α、达到的效能及搜索边界。
19.2 分析案例
19.2.1 示例一:Bland–Altman 一致性评价的样本量
代码
n_ba <- sample_size_bland_altman(
power = 0.80,
mu = 0.2,
sd = 1,
delta = 2.5
)
print(n_ba)Sample size for Bland-Altman agreement assessment
Method : Lu et al. (2016), noncentral-t approximation
Mean difference : 0.2000
SD of differences : 1.0000
Clinical limit : 2.5000
Confidence level : 0.9500
Agreement level : 0.9500
Sample size (n) : 201
Target power : 0.800000
Achieved power : 0.800300
在平均差异 mu = 0.2、差异 SD sd = 1、临床一致性限 delta = 2.5 的设定下,达到 80% 效能约需 201 对样本。
mu 为平均差异,sd 为差异标准差(>0),delta 为临床可接受的一致性限(>0)。conf.level 是一致性限置信区间的置信水平,agree.level 是 LoA 的覆盖度,两者是不同层次——前者影响估计的可靠性,后者决定 LoA 本身的宽度。
19.2.2 示例二:单比例置信区间的样本量
代码
n_pci <- sample_size_proportion_ci(p = 0.3, half_width = 0.05)
print(n_pci)Sample size for a single-proportion confidence interval
Method : wilson
Interval : two.sided
Anticipated proportion: 0.3000
Confidence level : 0.9500
Sample size (n) : 320
Target half-width : 0.050000
Achieved half-width : 0.049967
Target total width : 0.100000
Achieved total width : 0.099934
Planning interval : [0.252406, 0.352339]
Actual coverage : 0.956096
Actual alpha : 0.043904
对预期比例 p = 0.3,要使 95% Wilson 置信区间的总宽度不超过 0.10(半宽不超过 0.05),约需 320 例。结果同时给出规划区间、实际覆盖率和实际 α。
p 为预期比例(必须给定,0≤p≤1;边界值主要用于单侧精确区间),half_width 对双侧区间表示总宽度的一半,对单侧区间表示 p 到相应置信限的距离。method 可选 7 种置信区间方法(默认 "wilson",另有 "wald"、"wald-cc"、"agresti-coull"、"jeffreys"、"wilson-cc"、"clopper-pearson"),方法选择影响所需样本量,应在方案中说明。
19.2.3 示例三:单臂目标值检验的样本量
代码
n_sp <- sample_size_proportion(
p0 = 0.2,
p1 = 0.35,
alpha = 0.05,
power = 0.8,
alternative = "greater",
test = "exact",
power_method = "binomial"
)
print(n_sp)Sample size for a single-proportion target-value test
Test : Exact binomial test
Power calculation : Binomial enumeration
H0: p <= 0.2000
H1: p > 0.2000
Expected p : 0.3500
Sample size (n) : 56
Target alpha : 0.050000
Actual alpha : 0.043209
Alpha criterion : met
Target power : 0.800000
Achieved power : 0.806416 (binomial evaluation)
Critical successes : >= 17
在 p0 = 0.2(目标/零假设比例)与 p1 = 0.35(预期比例)、单侧 α = 0.05、效能 0.80 的设定下,精确二项设计需要 56 例;实际 α 和实际效能分别由结果中的 actual_alpha 和 achieved_power 给出。
alternative 可取 "greater"(此时要求 p1 > p0)、"less" 或 "two.sided"。test 选择精确、Score、Wald 或其他区间反演拒绝域;power_method 独立选择 "binomial" 或 "normal"。正态效能可用于 Exact、Score、Wald 及后二者的连续性校正版本;对无限总体,Exact 与 Score 的正态近似规划公式相同,但最终离散拒绝域仍由 test 决定。
19.2.4 Bland–Altman:PASS Example 1 和 Example 2
PASS Example 1 固定 mu = 0.5、delta = 7、conf.level = agree.level = 0.95,交叉考察两档效能和三个差值 SD。下面不删除不一致行,而是同时给出样本量差和效能差。
代码
ba_manual <- data.frame(
target_power = c(0.8, 0.8, 0.8, 0.9, 0.9, 0.9),
sd = c(2.5, 2.6, 2.7, 2.5, 2.6, 2.7),
pass_n = c(60L, 82L, 118L, 78L, 108L, 156L),
pass_power = c(0.8059, 0.8019, 0.8024, 0.9014, 0.9003, 0.9002)
)
ba_results <- lapply(
seq_len(nrow(ba_manual)),
function(i) sample_size_bland_altman(
power = ba_manual$target_power[i],
mu = 0.5, sd = ba_manual$sd[i], delta = 7,
conf.level = 0.95, agree.level = 0.95
)
)| 标准位置 | 统计量 | 标准结果 | ivdtools结果 |
|---|---|---|---|
| PASS BA Example 1 / power=0.8 / SD=2.5 | sample size | 60.0000 | 59.000000 |
| PASS BA Example 1 / power=0.8 / SD=2.5 | achieved power | 0.8059 | 0.803126 |
| PASS BA Example 1 / power=0.8 / SD=2.6 | sample size | 82.0000 | 82.000000 |
| PASS BA Example 1 / power=0.8 / SD=2.6 | achieved power | 0.8019 | 0.803997 |
| PASS BA Example 1 / power=0.8 / SD=2.7 | sample size | 118.0000 | 118.000000 |
| PASS BA Example 1 / power=0.8 / SD=2.7 | achieved power | 0.8024 | 0.803101 |
| PASS BA Example 1 / power=0.9 / SD=2.5 | sample size | 78.0000 | 78.000000 |
| PASS BA Example 1 / power=0.9 / SD=2.5 | achieved power | 0.9014 | 0.901856 |
| PASS BA Example 1 / power=0.9 / SD=2.6 | sample size | 108.0000 | 108.000000 |
| PASS BA Example 1 / power=0.9 / SD=2.6 | achieved power | 0.9003 | 0.900492 |
| PASS BA Example 1 / power=0.9 / SD=2.7 | sample size | 156.0000 | 156.000000 |
| PASS BA Example 1 / power=0.9 / SD=2.7 | achieved power | 0.9002 | 0.900235 |
power = 0.8, SD = 2.5 时 PASS 报 60,包按手册列出的 Lu 非中心 t 公式逐个搜索得到 59,相差 1 例。PASS 手册未给出 n = 59 的内部值,因此这里不把差异归因于舍入,也不为追求表面一致而把包结果强制加 1。效能列也如实保留:小样本几行存在约 0.00004–0.0028 的差异,随着 n 增大而缩小。
PASS Example 2 另以 power = 0.8, mu = 0.2, sd = 1, delta = 2.5 验证 Lu 等论文的结果。论文表格给出 203,而 PASS 与包都按“第一个达到目标的整数”得到 201;这里的差异发生在论文近似结果与整数搜索结果之间。
19.2.5 单比例置信区间:PASS Example 1–4
PASS 双侧案例输入的是总宽度,包输入 half_width,因此复算时使用 half_width = target_width / 2。Example 1 对 Clopper–Pearson 区间给出 3 个宽度与 5 个预期比例,共 15 个组合。
代码
ci_manual <- expand.grid(
p = seq(0.1, 0.5, by = 0.1),
target_width = c(0.04, 0.06, 0.10)
)
ci_manual$pass_n <- c(
914L, 1585L, 2065L, 2353L, 2449L,
417L, 715L, 928L, 1056L, 1098L,
158L, 264L, 341L, 387L, 402L
)
ci_results <- lapply(
seq_len(nrow(ci_manual)),
function(i) sample_size_proportion_ci(
p = ci_manual$p[i],
half_width = ci_manual$target_width[i] / 2,
conf.level = 0.95,
interval = "two.sided",
method = "clopper-pearson"
)
)| 标准位置 | 统计量 | 标准结果 | ivdtools结果 |
|---|---|---|---|
| PASS CI Example 1 / p=0.1 / width=0.04 | sample size | 914 | 914 |
| PASS CI Example 1 / p=0.2 / width=0.04 | sample size | 1585 | 1585 |
| PASS CI Example 1 / p=0.3 / width=0.04 | sample size | 2065 | 2065 |
| PASS CI Example 1 / p=0.4 / width=0.04 | sample size | 2353 | 2353 |
| PASS CI Example 1 / p=0.5 / width=0.04 | sample size | 2449 | 2449 |
| PASS CI Example 1 / p=0.1 / width=0.06 | sample size | 417 | 417 |
| PASS CI Example 1 / p=0.2 / width=0.06 | sample size | 715 | 715 |
| PASS CI Example 1 / p=0.3 / width=0.06 | sample size | 928 | 928 |
| PASS CI Example 1 / p=0.4 / width=0.06 | sample size | 1056 | 1056 |
| PASS CI Example 1 / p=0.5 / width=0.06 | sample size | 1098 | 1098 |
| PASS CI Example 1 / p=0.1 / width=0.10 | sample size | 158 | 158 |
| PASS CI Example 1 / p=0.2 / width=0.10 | sample size | 264 | 264 |
| PASS CI Example 1 / p=0.3 / width=0.10 | sample size | 341 | 341 |
| PASS CI Example 1 / p=0.4 / width=0.10 | sample size | 387 | 387 |
| PASS CI Example 1 / p=0.5 / width=0.10 | sample size | 402 | 402 |
包额外枚举最终 n 下的覆盖概率;这不是 PASS 用于选择 n 的宽度条件,所以作为诊断表单独报告。
代码
ci_special <- data.frame(
case = c("PASS Example 2", "PASS Example 3", "PASS Example 4"),
design = c(
"单侧下限,Clopper-Pearson",
"双侧,Wilson 连续性校正",
"单侧上限,Clopper-Pearson,p=0"
),
pass_n = c(25L, 29L, 299L)
)
ci_special_results <- list(
sample_size_proportion_ci(
p = 0.92, half_width = 0.15104,
interval = "lower", method = "clopper-pearson"
),
sample_size_proportion_ci(
p = 0.034483, half_width = 0.1945 / 2,
interval = "two.sided", method = "wilson-cc"
),
sample_size_proportion_ci(
p = 0, half_width = 0.01,
interval = "upper", method = "clopper-pearson"
)
)| 标准位置 | 统计量 | 标准结果 | ivdtools结果 |
|---|---|---|---|
| PASS Example 2 | sample size | 25 | 25 |
| PASS Example 3 | sample size | 29 | 29 |
| PASS Example 4 | sample size | 299 | 299 |
Example 3 说明 Wilson 连续性校正必须使用校正后的 Score 反演公式;若只在普通 Wilson 两端机械加减 \(1/(2n)\),结果不会复现 PASS。Example 4 验证 p = 0 的单侧精确区间,因此包允许区间规划的预期比例取 0 或 1。
19.2.6 单比例目标值检验:SAS、PASS 多参数对照
软件选项与包参数对应如下。
| SAS/PASS 选项 | ivdtools 参数 |
含义 |
|---|---|---|
SAS TEST=Z VAREST=NULL;PASS Z-test using S(P0) |
test = "score" |
α 项使用 \(p_0\) 方差 |
SAS TEST=ADJZ;PASS S(P0) with C.C. |
test = "score-cc" |
S(P0) Z 检验加连续性校正 |
PASS Z-test using S(Phat) |
test = "wald" |
α 项使用 \(p_1\) 方差的 Wald 近似 |
METHOD=NORMAL;Normal Approximation |
power_method = "normal" |
连续正态近似搜索样本量 |
| Exact;Binomial Enumeration | power_method = "binomial" |
离散二项拒绝域与效能 |
对照覆盖 SAS Example 90.2 的无校正/有校正结果、PASS Example 9 和 11,以及 PASS Example 2 的六个效应大小。
代码
target_manual <- data.frame(
case = c(
"SAS 90.2 Z", "SAS 90.2 ADJZ", "PASS 9", "PASS 11",
paste0("PASS 2, p1=", sprintf("%.2f", seq(0.55, 0.80, 0.05)))
),
alternative = c(
"less", "less", "greater", "two.sided", rep("two.sided", 6)
),
test = c(
"score", "score-cc", "score", "wald", rep("score", 6)
),
p0 = c(0.30, 0.30, 0.50, 0.30, rep(0.50, 6)),
p1 = c(0.20, 0.20, 0.60, 0.50, seq(0.55, 0.80, 0.05)),
target_power = c(0.80, 0.80, 0.80, 0.80, rep(0.90, 6)),
manual_n = c(119L, 129L, 153L, 50L, 1047L, 259L, 113L, 62L, 38L, 25L),
manual_power = c(
0.80000, 0.80100, 0.80125, 0.80743,
0.90011, 0.90055, 0.90120, 0.90286, 0.90249, 0.90321
)
)
target_results <- lapply(
seq_len(nrow(target_manual)),
function(i) sample_size_proportion(
p0 = target_manual$p0[i], p1 = target_manual$p1[i],
alpha = 0.05, power = target_manual$target_power[i],
alternative = target_manual$alternative[i],
test = target_manual$test[i], power_method = "normal"
)
)| 标准位置 | 统计量 | 标准结果 | ivdtools结果 |
|---|---|---|---|
| SAS 90.2 Z | sample size | 119.00000 | 119.00000 |
| SAS 90.2 Z | normal planning power | 0.80000 | 0.80032 |
| SAS 90.2 ADJZ | sample size | 129.00000 | 129.00000 |
| SAS 90.2 ADJZ | normal planning power | 0.80100 | 0.80094 |
| PASS 9 | sample size | 153.00000 | 153.00000 |
| PASS 9 | normal planning power | 0.80125 | 0.80125 |
| PASS 11 | sample size | 50.00000 | 50.00000 |
| PASS 11 | normal planning power | 0.80743 | 0.80743 |
| PASS 2, p1=0.55 | sample size | 1047.00000 | 1047.00000 |
| PASS 2, p1=0.55 | normal planning power | 0.90011 | 0.90011 |
| PASS 2, p1=0.60 | sample size | 259.00000 | 259.00000 |
| PASS 2, p1=0.60 | normal planning power | 0.90055 | 0.90055 |
| PASS 2, p1=0.65 | sample size | 113.00000 | 113.00000 |
| PASS 2, p1=0.65 | normal planning power | 0.90120 | 0.90120 |
| PASS 2, p1=0.70 | sample size | 62.00000 | 62.00000 |
| PASS 2, p1=0.70 | normal planning power | 0.90286 | 0.90286 |
| PASS 2, p1=0.75 | sample size | 38.00000 | 38.00000 |
| PASS 2, p1=0.75 | normal planning power | 0.90249 | 0.90249 |
| PASS 2, p1=0.80 | sample size | 25.00000 | 25.00000 |
| PASS 2, p1=0.80 | normal planning power | 0.90321 | 0.90321 |
十个案例还需检查最终整数样本量下的离散运行特征:
| 标准位置 | 统计量 | 标准结果 | ivdtools结果 |
|---|---|---|---|
| SAS 90.2 Z | binomial achieved power | NA | 0.80363 |
| SAS 90.2 Z | actual alpha | 0.05 | 0.04776 |
| SAS 90.2 ADJZ | binomial achieved power | NA | 0.79446 |
| SAS 90.2 ADJZ | actual alpha | 0.05 | 0.03595 |
| PASS 9 | binomial achieved power | NA | 0.80944 |
| PASS 9 | actual alpha | 0.05 | 0.05280 |
| PASS 11 | binomial achieved power | NA | 0.83888 |
| PASS 11 | actual alpha | 0.05 | 0.06532 |
| PASS 2, p1=0.55 | binomial achieved power | NA | 0.89681 |
| PASS 2, p1=0.55 | actual alpha | 0.05 | 0.04789 |
| PASS 2, p1=0.60 | binomial achieved power | NA | 0.89499 |
| PASS 2, p1=0.60 | actual alpha | 0.05 | 0.04656 |
| PASS 2, p1=0.65 | binomial achieved power | NA | 0.91362 |
| PASS 2, p1=0.65 | actual alpha | 0.05 | 0.05943 |
| PASS 2, p1=0.70 | binomial achieved power | NA | 0.91073 |
| PASS 2, p1=0.70 | actual alpha | 0.05 | 0.05590 |
| PASS 2, p1=0.75 | binomial achieved power | NA | 0.86830 |
| PASS 2, p1=0.75 | actual alpha | 0.05 | 0.03355 |
| PASS 2, p1=0.80 | binomial achieved power | NA | 0.89088 |
| PASS 2, p1=0.80 | actual alpha | 0.05 | 0.04329 |
binomial_power 和 actual_alpha 是包在最终整数 n 下追加的离散诊断,并未反过来改变正态近似样本量。Wald 或部分 Score 方案会出现实际 α 大于 0.05;例如 PASS Example 11 约为 0.06532。若方案要求实际 α 受控,应改用 power_method = "binomial";所得 n 可能与手册的连续近似 n 不同,这属于设计方法不同,不应改写成“一致”。
test |
power_method="normal" |
power_method="binomial" |
手册核验覆盖 |
|---|---|---|---|
exact |
支持;无限总体时规划公式同 Score | 支持 | PASS Example 5、12 核验离散拒绝域;Example 13 核验正态效能 |
score |
支持 | 支持 | SAS 90.2、PASS 2/5/9 |
score-cc |
支持 | 支持 | SAS 90.2 ADJZ、PASS 5 |
wald |
支持 | 支持 | PASS 5、11 |
wald-cc |
支持 | 支持 | PASS 5;手册没有单独的求 n 验证案例 |
agresti-coull、jeffreys |
不支持 | 支持 | 所查 PASS 单比例检验过程未提供这两种检验统计量 |
测试层还逐项复现了 PASS Example 5:6 个固定 n × 5 种检验,共 30 个离散效能和 30 个实际 α。这些是拒绝域实现的验证,不改变公开函数“只计算样本量”的接口。
19.2.7 CMDE《体外诊断试剂临床试验技术指导原则》附录案例一:有临床可接受标准的目标值法
附录采用正态近似公式
\[ n=\frac{\left[Z_{1-\alpha/2}\sqrt{P_0(1-P_0)}+ Z_{1-\beta}\sqrt{P_T(1-P_T)}\right]^2}{(P_T-P_0)^2}. \]
案例设双侧 \(\alpha=0.05\)、效能 \(1-\beta=0.80\)。阳性符合率的可接受标准/预期值为 85%/90%,阴性符合率为 90%/94%。附录用 \(Z_{0.975}=1.96\)、\(Z_{0.80}=0.84\),报告阳性组 362 例、阴性组 388 例,合计 750 例;按 10% 脱落剔除率加量后至少入组 834 例。
sample_size_proportion(test="score", power_method="normal") 执行同一连续正态近似。包使用未舍入的正态分位数,并将理论样本量向上取整;随后另外按离散二项拒绝域核算实际 α 和实际效能。
代码
cmde_target_value <- data.frame(
group = c("阳性组", "阴性组"),
p0 = c(0.85, 0.90),
p1 = c(0.90, 0.94),
cmde_n = c(362L, 388L)
)
cmde_target_results <- lapply(
seq_len(nrow(cmde_target_value)),
function(i) {
sample_size_proportion(
p0 = cmde_target_value$p0[i],
p1 = cmde_target_value$p1[i],
alpha = 0.05,
power = 0.80,
alternative = "two.sided",
test = "score",
power_method = "normal"
)
}
)| 标准位置 | 统计量 | 标准结果 | ivdtools结果 |
|---|---|---|---|
| CMDE target-value / 阳性组 | sample size | 362 | 363.00000 |
| CMDE target-value / 阳性组 | actual alpha | NA | 0.05552 |
| CMDE target-value / 阴性组 | sample size | 388 | 388.00000 |
| CMDE target-value / 阴性组 | actual alpha | NA | 0.05094 |
| CMDE target-value / 合计 | sample size | 750 | 751.00000 |
| CMDE target-value / 合计 | actual alpha | NA | NA |
阳性组公式值为 362.7756,满足目标效能的最小整数是 363;附件写为 362,来自近似分位数和普通取整。actual_alpha 是将连续近似确定的样本量重新放回离散拒绝域后得到的诊断指标,不参与 CMDE 公式本身的样本量搜索。
19.2.8 CMDE《体外诊断试剂临床试验技术指导原则》附录案例二:只要求置信区间精度的允许误差法
附录公式为
\[ n=\frac{Z_{1-\alpha/2}^2P(1-P)}{\Delta^2}. \]
灵敏度预期为 85%、特异度预期为 90%,允许误差 \(\Delta=0.05\)。该公式对应 sample_size_proportion_ci(method = "wald");包使用精确的 qnorm(0.975),并把样本量向上取整为满足半宽要求的最小整数。
代码
cmde_ci_precision <- data.frame(
group = c("阳性组(灵敏度)", "阴性组(特异度)"),
p = c(0.85, 0.90),
cmde_n = c(196L, 138L)
)
cmde_ci_precision$ivdtools_n <- vapply(
cmde_ci_precision$p,
function(p) sample_size_proportion_ci(
p = p, half_width = 0.05, conf.level = 0.95, method = "wald"
)$n,
integer(1)
)| 标准位置 | 统计量 | 标准结果 | ivdtools结果 |
|---|---|---|---|
| CMDE allowable-error / 阳性组(灵敏度) | sample size | 196 | 196 |
| CMDE allowable-error / 阴性组(特异度) | sample size | 138 | 139 |
| CMDE allowable-error / 合计 | sample size | 334 | 335 |
| CMDE allowable-error / 10% addition | enrolment | 371 | 373 |
阴性组包结果为 139,而附录报告 138。差异来自两个细节:附录代入近似值 1.96 后把 138.30 报为 138,包使用精确分位数并向上取整。附录据 334 例进一步报告 10% 加量后 371 例;若“至少入组”按保守整数处理,包的 335 个可分析病例应取 \(\lceil335/0.90\rceil=373\)。这不是置信区间方法差异,而是分位数精度和整数取整规则差异。
当预期比例接近 100% 时,指导原则也提醒正态近似可能不适用。此时可以用 sample_size_proportion_ci(method = "clopper-pearson") 等方法做敏感性分析,但结果属于改变区间方法后的补充分析,不能标成附件 Wald 公式的复算。