When the documentation mentions “groups”, it refers to models like multinomial logits where each predictor has one coefficient per outcome level. In this example, the “group” column is called “response”:
library(nnet)
library(modelsummary)
mod <- multinom(cyl ~ mpg + hp, data = mtcars, trace = FALSE)
modelsummary(
mod,
output = "markdown",
shape = response ~ model)
|
|
Model 1 |
(Intercept) |
6 |
0.500 |
|
|
(41.760) |
|
8 |
8.400 |
|
|
(0.502) |
mpg |
6 |
-83.069 |
|
|
(416.777) |
|
8 |
-120.167 |
|
|
(508.775) |
hp |
6 |
16.230 |
|
|
(81.808) |
|
8 |
20.307 |
|
|
(87.777) |
Num.Obs. |
|
32 |
R2 |
|
1.000 |
R2 Adj. |
|
0.971 |
AIC |
|
12.0 |
BIC |
|
20.8 |
RMSE |
|
0.00 |
What you probably mean is something different: Adding manual labels to sets of coefficients. This is easy to achieve because modelsummary()
produces a kableExtra
or a gt
table which can be customized in infinite ways.
https://cran.r-project.org/web/packages/kableExtra/vignettes/awesome_table_in_html.html
For example, you may want to look at the group_rows
function from kableExtra
:
library(kableExtra)
mod <- lm(mpg ~ cyl + disp + hp, data = mtcars)
modelsummary(mod) |>
group_rows(index = c("Uninteresting" = 4,
"Interesting" = 4,
"Other" = 7))
