r - R:在 RandomForestSRC 中用时变协变量拟合生存树
问题描述
在 LTRCtrees 包中,可以根据以下示例将决策树拟合到 Surv 函数的特殊格式:Surv(time, time2, event)
set.seed(0)
library(survival)
library(LTRCtrees)
## Create the start-stop-event triplet needed for coxph and LTRC trees
first <- with(pbcseq, c(TRUE, diff(id) !=0)) #first id for each subject
last <- c(first[-1], TRUE) #last id
time1 <- with(pbcseq, ifelse(first, 0, day))
time2 <- with(pbcseq, ifelse(last, futime, c(day[-1], 0)))
event <- with(pbcseq, ifelse(last, status, 0))
event <- 1*(event==2)
pbcseq$time1 <- time1
pbcseq$time2 <- time2
pbcseq$event <- event
## Fit the Cox model and LTRC trees with time-varying covariates
fit.cox <- coxph(Surv(time1, time2, event) ~ age + sex + log(bili), pbcseq)
LTRCIT.fit <- LTRCIT(Surv(time1, time2, event) ~ age + sex + log(bili), pbcseq)
LTRCART.fit <- LTRCART(Surv(time1, time2, event) ~ age + sex + log(bili), pbcseq)
是否可以使用 RandomForestSRC 库在随机森林上使用相同的功能
library(randomForestSRC)
RF.fit <- rfsrc(Surv(time1, time2, event) ~ age + sex + log(bili), data=pbcseq, nsplit = 3, ntree = 100, importance = TRUE)
这会产生错误:
Error in parseFormula(formula, data, ytry) :
Survival formula incorrectly specified.
解决方案
Wongvibulsin、Wu 和 Zeger (2019) 的这篇论文扩展了 randomForestSRC 包以处理 TVC,但您可能需要联系作者以获取任何相关代码。
推荐阅读
- javascript - 使用 vanilla javascript 路由显示动态元素
- python - 为什么在 YOLOv5 中这两个结果不同?
- java - 在 Android Studio 中选择图像后应用退出(未调用 OnActivityResult)
- javascript - 从事件监听器传递字符串数组时,它会抛出一个错误,如下所示
- webpack - 如何将 webpack-dev-server 与 nodemon-webpack-plugin 一起使用?
- python - Python SQL 查询执行
- javascript - MUI 输入不允许 oninput 属性
- postman-testcase - 邮递员如何使用正则表达式读取隐藏字段的值
- python - 将一个元素转换为一个元素的元组/列表/集合/字符串的简洁通用方法
- makefile - Vasp 6.2.1 未编译