I am using the modelsummary
package to create a table for a multilevel logistic regression model estimated via glmer from the lme4
package. I would know like to include the number of groups in my table. The information does not appear in get_gof(model)
, but it exists if I type in summary(model)
. In the example below, I would like to have one row with the information: Number of groups: 18.
A minimum reproducible example:
# Load the required packages
library(lme4)
# Load the sleepstudy dataset
data(sleepstudy)
# Convert the dependent variable to a binary outcome
sleepstudy$binary_outcome <- ifelse(sleepstudy$Reaction > median(sleepstudy$Reaction), 1, 0)
# Run the multilevel logistic regression model using glmer
model <- glmer(binary_outcome ~ Days + (1 | Subject), data = sleepstudy, family = binomial())
# Print the model summary
summary(model)
# Use Modelsummary to print the table
modelsummary(models,
output = "table.docx",
coef_map = cm, title = 'Table 1',
exponentiate = TRUE,
stars = T)