vincentarelbundock / modelsummary

Beautiful and customizable model summaries in R.
http://modelsummary.com
Other
912 stars 75 forks source link

Missing coefficient names for interaction terms that contain `I()` in tex outputs and pdf renders #693

Closed zekiakyol closed 10 months ago

zekiakyol commented 10 months ago
  1. If we use an interaction term that contains at least one term derived using I(), some coefficient names that contain I()does not show in .tex output and .pdf renders in Quarto. There is no problem for .html outputs and .html renders. I provide three scenarios below. Thank you!
  2. This is created on 2023-12-15 with reprex v2.0.2
library(modelsummary)

model1 <- lm(mpg ~ I(wt^2) * disp,
             data = mtcars)

model2 <- lm(mpg ~ I(wt^2) * I(disp^2),
             data = mtcars)

model3 <- lm(mpg ~ wt * I(disp^2),
             data = mtcars)

modelsummary(model1, output = "table1.html") # Works fine
modelsummary(model2, output = "table2.html") # Works fine
modelsummary(model3, output = "table3.html") # Works fine

modelsummary(model1, output = "table1.tex")  # all I() terms are missing in the coefficient names
modelsummary(model2, output = "table2.tex")  # some I() terms are missing in the coefficient names
modelsummary(model3, output = "table3.tex")  # some I() terms are missing in the coefficient names

Figure for .tex outputs:

table1-2-3

  1. sessionInfo() output
R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: Europe/Istanbul
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] modelsummary_1.4.3

loaded via a namespace (and not attached):
 [1] bslib_0.6.1         xfun_0.41           bayestestR_0.13.1   htmlwidgets_1.6.4   insight_0.19.7      lattice_0.21-8      vctrs_0.6.5        
 [8] tools_4.3.1         generics_0.1.3      parallel_4.3.1      datawizard_0.9.0    sandwich_3.1-0      tibble_3.2.1        fansi_1.0.6        
[15] pkgconfig_2.0.3     Matrix_1.6-4        checkmate_2.3.1     assertthat_0.2.1    webshot_0.5.5       gt_0.10.0           lifecycle_1.0.4    
[22] compiler_4.3.1      stringr_1.5.1       munsell_0.5.0       codetools_0.2-19    sass_0.4.8          htmltools_0.5.7     jquerylib_0.1.4    
[29] pillar_1.9.0        crayon_1.5.2        MASS_7.3-60         DT_0.31             cachem_1.0.8        multcomp_1.4-25     parallelly_1.36.0  
[36] tidyselect_1.2.0    rvest_1.0.3         digest_0.6.33       performance_0.10.8  mvtnorm_1.2-4       stringi_1.8.3       future_1.33.0      
[43] dplyr_1.1.4         listenv_0.9.0       splines_4.3.1       fastmap_1.1.1       grid_4.3.1          colorspace_2.1-0    cli_3.6.2          
[50] magrittr_2.0.3      survival_3.5-5      utf8_1.2.4          TH.data_1.1-2       future.apply_1.11.0 huxtable_5.5.3      scales_1.3.0       
[57] backports_1.4.1     estimability_1.4.1  rmarkdown_2.25      httr_1.4.7          emmeans_1.8.9       globals_0.16.2      zoo_1.8-12         
[64] kableExtra_1.3.4    coda_0.19-4         evaluate_0.23       knitr_1.45          parameters_0.21.3   lmtest_0.9-40       viridisLite_0.4.2  
[71] rlang_1.1.2         xtable_1.8-4        glue_1.6.2          xml2_1.3.6          jsonlite_1.8.8      svglite_2.1.3       rstudioapi_0.15.0  
[78] effectsize_0.8.6    R6_2.5.1            tables_0.9.17       systemfonts_1.0.5  
vincentarelbundock commented 10 months ago

Thanks a lot for the very useful report. I think I was able to fix this in version 1.4.3.9002, available now on Github. Let me know if you try it and it still doesn't work.