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

Problem using ggeffects for mclogit package #352

Open
gustavobrp opened this issue Jul 27, 2023 · 3 comments
Open

Problem using ggeffects for mclogit package #352

gustavobrp opened this issue Jul 27, 2023 · 3 comments
Labels
3 investigators ❔❓ bug 🐛 Something isn't working reprex 💾 An example (and data) to reproduce the issue is needed to

Comments

@gustavobrp
Copy link

Currently trying to use ggeffects for a mmblogit object from the mclogit package, but the following messages are being shown:

> ggeffects::ggeffect(model.example)
Can't compute marginal effects, 'effects::Effect()' returned an error.

Reason: 'arg' should be one of “PQL”, “MQL”
You may try 'ggpredict()' or 'ggemmeans()'.

Can't compute marginal effects, 'effects::Effect()' returned an error.

Reason: 'arg' should be one of “PQL”, “MQL”
You may try 'ggpredict()' or 'ggemmeans()'.

NULL
> ggeffects::ggpredict(model.example)
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : 
  contrasts can be applied only to factors with 2 or more levels
> ggeffects::ggemmeans(model.example)
Error: `terms` needs to be a character vector with at least one predictor name: one term used for the
  x-axis, more optional terms as grouping factors.

Here is a reprex from the database and the model. I'm using the uptaded versions of both packages. Note: the model converge in the complete dataset and model, and this happens using PQL or MQL method.

library(tidyverse)
#> Warning: package 'tidyverse' was built under R version 4.1.3
#> Warning: package 'ggplot2' was built under R version 4.1.3
#> Warning: package 'tibble' was built under R version 4.1.3
#> Warning: package 'tidyr' was built under R version 4.1.3
#> Warning: package 'readr' was built under R version 4.1.3
#> Warning: package 'purrr' was built under R version 4.1.3
#> Warning: package 'dplyr' was built under R version 4.1.3
#> Warning: package 'stringr' was built under R version 4.1.3
#> Warning: package 'forcats' was built under R version 4.1.3
#> Warning: package 'lubridate' was built under R version 4.1.3
library(mclogit)
#> Loading required package: Matrix
#> Warning: package 'Matrix' was built under R version 4.1.3
#> 
#> Attaching package: 'Matrix'
#> The following objects are masked from 'package:tidyr':
#> 
#>     expand, pack, unpack
library(ggeffects)

db.example <- structure(list(dep_resultado_academico = structure(c(3L, 2L, 
                                                                   1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 3L, 1L, 1L, 
                                                                   3L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 3L, 3L, 2L, 2L, 2L, 1L, 2L, 
                                                                   3L, 2L, 2L, 2L, 3L, 1L), .Label = c("Cursando", "Graduado", "Evasão"
                                                                   ), class = "factor"), faixa_idade = structure(c(3L, 2L, 2L, 3L, 
                                                                                                                   1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
                                                                                                                   2L, 1L, 2L, 2L, 2L, 2L, 2L, 4L, 2L, 2L, 2L, 3L, 2L, 2L, 1L, 3L, 
                                                                                                                   2L, 2L, 1L, 1L), .Label = c("Até 18 anos", "Entre 19 e 24 anos", 
                                                                                                                                               "Entre 25 e 29 anos", "30 anos ou mais"), class = "factor"), 
                             SEXO = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 
                                                1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 
                                                1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L
                             ), .Label = c("Masculino", "Feminino"), class = "factor"), 
                             CURSO_ATUAL = structure(c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
                                                       2L, 1L, 1L, 1L, 1L, 2L, 3L, 3L, 2L, 4L, 5L, 5L, 5L, 5L, 6L, 
                                                       6L, 6L, 7L, 8L, 4L, 9L, 5L, 5L, 5L, 1L, 1L, 1L, 10L, 10L, 
                                                       9L, 9L, 9L), .Label = c("Letras", "Medicina", "Engenharia Química", 
                                                                               "Pedagogia", "Direito", "Enfermagem", "Engenharia Civil", 
                                                                               "Engenharia Mecânica", "Psicologia", "Geografia", "Odontologia", 
                                                                               "Educação Física", "Administração", "Engenharia Elétrica", 
                                                                               "Geologia", "Ciências Biológicas", "Comunicação Social", 
                                                                               "Arquitetura e Urbanismo", "Engenharia de Produção", "Artes Visuais", 
                                                                               "Biblioteconomia", "História", "Farmácia", "Filosofia", "Medicina Veterinária", 
                                                                               "Matemática", "Ciências Contábeis", "Engenharia de Minas", 
                                                                               "Química", "Física", "Ciências Sociais", "Engenharia de Controle e Automação", 
                                                                               "Ciências Econômicas", "Engenharia Metalúrgica", "Fisioterapia", 
                                                                               "Terapia Ocupacional", "Fonoaudiologia", "Turismo", "Nutrição", 
                                                                               "Ciência da Computação", "Ciências Atuariais", "Estatística", 
                                                                               "Sistemas de Informação"), class = "factor")), row.names = c(NA, 
                                                                                                                                            -40L), class = c("tbl_df", "tbl", "data.frame"))

model.example <- mblogit(dep_resultado_academico ~ faixa_idade + SEXO, 
                 data = db.example,
                 random = c(~1|CURSO_ATUAL),
                 method = "MQL",
                 estimator = "REML",
                 maxit = 20)
#> 
#> Iteration 1 - deviance = 106.9198 - criterion = 1.029838
#> Iteration 2 - deviance = 117.4668 - criterion = 0.1434256
#> Iteration 3 - deviance = 120.2036 - criterion = 0.08122211
#> Iteration 4 - deviance = 119.9487 - criterion = 0.05115243
#> Iteration 5 - deviance = 122.9978 - criterion = 0.04380277
#> Iteration 6 - deviance = 120.1087 - criterion = 0.02562604
#> Iteration 7 - deviance = 122.7511 - criterion = 0.02329051
#> Iteration 8 - deviance = 120.0579 - criterion = 0.01496665
#> Iteration 9 - deviance = 122.5763 - criterion = 0.01425761
#> Iteration 10 - deviance = 120.0299 - criterion = 0.009791495
#> Iteration 11 - deviance = 122.4501 - criterion = 0.009594708
#> Iteration 12 - deviance = 120.0111 - criterion = 0.006903091
#> Iteration 13 - deviance = 122.4977 - criterion = 0.007190019
#> Iteration 14 - deviance = 120.0471 - criterion = 0.005561767
#> Iteration 15 - deviance = 120.4887 - criterion = 0.001793266
#> Iteration 16 - deviance = 122.1066 - criterion = 0.002193508
#> Iteration 17 - deviance = 121.6214 - criterion = 0.001708503
#> Iteration 18 - deviance = 122.5464 - criterion = 0.001892841
#> Iteration 19 - deviance = 121.7983 - criterion = 0.001469536
#> Iteration 20 - deviance = 122.5543 - criterion = 0.001601244
#> Warning: Algorithm did not converge
#> Warning: Fitted probabilities numerically 0 occurred


ggeffects::ggeffect(model.example)
#> Can't compute marginal effects, 'effects::Effect()' returned an error.
#> 
#> Reason: 'arg' should be one of "PQL", "MQL"
#> You may try 'ggpredict()' or 'ggemmeans()'.
#> 
#> Can't compute marginal effects, 'effects::Effect()' returned an error.
#> 
#> Reason: 'arg' should be one of "PQL", "MQL"
#> You may try 'ggpredict()' or 'ggemmeans()'.
#> NULL

ggeffects::ggpredict(model.example)
#> Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]): contrasts can be applied only to factors with 2 or more levels

ggeffects::ggemmeans(model.example)
#> Error: `terms` needs to be a character vector with at least one predictor name:
#>   one term used for the x-axis, more optional terms as grouping factors.

