Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A bug? Strange behaviour with shape #631

Closed
iago-pssjd opened this issue May 10, 2023 · 2 comments
Closed

A bug? Strange behaviour with shape #631

iago-pssjd opened this issue May 10, 2023 · 2 comments

Comments

@iago-pssjd
Copy link

iago-pssjd commented May 10, 2023

Hi!

  1. When summarising a multinomial model and placing model in the LHS of shape, output adds seemingly extra rows related to an inexistent group model.
library(nnet)

dat_multinom <- mtcars
dat_multinom$cyl <- sprintf("Cyl: %s", dat_multinom$cyl)

mod <- list(
    nnet::multinom(cyl ~ mpg, data = dat_multinom, trace = FALSE),
    nnet::multinom(cyl ~ mpg + drat, data = dat_multinom, trace = FALSE))

modelsummary(mod, shape = model + term + response ~ statistic, output = "markdown")
response Est. S.E.
group (Intercept) Cyl: 6
Cyl: 8
mpg Cyl: 6
Cyl: 8
drat Cyl: 6
Cyl: 8
(1) (Intercept) Cyl: 6 47.252 34.975
Cyl: 8 72.440 37.175
mpg Cyl: 6 -2.205 1.638
Cyl: 8 -3.580 1.775
drat Cyl: 6
Cyl: 8
(2) (Intercept) Cyl: 6 89.573 86.884
Cyl: 8 117.971 87.998
mpg Cyl: 6 -3.627 3.869
Cyl: 8 -4.838 3.915
drat Cyl: 6 -3.210 3.810
Cyl: 8 -5.028 4.199

The 6 rows relative to the group model (2nd to 7th) should not appear.

Thank you!

@iago-pssjd
Copy link
Author

iago-pssjd commented May 10, 2023

A second issue: for multinomial models coef_rename = TRUE only works for first response level.

library(nnet)
dat_multinom <- mtcars
dat_multinom <- transform(mtcars, vs = as.factor(vs), carb = as.factor(carb))
mod <- list(
    nnet::multinom(cyl ~ vs, data = dat_multinom, trace = FALSE),
    nnet::multinom(cyl ~ vs + carb, data = dat_multinom, trace = FALSE))
modelsummary(mod, shape = model + term + response ~ statistic, output = "markdown", coef_rename = TRUE)
response Est. S.E.
group (Intercept) 6
8
vs [1] 6
vs1 8
carb [2] 6
carb [3] 6
carb [4] 6
carb [6] 6
carb [8] 6
carb2 8
carb3 8
carb4 8
carb6 8
carb8 8
(1) (Intercept) 6 1.098 1.155
8 2.639 1.035
vs [1] 6 -2.015 1.297
vs1 8 -13.237 63.322
carb [2] 6
carb [3] 6
carb [4] 6
carb [6] 6
carb [8] 6
carb2 8
carb3 8
carb4 8
carb6 8
carb8 8
(2) (Intercept) 6 82.903 94.629
8 82.866 18.933
vs [1] 6 -83.819 94.630
vs1 8 -184.305 0.000
carb [2] 6 -94.450 227.108
carb [3] 6 -16.791 0.000
carb [4] 6 144.977 37.852
carb [6] 6 258.280 0.000
carb [8] 6 -27.108 0.000
carb2 8 -81.480 18.936
carb3 8 83.106 0.000
carb4 8 146.112 37.852
carb6 8 -106.938 0.000
carb8 8 125.316 0.000

@vincentarelbundock
Copy link
Owner

Thanks a lot for the report. Both issues should be fixed on Github now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants