【问题标题】:How can I determine the x-coordinate when y=1 in Spline Curve / RMS package / R?当样条曲线/ RMS包/ R中的y = 1时,如何确定x坐标?
【发布时间】:2019-01-21 13:49:44
【问题描述】:

我附上了一张用 R 中的 rms 包生成的样条曲线的图片。 它显示了危险比(死亡)与给定的药物累积剂量之间的关联。

请在下面找到我的数据和脚本。

我使用了 rms 包。我希望找到属于风险比 = y = 1 的 x 值 (w$total.mbq)。我尝试了 summary(model) 的不同组合,但它不起作用。

library(ggplot2)
library(rms)
d <- datadist(w)
options(datadist="d")
model <- cph(Surv(Follow.up.death,Death)~rcs(total.mbq),data=w)
ggplot(Predict(model, fun=exp)) + scale_y_continuous(breaks=c(1:10))

我的数据

w <- structure(list(Follow.up.death = c(18, 2, 14, 17, 31, 4, 20, 
15, 12, 19, 10, 17, 27, 22, 3, 43, 24, 14, 13, 5, 12, 137, 22, 
87, 48, 24, 72, 32, 14, 83, 68, 56, 57, 18, 16, 70, 1.9, 69.2, 
126.3, 41.6, 17.9, 1.3, 87.4, 4.4, 137.4, 17.5, 95.8, 65.2, 14.8, 
98.5, 16.6, 74.9, 10.3, 43.4, 32.5, 4.8, 7.3, 107.8, 6.8, 18.3, 
33, 25.2, 49.2, 15.9, 1.2, 42.7, 1, 9, 1.8, 15.6, 8.9, 15, 16.4, 
7.7, 75.5, 12.2, 54.8, 22.2, 9.7, 14.3, 5.2, 64.5, 21.8, 0.2, 
7.3, 18.7, 5.1, 17.3, 27.4, 16, 24.2, 9.7, 8.2, 5.7, 41.8, 10.6, 
22.8, 4.8, 6, 4, 50, 21, 30, 5, 11, 12), Death = c(0L, 1L, 1L, 
0L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 
0L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 
0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 
1L, 1L, 1L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 
1L, 0L, 0L, 0L, 0L, 0L, 0L), total.mbq = c(29354L, 7445L, 22309L, 
29699L, 29711L, 14765L, 22257L, 29715L, 29772L, 13320L, 20905L, 
12950L, 3400L, 14800L, 7400L, 21890L, 19400L, 14800L, 14700L, 
22200L, 1688L, 4500L, 8438L, 13500L, 14800L, 12580L, 12950L, 
13320L, 11840L, 13320L, 14800L, 13690L, 11250L, 12210L, 13320L, 
13320L, 14800L, 12580L, 20720L, 11840L, 14800L, 7030L, 14800L, 
14800L, 8325L, 11100L, 10730L, 13690L, 12210L, 14800L, 13320L, 
14800L, 12950L, 22200L, 17945L, 22200L, 8140L, 13690L, 11581L, 
14430L, 13320L, 13320L, 21090L, 11100L, 3885L, 6475L, 6660L, 
6660L, 5920L, 7500L, 5000L, 12500L, 12500L, 10000L, 12500L, 7500L, 
15000L, 10000L, 5000L, 7500L, 5000L, 15000L, 12500L, 7500L, 7500L, 
7500L, 5000L, 10000L, 10000L, 10000L, 12500L, 5000L, 5000L, 10000L, 
12500L, 5000L, 10000L, 10000L, 22200L, 14800L, 29000L, 14000L, 
4800L, 21600L, 28800L, 11400L)), .Names = c("Follow.up.death", 
"Death", "total.mbq"), class = "data.frame", row.names = c(NA, 
-106L))

【问题讨论】:

    标签: r regression rms cubic-spline


    【解决方案1】:
    f <- Function(model)  # create an R function for X*beta hat = log relative hazard
    

    这是total.mbq 的函数。使用 R 根求解器求解 f(x) = 0。我认为结果是中位数 total.mbq。另一方面,我可能已经解决了中心常数,因此所有受试者的平均对数风险为零。希望我现在能记住细节。

    【讨论】:

    • 感谢您的回复 - 没有像“summary(model, hr=1)”这样的“summary”内置函数?
    • 没有内置函数允许您指定预测值的值;它们只允许您指定预测变量的值。首先在total.mgq 的精细网格上绘制ftotal.mbq
    • 感谢您的宝贵时间。我真的很抱歉,但我对此很陌生——而且我不知道 R 根求解器。您能否根据我上面输入的内容推荐一个包并建议我可以使用的脚本?有很多问题要问,但我会非常感激
    • uniroot 函数将执行此操作,给定要考虑的 x 值范围。但从我建议的 x 网格上的简单图开始。另请查看rmsPredict 函数的adj.zeroref.zero 参数。
    猜你喜欢
    • 1970-01-01
    • 2016-09-07
    • 2019-05-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多