Created on 2023-07-27 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value
#>  version  R version 4.1.1 (2021-08-10)
#>  os       Windows 10 x64 (build 22621)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  Portuguese_Brazil.1252
#>  ctype    Portuguese_Brazil.1252
#>  tz       America/Sao_Paulo
#>  date     2023-07-27
#>  pandoc   2.19.2 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> - Packages -------------------------------------------------------------------
#>  package      * version   date (UTC) lib source
#>  abind          1.4-5     2016-07-21 [1] CRAN (R 4.1.1)
#>  boot           1.3-28    2021-05-03 [2] CRAN (R 4.1.1)
#>  car            3.1-1     2022-10-19 [1] CRAN (R 4.1.1)
#>  carData        3.0-5     2022-01-06 [1] CRAN (R 4.1.3)
#>  cli            3.6.1     2023-03-23 [1] CRAN (R 4.1.3)
#>  coda           0.19-4    2020-09-30 [1] CRAN (R 4.1.1)
#>  codetools      0.2-18    2020-11-04 [2] CRAN (R 4.1.1)
#>  colorspace     2.0-3     2022-02-21 [1] CRAN (R 4.1.3)
#>  data.table     1.14.8    2023-02-17 [1] CRAN (R 4.1.3)
#>  DBI            1.1.3     2022-06-18 [1] CRAN (R 4.1.3)
#>  digest         0.6.29    2021-12-01 [1] CRAN (R 4.1.3)
#>  dplyr        * 1.1.2     2023-04-20 [1] CRAN (R 4.1.3)
#>  effects        4.2-2     2022-07-13 [1] CRAN (R 4.1.3)
#>  ellipsis       0.3.2     2021-04-29 [1] CRAN (R 4.1.0)
#>  emmeans        1.8.1-1   2022-09-08 [1] CRAN (R 4.1.3)
#>  estimability   1.4.1     2022-08-05 [1] CRAN (R 4.1.3)
#>  evaluate       0.17      2022-10-07 [1] CRAN (R 4.1.3)
#>  fansi          1.0.3     2022-03-24 [1] CRAN (R 4.1.3)
#>  fastmap        1.1.0     2021-01-25 [1] CRAN (R 4.1.0)
#>  forcats      * 1.0.0     2023-01-29 [1] CRAN (R 4.1.3)
#>  fs             1.5.2     2021-12-08 [1] CRAN (R 4.1.3)
#>  generics       0.1.3     2022-07-05 [1] CRAN (R 4.1.3)
#>  ggeffects    * 1.2.3     2023-06-11 [1] CRAN (R 4.1.1)
#>  ggplot2      * 3.4.2     2023-04-03 [1] CRAN (R 4.1.3)
#>  glue           1.6.2     2022-02-24 [1] CRAN (R 4.1.3)
#>  gtable         0.3.1     2022-09-01 [1] CRAN (R 4.1.3)
#>  highr          0.9       2021-04-16 [1] CRAN (R 4.1.0)
#>  hms            1.1.2     2022-08-19 [1] CRAN (R 4.1.3)
#>  htmltools      0.5.3     2022-07-18 [1] CRAN (R 4.1.3)
#>  insight        0.19.3    2023-06-29 [1] CRAN (R 4.1.1)
#>  jsonlite       1.8.4     2022-12-06 [1] CRAN (R 4.1.3)
#>  knitr          1.40      2022-08-24 [1] CRAN (R 4.1.3)
#>  lattice        0.20-44   2021-05-02 [2] CRAN (R 4.1.1)
#>  lifecycle      1.0.3     2022-10-07 [1] CRAN (R 4.1.3)
#>  lme4           1.1-30    2022-07-08 [1] CRAN (R 4.1.3)
#>  lubridate    * 1.9.2     2023-02-10 [1] CRAN (R 4.1.3)
#>  magrittr       2.0.3     2022-03-30 [1] CRAN (R 4.1.3)
#>  MASS           7.3-54    2021-05-03 [2] CRAN (R 4.1.1)
#>  Matrix       * 1.5-1     2022-09-13 [1] CRAN (R 4.1.3)
#>  mclogit      * 0.9.4.2   2023-07-26 [1] local
#>  memisc         0.99.31.6 2023-03-10 [1] CRAN (R 4.1.3)
#>  minqa          1.2.4     2014-10-09 [1] CRAN (R 4.1.3)
#>  mitools        2.4       2019-04-26 [1] CRAN (R 4.1.2)
#>  multcomp       1.4-22    2023-02-10 [1] CRAN (R 4.1.3)
#>  munsell        0.5.0     2018-06-12 [1] CRAN (R 4.1.0)
#>  mvtnorm        1.1-3     2021-10-08 [1] CRAN (R 4.1.1)
#>  nlme           3.1-152   2021-02-04 [2] CRAN (R 4.1.1)
#>  nloptr         2.0.3     2022-05-26 [1] CRAN (R 4.1.3)
#>  nnet           7.3-18    2022-09-28 [1] CRAN (R 4.1.3)
#>  pillar         1.9.0     2023-03-22 [1] CRAN (R 4.1.3)
#>  pkgconfig      2.0.3     2019-09-22 [1] CRAN (R 4.1.0)
#>  purrr        * 1.0.1     2023-01-10 [1] CRAN (R 4.1.3)
#>  R.cache        0.16.0    2022-07-21 [1] CRAN (R 4.1.3)
#>  R.methodsS3    1.8.2     2022-06-13 [1] CRAN (R 4.1.3)
#>  R.oo           1.25.0    2022-06-12 [1] CRAN (R 4.1.3)
#>  R.utils        2.12.2    2022-11-11 [1] CRAN (R 4.1.3)
#>  R6             2.5.1     2021-08-19 [1] CRAN (R 4.1.1)
#>  Rcpp           1.0.9     2022-07-08 [1] CRAN (R 4.1.3)
#>  readr        * 2.1.4     2023-02-10 [1] CRAN (R 4.1.3)
#>  reprex         2.0.2     2022-08-17 [1] CRAN (R 4.1.3)
#>  rlang          1.1.0     2023-03-14 [1] CRAN (R 4.1.3)
#>  rmarkdown      2.17      2022-10-07 [1] CRAN (R 4.1.3)
#>  rstudioapi     0.14      2022-08-22 [1] CRAN (R 4.1.3)
#>  sandwich       3.0-2     2022-06-15 [1] CRAN (R 4.1.3)
#>  scales         1.2.1     2022-08-20 [1] CRAN (R 4.1.3)
#>  sessioninfo    1.2.2     2021-12-06 [1] CRAN (R 4.1.3)
#>  stringi        1.7.6     2021-11-29 [1] CRAN (R 4.1.2)
#>  stringr      * 1.5.0     2022-12-02 [1] CRAN (R 4.1.3)
#>  styler         1.10.1    2023-06-05 [1] CRAN (R 4.1.1)
#>  survey         4.1-1     2021-07-19 [1] CRAN (R 4.1.3)
#>  survival       3.4-0     2022-08-09 [1] CRAN (R 4.1.3)
#>  TH.data        1.1-1     2022-04-26 [1] CRAN (R 4.1.3)
#>  tibble       * 3.2.1     2023-03-20 [1] CRAN (R 4.1.3)
#>  tidyr        * 1.3.0     2023-01-24 [1] CRAN (R 4.1.3)
#>  tidyselect     1.2.0     2022-10-10 [1] CRAN (R 4.1.1)
#>  tidyverse    * 2.0.0     2023-02-22 [1] CRAN (R 4.1.3)
#>  timechange     0.2.0     2023-01-11 [1] CRAN (R 4.1.3)
#>  tzdb           0.3.0     2022-03-28 [1] CRAN (R 4.1.3)
#>  utf8           1.2.2     2021-07-24 [1] CRAN (R 4.1.0)
#>  vctrs          0.6.1     2023-03-22 [1] CRAN (R 4.1.3)
#>  withr          2.5.0     2022-03-03 [1] CRAN (R 4.1.3)
#>  xfun           0.33      2022-09-12 [1] CRAN (R 4.1.3)
#>  xtable         1.8-4     2019-04-21 [1] CRAN (R 4.1.0)
#>  yaml           2.3.7     2023-01-23 [1] CRAN (R 4.1.3)
#>  zoo            1.8-11    2022-09-17 [1] CRAN (R 4.1.3)
#> 
#> 
#> ------------------------------------------------------------------------------
@strengejacke
Copy link
Owner

