简体   繁体   English

如何处理 cox 比例风险 model 中的时间相关变量 r

[英]What to deal with time-dependent variables in cox proportional hazard model in r

I have a question about the time-dependent variables in cox model.我对 cox model 中的时间相关变量有疑问。 Supposed that I have three phases and the event may happen in any time and how can I fit these three time-dependent variables, tr1, tr2, tr3, in cox model?假设我有三个阶段并且事件可能随时发生,我如何在 cox model 中拟合这三个时间相关变量 tr1、tr2、tr3? The sample dataset is shown below:示例数据集如下所示:

tr1 <- c(11.6, 19.04, NA, NA, 10.39, 4.63)
tr2 <- c(63.85, 20.29, NA, NA, 11.64, 7.33)
tr3 <- c(66.51, 22.95, NA, NA, 16.05, 9.11)


if_event <- c(1, 1, 0, 0, 1, 1)
sur_time <- c(125.81, 30.23, 59.27, 161.17, 51.36, 7.52)
income <- c(103844, 57246, 83056, 38380, 37518, 900)
population <- c(10000, 20000, 40000, 88000, 90000, 102034)
dat <- cbind(tr1, tr2, tr3, if_event, sur_time, income, population)

Can I use coxph(Surv(time, event) ~ tr1 * tr2 + tr1 * tr3 + tr2 * tr3, data) to show that time-dependent variables, tr1, tr2 and tr3?我可以使用coxph(Surv(time, event) ~ tr1 * tr2 + tr1 * tr3 + tr2 * tr3, data)来显示时间相关变量 tr1、tr2 和 tr3?

Thanks so much for your kind help.非常感谢您的帮助。

在此处输入图像描述

More details about the dataset:有关数据集的更多详细信息:

tr1, tr2 and tr3 are three time-dependent variables since they have the same starting point, that is, tr1 means the time is from 0 to tr1 time, tr2 means the time from 0 to tr2, tr3 means the time from 0 to tr3. tr1、tr2和tr3是三个时间相关变量,因为它们的起点相同,即tr1表示从0到tr1的时间,tr2表示从0到tr2的时间,tr3表示从0到tr3的时间. When if_event is 1, it shows that the event has happened and look at the record 1, the survival happened after tr3 time; if_event为1时,说明事件已经发生,查看记录1,存活发生在tr3时间后; for record 6, the survival happened between tr2 and tr3.对于记录 6,生存发生在 tr2 和 tr3 之间。

I'm still not sure I understand you, but I need more space to write.我仍然不确定我是否理解你,但我需要更多的空间来写。

I think what you mean, is that there are 4 phases.我想你的意思是有4个阶段。 Every individual starts in phase 1, then at time tr1 they move to phase 2, at time tr2 they move to phase 3, and at time tr3 they move to phase 4. Below I create that dataset in start-stop format, as described here.每个人都从阶段 1 开始,然后在时间 tr1 他们进入阶段 2,在时间 tr2 他们进入阶段 3,在时间 tr3 他们进入阶段 4。下面我以开始-停止格式创建该数据集,如此处所述. https://cran.r-project.org/web/packages/survival/vignettes/timedep.pdf https://cran.r-project.org/web/packages/survival/vignettes/timedep.pdf

library(survival)
dat0 <- data.frame(
  id = 1:6,
  time = c(125.81, 30.23, 59.27, 161.17, 51.36, 7.52),
  status = c(1,1,0,0,1,1))
dat1 <- data.frame(
  id = 1:6,
  time = rep(0, 6),
  phase = factor(c("phase1", "phase1", NA, NA, "phase1", "phase1")))
dat2 <- data.frame(
  id = rep(1:6),
  time = c(11.6, 19.04, NA, NA, 10.39, 4.63),
  phase = factor(rep("phase2", 6)))
dat3 <- data.frame(
  id = rep(1:6),
  time = c(63.85, 20.29, NA, NA, 11.64, 7.33),
  phase = rep("phase3", 6))
dat4 <- data.frame(
  id = rep(1:6),
  time = c(66.51, 22.95, NA, NA, 16.05, 9.11),
  phase = rep("phase4", 6))
dat_rbind <- rbind(dat1, dat2, dat3, dat4)
newdat <- tmerge(dat0, dat0, id = id, status = event(time, status))
newdat$time <- NULL
dat <- tmerge(newdat, dat_rbind, id = id, phase = tdc(time, phase))
dat
#>    id status tstart  tstop  phase
#> 1   1      0   0.00  11.60 phase1
#> 2   1      0  11.60  63.85 phase2
#> 3   1      0  63.85  66.51 phase3
#> 4   1      1  66.51 125.81 phase4
#> 5   2      0   0.00  19.04 phase1
#> 6   2      0  19.04  20.29 phase2
#> 7   2      0  20.29  22.95 phase3
#> 8   2      1  22.95  30.23 phase4
#> 9   3      0   0.00  59.27   <NA>
#> 10  4      0   0.00 161.17   <NA>
#> 11  5      0   0.00  10.39 phase1
#> 12  5      0  10.39  11.64 phase2
#> 13  5      0  11.64  16.05 phase3
#> 14  5      1  16.05  51.36 phase4
#> 15  6      0   0.00   4.63 phase1
#> 16  6      0   4.63   7.33 phase2
#> 17  6      1   7.33   7.52 phase3

To interpret the data, individual 1 starts in phase 1 at time 0. For 0-11.60 they are in phase 1. At tr1 they have not yet had an event and they move from phase 1 into the next, into phase 2 from 11.60-63.85.为了解释数据,个人 1 在时间 0 开始在阶段 1。对于 0-11.60,他们处于阶段 1。在 tr1,他们还没有发生事件,他们从阶段 1 进入下一个阶段,从 11.60 进入阶段 2- 63.85。 Still no event as they move into phase 3 and phase 4. Then at time 125.81 they have an event while they were in phase 4.当他们进入阶段 3 和阶段 4 时仍然没有事件。然后在时间 125.81,他们在阶段 4 中发生了事件。

For individual 6, they experience an event at time 7.52, while they were in phase 3. This stops any future observations from happening for them, so individual 6 never enters phase 4.对于个人 6,他们在时间 7.52 经历了一个事件,当时他们处于阶段 3。这阻止了他们未来的任何观察发生,因此个人 6 永远不会进入阶段 4。

This is like I said in an earlier comment, and you said it wasn't quite right.这就像我在之前的评论中所说的,你说这不太对。 Can you describe what the problem with this is?你能描述一下这是什么问题吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM