基于tbl_uvregression進(jìn)行單因素分析整潔表格的繪制

官網(wǎng)教程地址
https://www.danieldsjoberg.com/gtsummary/reference/tbl_uvregression.html?q=tbl%20_%20uvregression#methods-1
個(gè)人認(rèn)為這個(gè)函數(shù)最重要的是下面這句說明: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.
因?yàn)閱我蛩亟Y(jié)果相關(guān)沒有影響,因此在向函數(shù)提供的列表中,除了結(jié)果變量外的其他變量都會(huì)做分析并被報(bào)告,這點(diǎn)比較重要,一般可以先select出需要的變量,然后進(jìn)行分析。

library(gtsummary)

# 邏輯回歸 1 ----------------------------------
tbl_uv_ex1 <-
  tbl_uvregression(
    trial[c("response", "age", "grade")],#構(gòu)建待分析列表
    method = glm,#確定回歸方法
    y = response,#確定結(jié)果變量
    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")],#構(gòu)建分析列表
    method = coxph,#生存分析的函數(shù)
    y = Surv(ttdeath, death),#構(gòu)建生存對(duì)象
    exponentiate = TRUE,
    pvalue_fun = function(x) style_pvalue(x, digits = 2)# P值保留兩位小數(shù)
  );tbl_uv_ex2 
# }

image.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容