r - 使用(样条)变换调整列线图刻度,rms 包 [R]
问题描述
考虑到我的变量槽样条变换,我正在使用 Cox 回归模型。在随后的列线图之前一切都很好......正如预期的那样,我的变量的比例也被转换了,但我想在值 0 和 2 之间的区域内添加一些自定义刻度(我猜是转换后的刻度)。有什么想法吗?
这是我的代码...
data <- source("https://pastebin.com/raw/rGtUSTLz")$value
ddist <- datadist(data)
options(datadist = "ddist")
fit <- cph(Surv(time, event) ~ rcs(var, 3), data = data, surv = T, x = T, y = T)
surv <- Survival(fit)
plot(nomogram(fit,
fun = list(function(x) surv(times = 10, lp = x),
function(x) surv(times = 30, lp = x),
function(x) surv(times = 60, lp = x)),
funlabel = paste("c", 1:3), lp = T))
...这些是真实的和期望的输出。
在此先感谢您的帮助!
解决方案
我也遇到过这个问题。我的答案是解决使用另一个包的方法,regplot
. 或者,如果您知道要绘制的刻度线处的点值是什么,那么您可以提供这些值而不是使用 regplot 的输出。基本上,您需要修改从列线图函数输出并用于绘制列线图的刻度线和点。
此方法还提供了一种通过编辑列线图输出来删除点/刻度线的方法。
data <- source("https://pastebin.com/raw/rGtUSTLz")$value
ddist <- datadist(data)
options(datadist = "ddist")
fit <- cph(Surv(time, event) ~ rcs(var, 3), data = data, surv = T, x = T, y = T)
surv <- Survival(fit)
nom1 <- nomogram(fit, fun = list(function(x) surv(times = 10, lp = x),
function(x) surv(times = 30, lp = x),
function(x) surv(times = 60, lp = x)),
funlabel = paste("c", 1:3), lp = T)
library(regplot)
# call regplot with points = TRUE to get output
regplot(fit, fun = list(function(x) surv(times = 10, lp = x),
function(x) surv(times = 30, lp = x),
function(x) surv(times = 60, lp = x)),
funlabel = paste("c", 1:3), points = TRUE)
# look at the points supplied through regplot and take those.
nom1_edit <- nom1
# now we edit the ticks supplied for var and their corresponding point value
nom1_edit[[1]][1] <- list(c(0, 0.06, 0.15, 0.3, 2,4,6,8,10,12,14,16))
nom1_edit[[1]][2] <- list(c(0, 10, 21, 32, 42.41191, 50.63878, 58.86565,
67.09252, 75.31939, 83.54626, 91.77313, 100.00000))
nom1_edit$var$points <- c(0, 10, 21, 32, 42.41191, 50.63878, 58.86565,
67.09252, 75.31939, 83.54626, 91.77313, 100.00000)
# plot the edited nomogram with new points
plot(nom1_edit)
推荐阅读
- java - 从节点调用 EJB 客户端
- angular - Angular 6,无法绑定到“org”,因为它不是“appCycleDirection”(指令)的已知属性
- elasticsearch - Scrapy 到 elasticsearch 批量导入?
- linux - 从 Bluez 5.48 开始如何写入特征
- c# - 使用 StackTrace 获取调用方法
- sql - SQL 错误 - “列定义不明确”
- python - Python将类和函数从一个文件导入另一个文件
- c - 赋值运算符如何处理二维字符数组的元素?
- laravel - 解决 Laravel 5.5 cookie 未在请求标头中设置导致登录时页面不活动的问题
- r - R bookdown,fontawesome5,渲染失败,但文件编织在 RStudio 中就好了