簡體   English   中英

如何在森林中總結 wto 多重邏輯回歸模型 plot

[英]how to summarise wto multiple logistic regression models in a forest plot

I want to output the results of the wonderful gtsummary package for tbl_uvregression by groups with the function "as.forest_plot" https://www.danieldsjoberg.com/bstfun/reference/as_forest_plot.html . 前面的示例“https://stackoverflow.com/questions/60958953/how-to-summarise-multiple-logistic-regression-models-in-a-table/60959878#60959878”效果很好,我遵循了他們的示例。 但是,是否可以將 output 兩組作為森林 plot?

forrest<- as_forest_plot(
  df_uv,
  col_names = c("estimate","p.value"),
   graph.pos = 2,
   boxsize = 0.3,
   title_line_color = "darkblue",
   col = forestplot::fpColors(box = "darkred",lines="black", zero = "gray50"),
   shapes_gp = forestplot::fpShapesGp(default = gpar(lineend = "square", linejoin = "mitre", lwd = 2, col = "black")),
   box = gpar(fill = "darkred", col = "black"), # only one parameter
   txt_gp = fpTxtGp(ticks=gpar(cex=0.9),xlab=gpar(cex=1.2,vjust=3.5)),
   zero=1, cex=0.9, lineheight = "auto", colgap=unit(6,"mm"),
   lwd.ci=1, ci.vertices=TRUE, ci.vertices.height = 0.4)

這給了我“錯誤: x=必須是 class 'tbl_regression' 或 'tbl_uvregression'”

非常感謝

我不熟悉此package 此代碼顯示一個圖表。 我希望它有幫助...

library(gtsummary)
library(tidyverse)
library(bstfun)
library(forestplot)

trial_subset <-
  trial %>%
  select(trt, response, age, marker, grade) 

df_uv <-
  trial_subset %>%
  # group by trt, and nest data within group
  group_by(trt) %>%
  nest() %>%
  # build univariate logistic regression models separately within grouping variable
  mutate(
    tbl_uv = map(
      data,
      ~tbl_uvregression(
        data = .x, 
        y = response,
        method = glm, 
        method.args = list(family = binomial),
        exponentiate = TRUE
      )
    )
  )


class(df_uv$tbl_uv[[1]])

forrest <- as_forest_plot(
  df_uv$tbl_uv[[1]],
  col_names = c("estimate","p.value"),
  graph.pos = 2,
  boxsize = 0.3,
  title_line_color = "darkblue",
  col = forestplot::fpColors(box = "darkred",lines="black", zero = "gray50"),
  shapes_gp = forestplot::fpShapesGp(default = gpar(lineend = "square", linejoin = "mitre", lwd = 2, col = "black")),
  box = gpar(fill = "darkred", col = "black"), # only one parameter
  txt_gp = fpTxtGp(ticks=gpar(cex=0.9),xlab=gpar(cex=1.2,vjust=3.5)),
  zero=1, cex=0.9, lineheight = "auto", colgap=unit(6,"mm"),
  lwd.ci=1, ci.vertices=TRUE, ci.vertices.height = 0.4)

森林圖

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM