broom currently doesn't support mclogit objects. But because these objects also inherit lm, the tidier seems to work.
# setup
set.seed(123)
library(mclogit)
#> Loading required package: Matrix
data(electors)
# model
mod <- mclogit::mclogit(
formula = cbind(Freq, interaction(time, class)) ~ econ.left / class + welfare / class + auth / class,
random = ~ 1 | party.time,
data = within(electors, party.time <- interaction(party, time))
)
#> Fitting plain conditional logit to obtain starting values
#> Iteration 1 - Deviance = 7377.939
#> Iteration 2 - Deviance = 4589.544
#> Iteration 3 - Deviance = 4293.485
#> Iteration 4 - Deviance = 4277.887
#> Iteration 5 - Deviance = 4277.808
#> Iteration 6 - Deviance = 4277.808
#> converged
#> Fitting random effects/random coefficients model
#> Iteration 1 - Deviance = 1876.788
#> Iteration 2 - Deviance = 1212.004
#> Iteration 3 - Deviance = 1009.8
#> Iteration 4 - Deviance = 958.7431
#> Iteration 5 - Deviance = 949.4332
#> Iteration 6 - Deviance = 948.1453
#> Iteration 7 - Deviance = 947.9013
#> Iteration 8 - Deviance = 947.8442
#> Iteration 9 - Deviance = 947.8329
#> Iteration 10 - Deviance = 947.8308
#> Iteration 11 - Deviance = 947.8305
#> Iteration 12 - Deviance = 947.8304
#> Iteration 13 - Deviance = 947.8304
#> Iteration 14 - Deviance = 947.8304
#> converged
# class of objects
class(mod)
#> [1] "mmclogit" "mclogit" "lm"
# tidier?
broom::tidy(mod)
#> # A tibble: 9 x 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 econ.left -0.172 0.138 -1.25 2.12e- 1
#> 2 welfare 2.05 0.214 9.58 9.71e- 22
#> 3 auth 0.0817 0.118 0.691 4.89e- 1
#> 4 econ.left:classnew.middle -1.67 0.0880 -19.0 3.61e- 80
#> 5 econ.left:classold.middle -2.97 0.149 -19.9 4.56e- 88
#> 6 classnew.middle:welfare -0.989 0.0609 -16.2 2.30e- 59
#> 7 classold.middle:welfare -1.62 0.129 -12.6 3.82e- 36
#> 8 classnew.middle:auth -1.39 0.0468 -29.8 1.64e-194
#> 9 classold.middle:auth 1.46 0.0582 25.0 2.05e-138
But it has trouble computing confidence intervals because the underlying method from stats fails:
# confidence intervals?
broom::tidy(mod, conf.int = TRUE)
#> Error in qt(a, object$df.residual): Non-numeric argument to mathematical function
# is there even a method for this?
confint(mod)
#> Error in qt(a, object$df.residual): Non-numeric argument to mathematical function
The glance and augment methods also fail:
# glance?
broom::glance(mod)
#> Error in eval_tidy(xs[[i]], unique_output): object 'r.squared' not found
# augment?
broom::augment(mod, data = electors)
#> Error: Can't augment data with observation level measures.
#> Did you provide `data` with the exact data used for model fitting?
Created on 2019-08-09 by the reprex package (v0.3.0)
Session info
devtools::session_info()
#> - Session info ----------------------------------------------------------
#> setting value
#> version R version 3.6.1 (2019-07-05)
#> os Windows 10 x64
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate English_United States.1252
#> ctype English_United States.1252
#> tz America/New_York
#> date 2019-08-09
#>
#> - Packages --------------------------------------------------------------
#> package * version date lib
#> abind 1.4-5 2016-07-21 [1]
#> assertthat 0.2.1 2019-03-21 [1]
#> backports 1.1.4 2019-04-10 [1]
#> base64enc 0.1-3 2015-07-28 [1]
#> broom 0.5.2.9002 2019-08-08 [1]
#> callr 3.3.1 2019-07-18 [1]
#> car 3.0-3 2019-05-27 [1]
#> carData 3.0-2 2018-09-30 [1]
#> cellranger 1.1.0 2016-07-27 [1]
#> cli 1.1.0 2019-03-19 [1]
#> crayon 1.3.4 2017-09-16 [1]
#> curl 4.0 2019-07-22 [1]
#> data.table 1.12.2 2019-04-07 [1]
#> desc 1.2.0 2019-04-03 [1]
#> devtools 2.1.0 2019-07-06 [1]
#> digest 0.6.20 2019-07-04 [1]
#> dplyr 0.8.3 2019-07-04 [1]
#> evaluate 0.14 2019-05-28 [1]
#> fansi 0.4.0 2018-11-05 [1]
#> forcats 0.4.0 2019-02-17 [1]
#> foreign 0.8-71 2018-07-20 [2]
#> fs 1.3.1 2019-05-06 [1]
#> generics 0.0.2 2019-03-05 [1]
#> glue 1.3.1 2019-03-12 [1]
#> haven 2.1.1 2019-07-04 [1]
#> highr 0.8 2019-03-20 [1]
#> hms 0.5.0 2019-07-09 [1]
#> htmltools 0.3.6 2017-04-28 [1]
#> jsonlite 1.6 2018-12-07 [1]
#> knitr 1.24 2019-08-08 [1]
#> lattice 0.20-38 2018-11-04 [2]
#> magrittr 1.5 2014-11-22 [1]
#> MASS 7.3-51.4 2019-03-31 [1]
#> Matrix * 1.2-17 2019-03-22 [1]
#> mclogit * 0.6.1 2018-09-27 [1]
#> memisc 0.99.17.2 2019-04-24 [1]
#> memoise 1.1.0 2017-04-21 [1]
#> openxlsx 4.1.0.1 2019-05-28 [1]
#> pillar 1.4.2 2019-06-29 [1]
#> pkgbuild 1.0.4 2019-08-05 [1]
#> pkgconfig 2.0.2 2018-08-16 [1]
#> pkgload 1.0.2 2018-10-29 [1]
#> prettyunits 1.0.2 2015-07-13 [1]
#> processx 3.4.1 2019-07-18 [1]
#> ps 1.3.0 2018-12-21 [1]
#> purrr 0.3.2 2019-03-15 [1]
#> R6 2.4.0 2019-02-14 [1]
#> Rcpp 1.0.2 2019-07-25 [1]
#> readxl 1.3.1 2019-03-13 [1]
#> remotes 2.1.0 2019-06-24 [1]
#> repr 1.0.1 2019-05-14 [1]
#> rio 0.5.16 2018-11-26 [1]
#> rlang 0.4.0 2019-06-25 [1]
#> rmarkdown 1.14.3 2019-08-02 [1]
#> rprojroot 1.3-2 2018-01-03 [1]
#> sessioninfo 1.1.1 2018-11-05 [1]
#> stringi 1.4.3 2019-03-12 [1]
#> stringr 1.4.0 2019-02-10 [1]
#> testthat 2.2.1 2019-07-25 [1]
#> tibble 2.1.3 2019-06-06 [1]
#> tidyr 0.8.3 2019-03-01 [1]
#> tidyselect 0.2.5 2018-10-11 [1]
#> usethis 1.5.1.9000 2019-07-27 [1]
#> utf8 1.1.4 2018-05-24 [1]
#> vctrs 0.2.0 2019-07-05 [1]
#> withr 2.1.2 2018-03-15 [1]
#> xfun 0.8 2019-06-25 [1]
#> yaml 2.2.0 2018-07-25 [1]
#> zeallot 0.1.0 2018-01-28 [1]
#> zip 2.0.3 2019-07-03 [1]
#> source
#> CRAN (R 3.5.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.5.0)
#> local
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.1)
#> CRAN (R 3.5.3)
#> Github (r-lib/desc@c860e7b)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> Github (brodieG/fansi@ab11e9c)
#> CRAN (R 3.5.2)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.0)
#> Github (r-lib/generics@c15ac43)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> Github (rstudio/rmarkdown@37bcb8f)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.1)
#> CRAN (R 3.5.1)
#> Github (r-lib/usethis@b241420)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.0)
#>
#> [1] C:/Users/inp099/Documents/R/win-library/3.6
#> [2] C:/Program Files/R/R-3.6.1/library
broomcurrently doesn't supportmclogitobjects. But because these objects also inheritlm, the tidier seems to work.But it has trouble computing confidence intervals because the underlying method from
statsfails:The
glanceandaugmentmethods also fail:Created on 2019-08-09 by the reprex package (v0.3.0)
Session info