基于tbl_uvregression进行单因素分析整洁表格的绘制

官网教程地址
https://www.danieldsjoberg.com/gtsummary/reference/tbl_uvregression.html?q=tbl%20_%20uvregression#methods-1
个人认为这个函数最重要的是下面这句说明:You may alternatively hold a single covariate constant. For this, pass a data frame, the type of regression model, and a single covariate in the x= argument. Each column of the data frame will serve as the outcome in a univariate regression model.
因为单因素结果相关没有影响,因此在向函数提供的列表中,除了结果变量外的其他变量都会做分析并被报告,这点比较重要,一般可以先select出需要的变量,然后进行分析。

library(gtsummary)

# 逻辑回归 1 ----------------------------------
tbl_uv_ex1 <-
  tbl_uvregression(
    trial[c("response", "age", "grade")],#构建待分析列表
    method = glm,#确定回归方法
    y = response,#确定结果变量
    method.args = list(family = binomial),
    exponentiate = TRUE
  );tbl_uv_ex1
image.png
library(survival)
tbl_uv_ex2 <-
  tbl_uvregression(
    trial[c("ttdeath", "death", "age", "grade", "response")],#构建分析列表
    method = coxph,#生存分析的函数
    y = Surv(ttdeath, death),#构建生存对象
    exponentiate = TRUE,
    pvalue_fun = function(x) style_pvalue(x, digits = 2)# P值保留两位小数
  );tbl_uv_ex2 
# }

image.png
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容