我正在try 使用R中的tidycmprsk包进行竞争风险分析.

我的数据集遇到了一个问题,因为没有经过审查的 case (数据集中的每个人都经历了三种结果之一).

From the documentation:
The event status variable must be a factor, with the first level indicating ’censor’ and subsequent levels the competing risks.

你有什么办法绕过这一关吗?否则,它会将我的一个级别/结果视为审查,而实际上它是感兴趣的结果.

例如,下面列出了累积发病率曲线,并给出了两种结果--癌症死亡和其他原因死亡:

library(tidycmprsk)

cuminc(Surv(ttdeath, death_cr) ~ trt, trial)

但如果你go 掉被审查的 case ,现在它只给出一种失败类型的结果,认为另一种是你的被审查变量:

data <- trial %>%
  mutate(death_cr_new = case_when(
    death_cr=="censor" ~ 2,
    death_cr=="death from cancer" ~ 2,
    death_cr=="death other causes" ~ 3
  ))

data$death_cr_new<-as.factor(data$death_cr_new)

cuminc(Surv(ttdeath, death_cr_new) ~ trt, data)

推荐答案

即使没有被观察到,结果因素的第一级必须是审查水平.扩大你的例子,我在结果中添加了一个未观察到的级别,以表明正在进行审查.

library(tidycmprsk)

data <- 
  trial %>%
  dplyr::mutate(
    death_cr_new = 
      dplyr::case_when(
        death_cr=="censor" ~ 2,
        death_cr=="death from cancer" ~ 2,
        death_cr=="death other causes" ~ 3
      ) %>%
      factor(levels = 1:3)
  )

data$death_cr_new %>% table()
#> .
#>   1   2   3 
#>   0 145  55


cuminc(Surv(ttdeath, death_cr_new) ~ trt, data)
#> 
#> ── cuminc() ────────────────────────────────────────────────────────────────────
#> • Failure type "2"
#> strata   time   n.risk   estimate   std.error   95% CI          
#> Drug A   5.00   97       0.000      0.000       NA, NA          
#> Drug A   10.0   94       0.020      0.014       0.004, 0.065    
#> Drug A   15.0   83       0.071      0.026       0.031, 0.134    
#> Drug A   20.0   61       0.173      0.039       0.106, 0.255    
#> Drug B   5.00   102      0.000      0.000       NA, NA          
#> Drug B   10.0   95       0.039      0.019       0.013, 0.090    
#> Drug B   15.0   75       0.167      0.037       0.102, 0.246    
#> Drug B   20.0   55       0.255      0.043       0.175, 0.343
#> • Failure type "3"
#> strata   time   n.risk   estimate   std.error   95% CI          
#> Drug A   5.00   97       0.010      0.010       0.001, 0.050    
#> Drug A   10.0   94       0.020      0.014       0.004, 0.065    
#> Drug A   15.0   83       0.082      0.028       0.038, 0.147    
#> Drug A   20.0   61       0.204      0.041       0.131, 0.289    
#> Drug B   5.00   102      0.000      0.000       NA, NA          
#> Drug B   10.0   95       0.029      0.017       0.008, 0.077    
#> Drug B   15.0   75       0.098      0.030       0.050, 0.165    
#> Drug B   20.0   55       0.206      0.040       0.133, 0.289
#> • Tests
#> outcome   statistic   df     p.value    
#> 2         1.03        1.00   0.31       
#> 3         0.089       1.00   0.77

reprex package(v2.0.1)于2022-08-17创建

R相关问答推荐

R:更新后无法运行控制台

在垂直轴中包含多个ggplot2图中的平均值

当两个图层映射到相同的美学时,隐藏一个图层的图例值

为了网络分析目的,将数据框转换为长格式列联表

根据类别合并(汇总)某些行

DEN扩展包中的RECT树形图出现异常行为

如何指定我的函数应该查找哪个引用表?

如何根据R中其他变量的类别汇总值?

在数据帧列表上绘制GGPUP

如何计算增加10米(0.01公里)的行?

将工作目录子文件夹中的文件批量重命名为顺序

如何在使用因子时获得Sankey图的Scale_Fill_Viridis的全范围

使用函数从R中的列中删除标高

在不重复主题的情况下重新排列组

如何用不同长度的向量填充列表?

在不带max()的data.table中按组查找最后一个元素

合并多个数据帧,同时将它们的名称保留为列名?

如何将一列相关性转换为R中的相关性矩阵

打印的.txt文件,将值显示为&Quot;Num&Quot;而不是值

使用grepl过滤特定列范围内的列名