Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a function within gtsummary to add the R2, N, and F-statistic to an output table which includes multiple models?

I'm using tbl_merge to add several regression models together and present them in a single table, but would ideally like to be able to present the R2, F-statistic, and N for each model at the bottom of the table, as you can do for the case of a single model with add_glance_source_note. Is there an easy way to do this?

like image 246
bee Avatar asked Nov 01 '25 14:11

bee


1 Answers

You can use the function add_glance_table() to append the additional statistics to the table. Example below!

library(gtsummary)
packageVersion("gtsummary")
#> [1] '1.4.0'

tbl1 <-
  lm(marker ~ age + grade, trial) %>% 
  tbl_regression() %>%
  add_glance_table(include = c(nobs, r.squared))

tbl2 <- tbl_merge(list(tbl1, tbl1))

enter image description here Created on 2021-04-13 by the reprex package (v2.0.0)

like image 50
Daniel D. Sjoberg Avatar answered Nov 04 '25 06:11

Daniel D. Sjoberg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!