官網(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