使用 DescTools::medianCI() 时围绕中位数的 90% 置信区间

90% confidence interval around the median in using DescTools::medianCI()

我需要得到围绕中位数的 90% 置信区间。

x <- c(251, 108, 27, 18, 195, 82, 222, 38, 81, 181, 140, 21, 43, 47, 15, 37, 46, 107, 19, 178, 95, 130, 60, 34, 48, 219, 338, 78, 117, 62, 40, 52)
MedianCI(x, conf.level=0.9)

结果是

median lwr.ci upr.ci 
 70     46    108  
attr(,"conf.level") [1] 0.9498975

它生成一个 0.949 级别的间隔,但我想要 0.9。正确的方法是什么?正确答案应该是 (70, 47, 108).

这里有两个主要问题。

  1. 书上给出的方法是大概的。正如作者所说,对于大多数 large-sample 数据集来说可能没问题,但实际上它比 MedianCI

    实现的方法更不“正确”
  2. 特别是对于小数据集,置信区间(无论如何计算)不太可能与数据集中的观察值完全一致:这就是作者说

    的原因

The results of the equation are rounded up to the next integer and the boundary of the confidence interval is between the two values in the data set.

(我不清楚为什么结果会针对下限和上限 CI 进行四舍五入;我本希望它们针对上限进行四舍五入,针对下限进行四舍五入...)

通过给你 0.949 置信区间而不是你要求的 0.9,MedianCI 是保守的(CI 的典型定义是一个包含真实值 至少 x% 的时间);置信水平 0.89-0.94 将为您提供 0.949 水平,而 0.79-0.88 的值将为您提供 0.889 水平。

如果您对我的回答的技术细节有 follow-up 个问题,您应该在 CrossValidated 上提问。我不知道某个地方的 R 包中是否有 handy-dandy built-in 函数实现了书中给出的近似方法(尽管它应该只需要 advanced-beginner R 技能来实现;如果您想尝试一下,试一试,当您遇到困难时可以随时提出另一个问题...)