繁体   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