strengejacke / sjPlot

sjPlot - Data Visualization for Statistics in Social Science
https://strengejacke.github.io/sjPlot
611 stars 93 forks source link

plot_model and tab_model not working for conditional logistic regressions #592

Closed temuulene closed 4 years ago

temuulene commented 4 years ago

I keep getting following errors when trying to use plot_model and tab_model to display estimates from survival::clogit models.

library(survival)
library(sjPlot)
#> Learn more about sjPlot with 'browseVignettes("sjPlot")'.

logan <- survival::logan
resp <- levels(logan$occupation)
n <- nrow(logan)
indx <- rep(1:n, length(resp))
logan2 <- data.frame(logan[indx,],
                     id = indx,
                     tocc = factor(rep(resp, each=n)))
logan2$case <- (logan2$occupation == logan2$tocc)
m <- clogit(case ~ tocc + tocc:education + strata(id), logan2)

plot_model(m)
#> Warning in colnames(mf)[1:2] <- rn_not_combined: number of items to replace is
#> not a multiple of replacement length

#> Warning in colnames(mf)[1:2] <- rn_not_combined: number of items to replace is
#> not a multiple of replacement length
#> Error in gsub("Statistic", gsub("-statistic", "", attr(statistic, "statistic", : invalid 'replacement' argument
tab_model(m)
#> Error in gsub("Statistic", gsub("-statistic", "", attr(statistic, "statistic", : invalid 'replacement' argument

Created on 2020-02-06 by the reprex package (v0.3.0)

Session info ``` r devtools::session_info() #> - Session info --------------------------------------------------------------- #> setting value #> version R version 3.6.2 (2019-12-12) #> os Windows 10 x64 #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate English_United States.1252 #> ctype English_United States.1252 #> tz America/Los_Angeles #> date 2020-02-06 #> #> - Packages ------------------------------------------------------------------- #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0) #> backports 1.1.5 2019-10-02 [1] CRAN (R 3.6.1) #> bayestestR 0.5.1 2020-01-27 [1] CRAN (R 3.6.2) #> boot 1.3-24 2019-12-20 [1] CRAN (R 3.6.2) #> broom 0.5.4 2020-01-27 [1] CRAN (R 3.6.2) #> callr 3.4.1 2020-01-24 [1] CRAN (R 3.6.2) #> cli 2.0.1 2020-01-08 [1] CRAN (R 3.6.2) #> coda 0.19-3 2019-07-05 [1] CRAN (R 3.6.0) #> codetools 0.2-16 2018-12-24 [2] CRAN (R 3.6.2) #> colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.6.0) #> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0) #> desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.0) #> devtools 2.2.1 2019-09-24 [1] CRAN (R 3.6.1) #> digest 0.6.23 2019-11-23 [1] CRAN (R 3.6.1) #> dplyr 0.8.4 2020-01-31 [1] CRAN (R 3.6.2) #> effectsize 0.1.1 2020-01-27 [1] CRAN (R 3.6.2) #> ellipsis 0.3.0 2019-09-20 [1] CRAN (R 3.6.1) #> emmeans 1.4.4 2020-01-28 [1] CRAN (R 3.6.2) #> estimability 1.3 2018-02-11 [1] CRAN (R 3.6.0) #> evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.0) #> fansi 0.4.1 2020-01-08 [1] CRAN (R 3.6.2) #> forcats 0.4.0 2019-02-17 [1] CRAN (R 3.6.0) #> fs 1.3.1 2019-05-06 [1] CRAN (R 3.6.0) #> generics 0.0.2 2018-11-29 [1] CRAN (R 3.6.0) #> ggeffects 0.14.1 2020-01-28 [1] CRAN (R 3.6.2) #> ggplot2 3.2.1 2019-08-10 [1] CRAN (R 3.6.1) #> glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.0) #> gtable 0.3.0 2019-03-25 [1] CRAN (R 3.6.0) #> haven 2.2.0 2019-11-08 [1] CRAN (R 3.6.2) #> highr 0.8 2019-03-20 [1] CRAN (R 3.6.0) #> hms 0.5.3 2020-01-08 [1] CRAN (R 3.6.2) #> htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.2) #> insight 0.8.1 2020-02-02 [1] CRAN (R 3.6.2) #> knitr 1.28 2020-02-06 [1] CRAN (R 3.6.2) #> lattice 0.20-38 2018-11-04 [1] CRAN (R 3.6.0) #> lazyeval 0.2.2 2019-03-15 [1] CRAN (R 3.6.0) #> lifecycle 0.1.0 2019-08-01 [1] CRAN (R 3.6.1) #> lme4 1.1-21 2019-03-05 [1] CRAN (R 3.6.0) #> magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0) #> MASS 7.3-51.4 2019-03-31 [2] CRAN (R 3.6.2) #> Matrix 1.2-18 2019-11-27 [2] CRAN (R 3.6.2) #> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.6.0) #> minqa 1.2.4 2014-10-09 [1] CRAN (R 3.6.0) #> modelr 0.1.5 2019-08-08 [1] CRAN (R 3.6.1) #> multcomp 1.4-12 2020-01-10 [1] CRAN (R 3.6.2) #> munsell 0.5.0 2018-06-12 [1] CRAN (R 3.6.0) #> mvtnorm 1.0-12 2020-01-09 [1] CRAN (R 3.6.2) #> nlme 3.1-142 2019-11-07 [2] CRAN (R 3.6.2) #> nloptr 1.2.1 2018-10-03 [1] CRAN (R 3.6.0) #> parameters 0.4.1 2020-01-17 [1] CRAN (R 3.6.2) #> performance 0.4.3 2020-01-22 [1] CRAN (R 3.6.2) #> pillar 1.4.3 2019-12-20 [1] CRAN (R 3.6.2) #> pkgbuild 1.0.6 2019-10-09 [1] CRAN (R 3.6.1) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.1) #> pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.6.0) #> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 3.6.2) #> processx 3.4.1 2019-07-18 [1] CRAN (R 3.6.1) #> ps 1.3.0 2018-12-21 [1] CRAN (R 3.6.0) #> purrr 0.3.3 2019-10-18 [1] CRAN (R 3.6.1) #> R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.1) #> Rcpp 1.0.3 2019-11-08 [1] CRAN (R 3.6.2) #> remotes 2.1.0 2019-06-24 [1] CRAN (R 3.6.0) #> rlang 0.4.4 2020-01-28 [1] CRAN (R 3.6.2) #> rmarkdown 2.1 2020-01-20 [1] CRAN (R 3.6.2) #> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.0) #> sandwich 2.5-1 2019-04-06 [1] CRAN (R 3.6.1) #> scales 1.1.0 2019-11-18 [1] CRAN (R 3.6.1) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.0) #> sjlabelled 1.1.3 2020-01-28 [1] CRAN (R 3.6.2) #> sjmisc 2.8.3 2020-01-10 [1] CRAN (R 3.6.2) #> sjPlot * 2.8.2 2020-01-23 [1] CRAN (R 3.6.2) #> sjstats 0.17.8 2020-01-21 [1] CRAN (R 3.6.2) #> snakecase 0.11.0 2019-05-25 [1] CRAN (R 3.6.0) #> stringi 1.4.5 2020-01-11 [1] CRAN (R 3.6.2) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.0) #> survival * 3.1-8 2019-12-03 [1] CRAN (R 3.6.1) #> testthat 2.3.1 2019-12-01 [1] CRAN (R 3.6.1) #> TH.data 1.0-10 2019-01-21 [1] CRAN (R 3.6.1) #> tibble 2.1.3 2019-06-06 [1] CRAN (R 3.6.0) #> tidyr 1.0.2 2020-01-24 [1] CRAN (R 3.6.2) #> tidyselect 1.0.0 2020-01-27 [1] CRAN (R 3.6.2) #> usethis 1.5.1 2019-07-04 [1] CRAN (R 3.6.0) #> vctrs 0.2.2 2020-01-24 [1] CRAN (R 3.6.2) #> withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0) #> xfun 0.12 2020-01-13 [1] CRAN (R 3.6.2) #> xtable 1.8-4 2019-04-21 [1] CRAN (R 3.6.0) #> yaml 2.2.1 2020-02-01 [1] CRAN (R 3.6.2) #> zoo 1.8-7 2020-01-10 [1] CRAN (R 3.6.2) #> #> [1] C:/Users/Temuulen/Documents/R/win-library/3.6 #> [2] C:/Program Files/R/R-3.6.2/library ```
strengejacke commented 4 years ago

Thanks, should work now once you update sjPlot and the insight-pacakge from GitHub. If not, you may also need to update parameters from GitHub.