I cannot reproduce your example, the model gives an error:

library(mclogit)
#> Loading required package: Matrix
library(ggeffects)

db.example <- structure(list(dep_resultado_academico = structure(c(3L, 2L, 
                                                                   1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 3L, 1L, 1L, 
                                                                   3L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 3L, 3L, 2L, 2L, 2L, 1L, 2L, 
                                                                   3L, 2L, 2L, 2L, 3L, 1L), .Label = c("Cursando", "Graduado", "Evasão"
                                                                   ), class = "factor"), faixa_idade = structure(c(3L, 2L, 2L, 3L, 
                                                                                                                   1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
                                                                                                                   2L, 1L, 2L, 2L, 2L, 2L, 2L, 4L, 2L, 2L, 2L, 3L, 2L, 2L, 1L, 3L, 
                                                                                                                   2L, 2L, 1L, 1L), .Label = c("Até 18 anos", "Entre 19 e 24 anos", 
                                                                                                                                               "Entre 25 e 29 anos", "30 anos ou mais"), class = "factor"), 
                             SEXO = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 
                                                1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 
                                                1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L
                             ), .Label = c("Masculino", "Feminino"), class = "factor"), 
                             CURSO_ATUAL = structure(c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
                                                       2L, 1L, 1L, 1L, 1L, 2L, 3L, 3L, 2L, 4L, 5L, 5L, 5L, 5L, 6L, 
                                                       6L, 6L, 7L, 8L, 4L, 9L, 5L, 5L, 5L, 1L, 1L, 1L, 10L, 10L, 
                                                       9L, 9L, 9L), .Label = c("Letras", "Medicina", "Engenharia Química", 
                                                                               "Pedagogia", "Direito", "Enfermagem", "Engenharia Civil", 
                                                                               "Engenharia Mecânica", "Psicologia", "Geografia", "Odontologia", 
                                                                               "Educação Física", "Administração", "Engenharia Elétrica", 
                                                                               "Geologia", "Ciências Biológicas", "Comunicação Social", 
                                                                               "Arquitetura e Urbanismo", "Engenharia de Produção", "Artes Visuais", 
                                                                               "Biblioteconomia", "História", "Farmácia", "Filosofia", "Medicina Veterinária", 
                                                                               "Matemática", "Ciências Contábeis", "Engenharia de Minas", 
                                                                               "Química", "Física", "Ciências Sociais", "Engenharia de Controle e Automação", 
                                                                               "Ciências Econômicas", "Engenharia Metalúrgica", "Fisioterapia", 
                                                                               "Terapia Ocupacional", "Fonoaudiologia", "Turismo", "Nutrição", 
                                                                               "Ciência da Computação", "Ciências Atuariais", "Estatística", 
                                                                               "Sistemas de Informação"), class = "factor")), row.names = c(NA, 
                                                                                                                                            -40L), class = c("tbl_df", "tbl", "data.frame"))

