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
Error in nnet #109
Comments
Thanks for the feedback. It seems related to add_n feature. library(nnet)
library(MASS)
library(broom.helpers)
test1 <- multinom(race ~ age + lwt + bwt, data = birthwt)
#> # weights: 15 (8 variable)
#> initial value 207.637723
#> iter 10 value 168.608572
#> final value 168.587348
#> converged
test1 %>% tidy_plus_plus()
#> Error: Join columns must be present in data.
#> x Problem with `term`.
test1 %>% tidy_plus_plus(add_n = FALSE)
#> # A tibble: 6 x 17
#> y.level term variable var_label var_class var_type var_nlevels contrasts
#> <chr> <chr> <chr> <chr> <chr> <chr> <int> <chr>
#> 1 2 age age age integer continu~ NA <NA>
#> 2 2 lwt lwt lwt integer continu~ NA <NA>
#> 3 2 bwt bwt bwt integer continu~ NA <NA>
#> 4 3 age age age integer continu~ NA <NA>
#> 5 3 lwt lwt lwt integer continu~ NA <NA>
#> 6 3 bwt bwt bwt integer continu~ NA <NA>
#> # ... with 9 more variables: contrasts_type <chr>, reference_row <lgl>,
#> # label <chr>, estimate <dbl>, std.error <dbl>, statistic <dbl>,
#> # p.value <dbl>, conf.low <dbl>, conf.high <dbl>
test1 %>% tidy_and_attach() %>% tidy_add_n()
#> Error: Join columns must be present in data.
#> x Problem with `term`. Created on 2021-02-24 by the reprex package (v1.0.0) |
OK the problem comes from the fact that race is not coded as a factor. Easy solution: transform race before computing the model library(nnet)
library(MASS)
library(broom.helpers)
tmp <- birthwt
tmp$race <- factor(tmp$race)
test2 <- multinom(race ~ age + lwt + bwt, data = tmp)
#> # weights: 15 (8 variable)
#> initial value 207.637723
#> iter 10 value 168.608572
#> final value 168.587348
#> converged
test2 %>% tidy_plus_plus()
#> # A tibble: 6 x 19
#> y.level term variable var_label var_class var_type var_nlevels contrasts
#> <chr> <chr> <chr> <chr> <chr> <chr> <int> <chr>
#> 1 2 age age age integer continu~ NA <NA>
#> 2 2 lwt lwt lwt integer continu~ NA <NA>
#> 3 2 bwt bwt bwt integer continu~ NA <NA>
#> 4 3 age age age integer continu~ NA <NA>
#> 5 3 lwt lwt lwt integer continu~ NA <NA>
#> 6 3 bwt bwt bwt integer continu~ NA <NA>
#> # ... with 11 more variables: contrasts_type <chr>, reference_row <lgl>,
#> # label <chr>, n_obs <dbl>, n_event <dbl>, estimate <dbl>, std.error <dbl>,
#> # statistic <dbl>, p.value <dbl>, conf.low <dbl>, conf.high <dbl> Created on 2021-02-24 by the reprex package (v1.0.0) |
Should be fixed now library(nnet)
library(MASS)
library(broom.helpers)
test1 <- multinom(race ~ age + lwt + bwt, data = birthwt)
#> # weights: 15 (8 variable)
#> initial value 207.637723
#> iter 10 value 168.608572
#> final value 168.587348
#> converged
test1 %>% tidy_plus_plus()
#> # A tibble: 6 x 19
#> y.level term variable var_label var_class var_type var_nlevels contrasts
#> <chr> <chr> <chr> <chr> <chr> <chr> <int> <chr>
#> 1 2 age age age integer continu~ NA <NA>
#> 2 2 lwt lwt lwt integer continu~ NA <NA>
#> 3 2 bwt bwt bwt integer continu~ NA <NA>
#> 4 3 age age age integer continu~ NA <NA>
#> 5 3 lwt lwt lwt integer continu~ NA <NA>
#> 6 3 bwt bwt bwt integer continu~ NA <NA>
#> # ... with 11 more variables: contrasts_type <chr>, reference_row <lgl>,
#> # label <chr>, n_obs <dbl>, n_event <dbl>, estimate <dbl>, std.error <dbl>,
#> # statistic <dbl>, p.value <dbl>, conf.low <dbl>, conf.high <dbl> Created on 2021-02-24 by the reprex package (v1.0.0) |
Wowow, so fast! Thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey hey,
This issue was reported today for a multinomial model. I didn't get a chance to look into the details yet, but wanted to record it here.
Created on 2021-02-24 by the reprex package (v1.0.0)
The text was updated successfully, but these errors were encountered: