fsolt / dotwhisker

Dot-and-Whisker Plots of Regression Results
https://fsolt.org/dotwhisker/
Other
57 stars 10 forks source link

use `parameters` instead of `broomExtra`? #106

Closed IndrajeetPatil closed 2 years ago

IndrajeetPatil commented 3 years ago

Is there any downside to making this switch? None, the outputs are pretty much identical because broomExtra defaults to parameters anyway. So you will get the same behavior you do now.

library(lme4)
#> Loading required package: Matrix
library(broomExtra)
library(parameters)
options(tibble.width = Inf)

model <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)

# broomExtra output
tidy_parameters(model)
#> # A tibble: 6 x 11
#>   term                    estimate std.error conf.level conf.low conf.high
#>   <chr>                      <dbl>     <dbl>      <dbl>    <dbl>     <dbl>
#> 1 (Intercept)             251.          6.82       0.95   238.       265. 
#> 2 Days                     10.5         1.55       0.95     7.44      13.5
#> 3 SD (Intercept)           24.7        NA          0.95    NA         NA  
#> 4 SD (Days)                 5.92       NA          0.95    NA         NA  
#> 5 Cor (Intercept~Subject)   0.0656     NA          0.95    NA         NA  
#> 6 SD (Observations)        25.6        NA          0.95    NA         NA  
#>   statistic df.error    p.value effect group     
#>       <dbl>    <int>      <dbl> <chr>  <chr>     
#> 1     36.8       174  4.54e-297 fixed  ""        
#> 2      6.77      174  1.27e- 11 fixed  ""        
#> 3     NA          NA NA         random "Subject" 
#> 4     NA          NA NA         random "Subject" 
#> 5     NA          NA NA         random "Subject" 
#> 6     NA          NA NA         random "Residual"

# parameters output
parameters(model) |>
  standardize_names(style = "broom") |>
  tibble::as_tibble()
#> # A tibble: 6 x 11
#>   term                    estimate std.error conf.level conf.low conf.high
#>   <chr>                      <dbl>     <dbl>      <dbl>    <dbl>     <dbl>
#> 1 (Intercept)             251.          6.82       0.95   238.       265. 
#> 2 Days                     10.5         1.55       0.95     7.44      13.5
#> 3 SD (Intercept)           24.7        NA          0.95    NA         NA  
#> 4 SD (Days)                 5.92       NA          0.95    NA         NA  
#> 5 Cor (Intercept~Subject)   0.0656     NA          0.95    NA         NA  
#> 6 SD (Observations)        25.6        NA          0.95    NA         NA  
#>   statistic df.error    p.value effect group     
#>       <dbl>    <int>      <dbl> <chr>  <chr>     
#> 1     36.8       174  4.54e-297 fixed  ""        
#> 2      6.77      174  1.27e- 11 fixed  ""        
#> 3     NA          NA NA         random "Subject" 
#> 4     NA          NA NA         random "Subject" 
#> 5     NA          NA NA         random "Subject" 
#> 6     NA          NA NA         random "Residual"

Benefit: It reduces the dependency load significantly!

tools::package_dependencies(c("broomExtra", "parameters"), recursive = TRUE)
#> $broomExtra
#>  [1] "broom"       "broom.mixed" "dplyr"       "magrittr"    "parameters" 
#>  [6] "performance" "rlang"       "tibble"      "backports"   "ellipsis"   
#> [11] "generics"    "glue"        "methods"     "purrr"       "stringr"    
#> [16] "tidyr"       "plyr"        "reshape2"    "nlme"        "coda"       
#> [21] "TMB"         "cubelyr"     "lifecycle"   "R6"          "tidyselect" 
#> [26] "utils"       "vctrs"       "pillar"      "bayestestR"  "insight"    
#> [31] "stats"       "fansi"       "pkgconfig"   "lattice"     "grDevices"  
#> [36] "graphics"    "cli"         "crayon"      "utf8"        "Rcpp"       
#> [41] "stringi"     "cpp11"       "Matrix"      "RcppEigen"   "grid"       
#> [46] "tools"      
#> 
#> $parameters
#> [1] "bayestestR" "insight"    "methods"    "stats"      "utils"

Created on 2021-06-17 by the reprex package (v2.0.0)

P.S. I am author and maintainer of broomExtra, and would be happy to make a PR if you want.

IndrajeetPatil commented 2 years ago

Awesome!

Do you have plans to submit the new version of the package to CRAN anytime soon?

IndrajeetPatil commented 2 years ago

The docs also need to be tweaked a bit, btw:

Screenshot 2021-07-17 at 08 18 17
sammo3182 commented 2 years ago

Ah, thank you for the reminder! That will be fixed in the released version. I'll submit it to CRAN right now. Sorry for not leaving a message before or immediately after closing the issue---the entire morning was spent cleaning the repo (issues piled up).

Thank you again, Indrajee @IndrajeetPatil , for the suggestion. And I would also like to say, the broomExtra is amazing! Although we won't use it directly in dotwhisker as the author suggested (how nice, friendly, and open-mind the author is!), it definitely helps people to prepare their analyses outputs for using dotwhisker. It also opens opportunities for presenting pretty tables (in the appendices of course :P) with modelsummary!

IndrajeetPatil commented 2 years ago

Sounds good.

Thank you very much for being open to suggestions and for all the work you have put into this awesome visualization package! :)