model.example <- mblogit(dep_resultado_academico ~ faixa_idade + SEXO, 
                 data = db.example,
                 random = c(~1|CURSO_ATUAL),
                 method = "MQL",
                 estimator = "REML",
                 maxit = 20)
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 1 - deviance = 109.3839 - criterion = 1.033022
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 2 - deviance = 120.908 - criterion = 0.1304513
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 3 - deviance = 119.6012 - criterion = 0.04783325
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 4 - deviance = 119.6994 - criterion = 0.03275368
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 5 - deviance = 119.7083 - criterion = 0.02436854
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 6 - deviance = 119.6681 - criterion = 0.01883837
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 7 - deviance = 119.684 - criterion = 0.01487719
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 8 - deviance = 119.6689 - criterion = 0.0120209
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 9 - deviance = 119.6765 - criterion = 0.009879401
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 10 - deviance = 119.6706 - criterion = 0.008252256
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 11 - deviance = 119.674 - criterion = 0.006984561
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 12 - deviance = 119.6716 - criterion = 0.005983284
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 13 - deviance = 119.6731 - criterion = 0.005178449
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 14 - deviance = 119.6721 - criterion = 0.004523611
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 15 - deviance = 119.6728 - criterion = 0.003981716
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 16 - deviance = 119.6723 - criterion = 0.003526526
#> Error in .solve.checkCond(a, tol): 'a' is computationally singular, rcond(a)=1.0131e-16

summary(model.example)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'object' in selecting a method for function 'summary': object 'model.example' not found

Created on 2023-08-30 with reprex v2.0.2

@strengejacke strengejacke added the reprex 💾 An example (and data) to reproduce the issue is needed to label Aug 30, 2023
@gustavobrp
Copy link
Author

Hi Daniel.

I tested again here and the model worked, strange. What can I do to help?

I'm using the lastest version of mclogit() and ggeffects().

mclogit() gives the warning that the algorithm did not converge here, but it works, and when I try to use ggeffects() the problem persists.

library(mclogit)
#> Loading required package: Matrix
library(ggeffects)

