0

I have experienced the same issue with multinom (nnet) and an extra "N" row above the glance table in tbl_regression (gtsummary) that this user had: Previous post

In the replies to the previous question it was asked to provide reproducable code, so here it is:

library(nnet)
library(gtsummary)
library(tidyverse)

# Create a sample data frame
set.seed(123)
df <- data.frame(
  y = sample(c(0, 1, 2), 100, replace = TRUE),
  x1 = rnorm(100),
  x2 = rnorm(100),
  x3 = rnorm(100)
)

# Fit a multinomial logistic regression model with nnet
model <- nnet::multinom(y ~ x1 + x2 + x3, data = df)

# Create a summary table with tbl_regression
model_tab <- tbl_regression(model, 
               exponentiate = TRUE) %>% 
  add_glance_table(c(nobs, AIC)) 

model_tab

enter image description here

I suspect the NA row has to do with tbl_regression producing an "empty model" for the NAs in the dependent variable. When I used Daniel Sjoberg's function to display a multinom model in wide format here, I noted that tbl_regression produced an additional empty model column for the value "NA" of my dependent variable, to the right of my table. I tried to use na.action = na.omit in multinom, to no avail.

So, perhaps tbl_regression is just too buggy for multinom models and I have to shift to another table-producing package. Nonetheless, if anyone has a clue how to avoid the NA issue, I would be happy to continue using the otherwise very useful gtsummary package.

Chris_S
  • 11
  • 4

0 Answers0