Closed iago-pssjd closed 3 months ago
This is already possible by using include_reference=TRUE
if you are using the latest version of the parameters
package.
Thanks @vincentarelbundock However, doing this, coef_rename =TRUE
has no effect
On my computer, this seems to work:
library(modelsummary)
mod <- lm(mpg ~ hp + factor(cyl), mtcars)
modelsummary(mod, coef_rename = TRUE, include_reference = TRUE)
+-------------+---------+
| | (1) |
+=============+=========+
| (Intercept) | 28.650 |
+-------------+---------+
| | (1.588) |
+-------------+---------+
| hp | -0.024 |
+-------------+---------+
| | (0.015) |
+-------------+---------+
| cyl [4] | - |
+-------------+---------+
| cyl [6] | -5.968 |
+-------------+---------+
| | (1.639) |
+-------------+---------+
| cyl [8] | -8.521 |
+-------------+---------+
| | (2.326) |
+-------------+---------+
| Num.Obs. | 32 |
+-------------+---------+
| R2 | 0.754 |
+-------------+---------+
| R2 Adj. | 0.727 |
+-------------+---------+
| AIC | 169.9 |
+-------------+---------+
| BIC | 177.2 |
+-------------+---------+
| Log.Lik. | -79.948 |
+-------------+---------+
| F | 28.585 |
+-------------+---------+
| RMSE | 2.94 |
+-------------+---------+
Not in any of both I use (yesterday, Windows 10 computer at job, now Linux at home): I would expect in next modelsummary
table appear Gross horsepower
instead of hp
> mtcars2 <- mtcars
> attr(mtcars2$hp, "label") <- "Gross horsepower"
> library(modelsummary)
`modelsummary` 2.0.0 now uses `tinytable` as its default table-drawing backend. Learn more
at: https://vincentarelbundock.github.io/tinytable/
Revert to `kableExtra` for one session:
options(modelsummary_factory_default = 'kableExtra')
Change the default backend persistently:
config_modelsummary(factory_default = 'gt')
Silence this message forever:
config_modelsummary(startup_message = FALSE)
> mod <- lm(mpg ~ hp + factor(cyl), mtcars2)
> modelsummary(mod, coef_rename = TRUE, include_reference = TRUE)
+-------------+---------+
| | (1) |
+=============+=========+
| (Intercept) | 28.650 |
+-------------+---------+
| | (1.588) |
+-------------+---------+
| hp | -0.024 |
+-------------+---------+
| | (0.015) |
+-------------+---------+
| cyl [4] | - |
+-------------+---------+
| cyl [6] | -5.968 |
+-------------+---------+
| | (1.639) |
+-------------+---------+
| cyl [8] | -8.521 |
+-------------+---------+
| | (2.326) |
+-------------+---------+
| Num.Obs. | 32 |
+-------------+---------+
| R2 | 0.754 |
+-------------+---------+
| R2 Adj. | 0.727 |
+-------------+---------+
| AIC | 169.9 |
+-------------+---------+
| BIC | 177.2 |
+-------------+---------+
| Log.Lik. | -79.948 |
+-------------+---------+
| F | 28.585 |
+-------------+---------+
| RMSE | 2.94 |
+-------------+---------+
> sessionInfo()
R version 4.3.3 (2024-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 12 (bookworm)
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.21.so; LAPACK version 3.11.0
locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C LC_TIME=en_GB.UTF-8
[4] LC_COLLATE=en_GB.UTF-8 LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=en_GB.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
time zone: Europe/Madrid
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] modelsummary_2.0.0
loaded via a namespace (and not attached):
[1] Matrix_1.6-5 future.apply_1.11.2 compiler_4.3.3 tinytable_0.2.1
[5] parallel_4.3.3 globals_0.16.3 splines_4.3.3 fastmap_1.1.1
[9] lattice_0.22-5 coda_0.19-4.1 TH.data_1.1-2 tables_0.9.17
[13] generics_0.1.3 lmtest_0.9-40 knitr_1.46 MASS_7.3-60.0.1
[17] backports_1.4.1 checkmate_2.3.1 future_1.33.2 insight_0.19.10
[21] rlang_1.1.3 multcomp_1.4-25 performance_0.11.0 xfun_0.43
[25] parameters_0.21.6 datawizard_0.10.0 estimability_1.5 cli_3.6.2
[29] emmeans_1.10.1 digest_0.6.35 grid_4.3.3 rstudioapi_0.16.0
[33] xtable_1.8-4 mvtnorm_1.2-4 sandwich_3.1-0 effectsize_0.8.7
[37] glue_1.7.0 data.table_1.15.4 listenv_0.9.1 codetools_0.2-19
[41] zoo_1.8-12 survival_3.5-8 fansi_1.0.6 parallelly_1.37.1
[45] bayestestR_0.13.2 tools_4.3.3 htmltools_0.5.8.1
>
(There is also no effect if the labelled variable is cyl
)
thanks, I see that now (you had not mentioned attribute labels before).
I traced it to a problem in an upstream package. Once it is fixed there, modelsummary
shoudl be fixed automatically. I opened an issue here: https://github.com/easystats/parameters/issues/961
Thanks!
Dear @vincentarelbundock ,
I only tested now this functionality (since https://github.com/easystats/parameters/issues/961 seemed to be solved). And I get that the pretty_names
are not applied to the reference row. For example, see the rows 1 and 6 in the next screenshot:
still seems like a parameters problem. Maybe you can come up with a minimal working example with just parameters and report it there.
I know it is possible doing that by hand: https://stackoverflow.com/questions/64989689/how-to-add-a-text-line-to-your-regression-table-above-one-coefficient-using-the
But it would be great if it was possible through something like
reference = TRUE