db.example <- structure(list(dep_resultado_academico = structure(c(3L, 2L, 
                                                                   1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 3L, 1L, 1L, 
                                                                   3L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 3L, 3L, 2L, 2L, 2L, 1L, 2L, 
                                                                   3L, 2L, 2L, 2L, 3L, 1L), .Label = c("Cursando", "Graduado", "Evasão"
                                                                   ), class = "factor"), faixa_idade = structure(c(3L, 2L, 2L, 3L, 
                                                                                                                   1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
                                                                                                                   2L, 1L, 2L, 2L, 2L, 2L, 2L, 4L, 2L, 2L, 2L, 3L, 2L, 2L, 1L, 3L, 
                                                                                                                   2L, 2L, 1L, 1L), .Label = c("Até 18 anos", "Entre 19 e 24 anos", 
                                                                                                                                               "Entre 25 e 29 anos", "30 anos ou mais"), class = "factor"), 
                             SEXO = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 
                                                1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 
                                                1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L
                             ), .Label = c("Masculino", "Feminino"), class = "factor"), 
                             CURSO_ATUAL = structure(c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
                                                       2L, 1L, 1L, 1L, 1L, 2L, 3L, 3L, 2L, 4L, 5L, 5L, 5L, 5L, 6L, 
                                                       6L, 6L, 7L, 8L, 4L, 9L, 5L, 5L, 5L, 1L, 1L, 1L, 10L, 10L, 
                                                       9L, 9L, 9L), .Label = c("Letras", "Medicina", "Engenharia Química", 
                                                                               "Pedagogia", "Direito", "Enfermagem", "Engenharia Civil", 
                                                                               "Engenharia Mecânica", "Psicologia", "Geografia", "Odontologia", 
                                                                               "Educação Física", "Administração", "Engenharia Elétrica", 
                                                                               "Geologia", "Ciências Biológicas", "Comunicação Social", 
                                                                               "Arquitetura e Urbanismo", "Engenharia de Produção", "Artes Visuais", 
                                                                               "Biblioteconomia", "História", "Farmácia", "Filosofia", "Medicina Veterinária", 
                                                                               "Matemática", "Ciências Contábeis", "Engenharia de Minas", 
                                                                               "Química", "Física", "Ciências Sociais", "Engenharia de Controle e Automação", 
                                                                               "Ciências Econômicas", "Engenharia Metalúrgica", "Fisioterapia", 
                                                                               "Terapia Ocupacional", "Fonoaudiologia", "Turismo", "Nutrição", 
                                                                               "Ciência da Computação", "Ciências Atuariais", "Estatística", 
                                                                               "Sistemas de Informação"), class = "factor")), row.names = c(NA, 
                                                                                                                                            -40L), class = c("tbl_df", "tbl", "data.frame"))


model.example <- mblogit(dep_resultado_academico ~ faixa_idade + SEXO, 
                         data = db.example,
                         random = c(~1|CURSO_ATUAL),
                         method = "MQL",
                         estimator = "REML",
                         maxit = 20)
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 1 - deviance = 109.3839 - criterion = 1.033022
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 2 - deviance = 120.908 - criterion = 0.1304513
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 3 - deviance = 119.6012 - criterion = 0.04783325
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 4 - deviance = 119.6994 - criterion = 0.03275368
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 5 - deviance = 119.7083 - criterion = 0.02436854
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 6 - deviance = 119.6681 - criterion = 0.01883837
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 7 - deviance = 119.684 - criterion = 0.01487719
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 8 - deviance = 119.6689 - criterion = 0.0120209
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 9 - deviance = 119.6765 - criterion = 0.009879401
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 10 - deviance = 119.6706 - criterion = 0.008252256
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 11 - deviance = 119.674 - criterion = 0.006984559
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 12 - deviance = 119.6716 - criterion = 0.005983286
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 13 - deviance = 119.6731 - criterion = 0.005178275
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 14 - deviance = 119.6721 - criterion = 0.004523205
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 15 - deviance = 119.6728 - criterion = 0.003982371
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 16 - deviance = 119.6723 - criterion = 0.003511752
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 17 - deviance = 119.6726 - criterion = 0.003164549
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 18 - deviance = 119.6724 - criterion = 0.002484265
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 19 - deviance = 119.6725 - criterion = 0.001902648
#> Warning: Inner iterations did not coverge - nlminb message: false convergence
#> (8)
#> 
#> Iteration 20 - deviance = 119.6725 - criterion = 0.0006252818
#> Warning: Algorithm did not converge
#> Warning: Fitted probabilities numerically 0 or 1 occurred

ggeffect(model.example)
#> Can't compute marginal effects, `effects::Effect()` returned an error.
#> 
#> Reason: unused argument (qr = TRUE)
#> You may try `ggpredict()` or `ggemmeans()`.
#> 
#> Can't compute marginal effects, `effects::Effect()` returned an error.
#> 
#> Reason: unused argument (qr = TRUE)
#> You may try `ggpredict()` or `ggemmeans()`.
#> NULL

Created on 2023-08-30 with [reprex v2.0.2](https://reprex.tidyverse.org/)

@strengejacke
Copy link
Owner

Can you save the model object (in RData or RDS format), zip it and attach it to this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 investigators ❔❓ bug 🐛 Something isn't working reprex 💾 An example (and data) to reproduce the issue is needed to
Projects
None yet
Development

No branches or pull requests

2 participants