easystats / modelbased

:chart_with_upwards_trend: Estimate effects, contrasts and means based on statistical models
https://easystats.github.io/modelbased/
GNU General Public License v3.0
234 stars 19 forks source link

`coxme` is part of `insight::supported_models()` but not supported for `modelbased::estimate_grouplevel()` #213

Open walrossker opened 2 years ago

walrossker commented 2 years ago

Trying to estimate confidence intervals for the random effects in a coxme model using modelbased::estimate_grouplevel, but the error message suggests that it's not actually supported (reprex below). Other modelbased functions work on the coxme model though, so is it just the estimate_grouplevel function that is not supported? If so, any tips on how to get confidence intervals / p-values on random effects from this model are much appreciated. Thanks!

mod <- coxme::coxme(
  survival::Surv(time = enum, event = event) ~ rx + number + size + (1 + number|id),
  data = survival::bladder
)

"coxme" %in% insight::supported_models()
#> [1] TRUE

modelbased::estimate_grouplevel(mod, type = "random")
#> Error: Sorry, `model_parameters()` failed with the following error (possible
#>   class 'coxme' not supported):
#> 
#>   'arg' should be one of "fixed", "random"

modelbased::estimate_means(mod, at = "number")
#> Estimated Marginal Means
#> 
#> number | Mean |   SE |       95% CI
#> -----------------------------------
#> 1.00   | 0.78 | 0.07 | [0.66, 0.93]
#> 1.78   | 0.91 | 0.03 | [0.86, 0.97]
#> 2.56   | 1.06 | 0.04 | [0.99, 1.14]
#> 3.33   | 1.23 | 0.11 | [1.03, 1.48]
#> 4.11   | 1.43 | 0.22 | [1.06, 1.93]
#> 4.89   | 1.66 | 0.35 | [1.10, 2.52]
#> 5.67   | 1.93 | 0.52 | [1.14, 3.29]
#> 6.44   | 2.25 | 0.74 | [1.18, 4.30]
#> 7.22   | 2.61 | 1.02 | [1.22, 5.61]
#> 8.00   | 3.04 | 1.37 | [1.26, 7.34]
#> 
#> Marginal means estimated at number

sessionInfo()
#> R version 4.0.4 (2021-02-15)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19042)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=English_United States.1252 
#> [2] LC_CTYPE=English_United States.1252   
#> [3] LC_MONETARY=English_United States.1252
#> [4] LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.1252    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.8.3       nloptr_2.0.0       compiler_4.0.4     highr_0.9         
#>  [5] parameters_0.18.2  tools_4.0.4        boot_1.3-26        modelbased_0.8.5  
#>  [9] digest_0.6.29      lme4_1.1-30        evaluate_0.15      nlme_3.1-152      
#> [13] lattice_0.20-41    rlang_1.0.2        reprex_2.0.1       Matrix_1.3-2      
#> [17] cli_3.2.0          rstudioapi_0.13    yaml_2.3.5         mvtnorm_1.1-3     
#> [21] xfun_0.30          fastmap_1.1.0      withr_2.5.0        bayestestR_0.12.1 
#> [25] stringr_1.4.1      knitr_1.39         fs_1.5.2           grid_4.0.4        
#> [29] glue_1.6.2         coxme_2.2-17       bdsmatrix_1.3-6    survival_3.2-7    
#> [33] rmarkdown_2.13     minqa_1.2.4        magrittr_2.0.3     htmltools_0.5.2   
#> [37] emmeans_1.7.3      splines_4.0.4      MASS_7.3-53        datawizard_0.5.1  
#> [41] insight_0.18.2     xtable_1.8-4       stringi_1.7.6      estimability_1.4.1