Adding the overall row estimates in gtsummary for Poisson regression

25 Views Asked by At

I would like to add a row that shows the estimates for the total sample. I am using Poisson regression and generating the findings for different groups using the tbl_strata2 command. However, I am able to generate the estimates for various indicators, for example in this example; sex. However, I would like to add a row indicating the incidence rates for the total sample before indicating the rates for the respective indicators. Below is an example code:

df = tibble(
  study_arm = c("C", "T", "C", "T", "C", "T", "C", "T"),
  events = c(3,4,12,6,7, 8,9,10),
  time_at_risk = c(100,200,400,200,300,100,500,500),
  sex=c("M", "F", "F", "M", "F", "M", "F", "M"))
library(gtsummary)

df %>% select(events, sex, time_at_risk, study_arm) %>%
tbl_strata2( strata=study_arm,
.tbl_fun=
~.x %>%
  tbl_uvregression(y= events,
                   method = glm,
                   formula = "{y} ~ {x} + offset(log(time_at_risk))",
                    method.args = list(family = poisson(link = log)),
                   exponentiate = TRUE,
                   hide_n = TRUE,
                   pvalue_fun = function(x) style_pvalue(x, digits = 3)) )
0

There are 0 best solutions below