bee
bee

Reputation: 63

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?

Upvotes: 3

Views: 806

Answers (1)

Daniel D. Sjoberg
Daniel D. Sjoberg

Reputation: 11784

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)

Upvotes: 5

Related Questions