简体   繁体   English

生存包R:survSplit“开始时间<结束时间”

[英]Survival package R: survSplit “start time < end time”

I am trying to create a dataframe with cutpoints for piecewise hazard modelling using the survSplit function from survival. 我正在尝试使用生存的survSplit函数来创建带有切点的数据框,以进行分段危害建模。 The data is right-censored, but not left-truncated/censored. 数据是右删截的,但不是左截断/删截的。 The data looks like this 数据看起来像这样

stay event sex marstat agegr health ID 0.101 1 f 0 (75,90] 1 1 0.167 1 f 0 (75,90] 2 2 2.968 0 f 0 [65,75] 2 3

With stay being the time variable, and event being the event indicator 停留是时间变量,事件是事件指示器

Based on previous experience with the survsplit I started with the following code: 基于对survsplit的先前经验,我从以下代码开始:

             datasplit <- survSplit(data= data, cut = c(0.25, 0.5, 1, 2,3), 
                          end = "stay", start = "start", episode= "interval")

This did not work because it did not have a formula (but it apparently worked for me back in november, with what I guess was an older version of the survival package?) After a bit of googling of what the formula should be I entered the following 这是行不通的,因为它没有公式(但是显然在11月,它对我有用,我猜那是一个较旧的生存包版本?)在仔细搜索了应该使用的公式后,我进入了以下

           datasplit <- survSplit(Surv(stay, event)~., 
                        data= data, cut = c(0.25, 0.5, 1, 2,3), 
                        end = "stay", start = "start", episode= "interval")

I get the error message: " start time < end time", which is odd seeing as there is no start time. 我收到错误消息:“开始时间<结束时间”,由于没有开始时间,这很奇怪。 Based on a previous answer I saw on Stack overflow, I retried without end = and event = , but the error message did not go away. 根据我在堆栈溢出中看到的先前答案,我在没有end =和event =的情况下重试,但错误消息没有消失。 I am not sure what I can do to remedy it at this point. 我不确定目前该如何解决。

I see that you have already provided a response , but I wanted to discuss a little bit more the topic. 我看到您已经提供了答复,但是我想讨论更多有关该主题的内容。

There are two things to take into account here, sometimes in survival analysis it makes no sense that time happens at 0, so probably you are right that the events at time 0 should be added error to make sense of them. 这里有两点要考虑,有时在生存分析中,时间在0发生没有意义,因此您可能是对的,应该在时间0的事件中添加错误以使其有意义。

  longdata <- survival::survSplit(Surv(time2event, os_event ) ~.,
                        data = d %>%
                        dplyr::mutate(os_event = ( status == event_type),
                                      time2event = time) ,
                        cut = tau,
                        subset = (d %>% dplyr::select(time) %>%
                          unlist) != 0,
                        start = "start",
                        end = "event",
                        episode = "interval")

I found that the function has also a option called subset that could work to drop the observation at time 0 otherwise, I have read sometimes that observations at time 0 should be dropped, however I make more sense of your solution of adding a small error. 我发现该函数还有一个称为子集的选项,可以用来删除时间0处的观察值,否则,我有时会读到应该删除时间0处的观察值,但是我对添加小错误的解决方案更有意义。

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

相关问题 R生存包; 绘制 log(-log(survival)) 对 log(time) - R survival package; plotting log(-log(survival)) against log(time) 使用R生存软件包计算proc寿命测试95%CI的中位生存时间 - Calculate the proc lifetest 95%CI for median survival time using R survival package R 平滑生存曲线力起止 - R smooth survival curve force start and end 使用&#39;生存&#39;包中的&#39;tmerge&#39;为生存数据添加时变协变量 - Adding time varying covariates to survival data using 'tmerge' in 'survival' package R计算开始结束时间之间的时间间隔内的时间 - R calculate time within time interval between start End time R中开始,结束,持续时间的时间序列可视化 - Time series visualization for start, end, duration in R 如何在r的生存包中的`coxph`模型中创建协变量时间依赖? - How to create a co-variate time dependent to use in `coxph` model in survival package in r? 在R中找到时间序列峰值的开始和结束 - Finding start and end of a peak in time series in R R 使用 survSplit 重塑/扩展数据集以获得 cox 回归的时变变量 - R reshaping / expanding dataset using survSplit to obtain time-varying variable for cox regression 如何基于开始和停止时间创建生存时间变量 - How to create a survival time variable based on start and stop time
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM