【问题标题】:Multiple univariate Cox regression with tbl_uvregression() function from {gtsummary}具有来自 {gtsummary} 的 tbl_uvregression() 函数的多元单变量 Cox 回归
【发布时间】:2021-03-04 12:23:32
【问题描述】:

我找不到如何使用 {gtsummary} 中的 tbl_uvregression() 函数执行多单变量 Cox 回归。

这是我到目前为止:

  • 执行多元单变量逻辑回归,其中:
tbl_uvregression(dataSOF, method = glm, y = death, method.args = list(family = binomial), exponentiate = T)
  • 执行单变量 cox 回归,其中:
coxph(Surv(survival_days, survival_status) ~ age, data = dataSOF) %>%
  tbl_regression(exponentiate = TRUE)
  • 执行多元 cox 回归,其中:
coxph(Surv(survival_days, survival_status) ~ age+disease, data = dataSOF) %>%
  tbl_regression(exponentiate = TRUE)

但我无法得到多个单变量 cox 回归...

我试过了:

tbl_uvregression(
  dataSOF,
  method=coxph,
  y = Surv(time = survival_days, event = survival_status),
  method.args = list(family = binomial),
  exponentiate = T
)

但我收到以下错误:

Erreur : Problem with `mutate()` input `model`.
x Argument family not matched
i Input `model` is `map(...)`.
Run `rlang::last_error()` to see where the error occurred.

我正在处理的数据:

dput(dataSOF[1:10, ])
structure(list(ID = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), age = c(62, 
57, 67, 74, 71, 67, 46, 71, 53, 63), disease = c(0, 1, 1, 1, 
1, 0, 1, 0, 0, 0), death = c(0, 0, 1, 0, 1, 1, 0, 1, 0, 1), censored_survival_days = c(60, 
60, 60, 60, 60, 60, 60, 60, 60, 60), censored_survival_status = c(1, 
1, 1, 1, 1, 1, 1, 1, 1, 1)), row.names = c(NA, -10L), class = c("tbl_df", 
"tbl", "data.frame"))

有什么建议吗? 非常感谢提前!


更新

另一个可复制的例子:

dataAAV3 <- structure(list(age = c(62, 57, 67, 46, 53, 63, 60, 77, 69, 86
), sexe = c(1, 1, 1, 1, 1, 1, 0, 1, 0, 1), survie_sans_deces_cens5 = c(60, 
                                                                       60, 60, 60, 60, 60, 60, 20, 60, 8), status_deces_cens5 = structure(c(1L, 
                                                                                                                                            1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L), .Label = c("1", "2"), class = "factor")), row.names = c(NA, 
                                                                                                                                                                                                                                         -10L), class = c("tbl_df", "tbl", "data.frame"))```


library(gtsummary)
#> Warning: le package 'gtsummary' a été compilé avec la version R 4.0.3
tbl_uvregression(
  dataAAV3,
  method=coxph,
  y = Surv(time = survie_sans_deces_cens5, event = status_deces_cens5),
  exponentiate = TRUE)
#> Warning in .select_to_varnames(select = !!y, data = data, arg_name = "y"):
#> redémarrage de l'évaluation d'une promesse interrompue
#> Error: Specify one, and only one, of `x` and `y`. This function can
#>          create univariate regression models holding either a covariate or outcome
#>          constant.
Created on 2021-03-04 by the reprex package (v1.0.0)

【问题讨论】:

  • 从单变量回归模型调用中删除以下行。 method.args = 列表(家庭 = 二项式)。这是用于 glm 逻辑回归的,而不是 Cox 所需要的
  • 按照建议,我尝试了tbl_uvregression(dataSOF,method=coxph,y = Surv(time = survival_days, event = survival_status),exponentiate = T),但仍然遇到与上述相同的错误...
  • 您能否将代码和结果放入正确的表示中?在您删除家庭参数后得到相同的错误是很奇怪的。 reprex.tidyverse.org
  • 这次没有得到同样的错误:library(gtsummary) #&gt; Warning: le package 'gtsummary' a été compilé avec la version R 4.0.3 tbl_uvregression( dataSOF, method=coxph, y = Surv(time = survival_days, event = survival_status), exponentiate = T ) #&gt; Warning in .select_to_varnames(select = !!y, data = data, arg_name = "y"): #&gt; redémarrage de l'évaluation d'une promesse interrompue #&gt; Error: Specify one, and only one, of `x` and `y`. This function can #&gt; create univariate regression models holding either a covariate or outcome #&gt; constant.

标签: r cox-regression survival gtsummary


【解决方案1】:

使用您的示例数据,以下代码有效。请注意,您提供的数据框中的变量名称与函数调用中的变量名称不匹配。

library(gtsummary)
packageVersion("gtsummary")
#> [1] '1.3.7'
library(survival)

dataSOF <-
  structure(
    list(
      ID = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
      age = c(62, 57, 67, 74, 71, 67, 46, 71, 53, 63),
      disease = c(0, 1, 1, 1, 1, 0, 1, 0, 0, 0), 
      death = c(0, 0, 1, 0, 1, 1, 0, 1, 0, 1), 
      censored_survival_days = c(60, 60, 60, 60, 60, 60, 60, 60, 60, 60), 
      censored_survival_status = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
    ), 
    row.names = c(NA, -10L), 
    class = c("tbl_df", "tbl", "data.frame")
  )


tbl_uvregression(
  dataSOF,
  method=coxph,
  y = Surv(time = censored_survival_days, event = censored_survival_status),
  exponentiate = TRUE,
  include = -ID
)

reprex package (v1.0.0) 于 2021 年 3 月 4 日创建

【讨论】:

  • 你的代码对我有用! ...但是当我使用完整的数据集时,我仍然得到一个错误(现在是新的):Erreur : Problem with `mutate()` input `model`. x an id statement is required for multi-state models i Input `model` is `map(...)`. Run `rlang::last_error()` to see where the error occurred.
  • 您可以执行以下操作之一吗? 1. 创建一个可以在我的机器上运行的可重现示例? 2. 在tbl_uvregression() 之外构建每个单变量回归模型。我怀疑模型构建有错误,因此tbl_uvregression() 将无法包装代码。
  • 好的:请参阅更新的第一篇文章以获取可复制的示例
  • 您指定的模型不正确。如果您尝试在 tbl_uvregression() 函数之外构建模型,则会出现错误。 coxph(Surv(time = survie_sans_deces_cens5, event = status_deces_cens5) ~ age, data = dataAAV3)。该函数无法构造一系列错误指定的模型。
  • 我的第一个数据库中一定有错字或其他类似的东西。我从一个新的开始,一切都很顺利!非常感谢您的帮助!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多