easystats / parameters

:bar_chart: Computation and processing of models' parameters
https://easystats.github.io/parameters/
GNU General Public License v3.0
428 stars 36 forks source link

standardize_parameters() does not "beautify" parameter column for factors #983

Closed jmgirard closed 2 months ago

jmgirard commented 3 months ago

Note the difference between model_parameters() and standardize_parameters():

library(easystats)
#> # Attaching packages: easystats 0.7.2
#> ✔ bayestestR  0.13.2   ✔ correlation 0.8.4 
#> ✔ datawizard  0.11.0   ✔ effectsize  0.8.8 
#> ✔ insight     0.20.0   ✔ modelbased  0.8.7 
#> ✔ performance 0.12.0   ✔ parameters  0.21.7
#> ✔ report      0.5.8    ✔ see         0.8.4
fit <- lm(Sepal.Length ~ Species, data = iris)
model_parameters(fit)
#> Parameter            | Coefficient |   SE |       95% CI | t(147) |      p
#> --------------------------------------------------------------------------
#> (Intercept)          |        5.01 | 0.07 | [4.86, 5.15] |  68.76 | < .001
#> Species [versicolor] |        0.93 | 0.10 | [0.73, 1.13] |   9.03 | < .001
#> Species [virginica]  |        1.58 | 0.10 | [1.38, 1.79] |  15.37 | < .001
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a Wald t-distribution approximation.
standardize_parameters(fit)
#> # Standardization method: refit
#> 
#> Parameter         | Std. Coef. |         95% CI
#> -----------------------------------------------
#> (Intercept)       |      -1.01 | [-1.18, -0.84]
#> Speciesversicolor |       1.12 | [ 0.88,  1.37]
#> Speciesvirginica  |       1.91 | [ 1.66,  2.16]

Created on 2024-06-10 with reprex v2.1.0

mattansb commented 3 months ago

standardize_parameters() ~is now @strengejacke's problem~ now lives in {parameters} (:

strengejacke commented 3 months ago

You could - for now - workaround this by using:

fit <- lm(Sepal.Length ~ Species, data = iris)
parameters::model_parameters(fit, standardize = "refit")
#> Parameter            | Coefficient |   SE |         95% CI | t(147) |      p
#> ----------------------------------------------------------------------------
#> (Intercept)          |       -1.01 | 0.09 | [-1.18, -0.84] | -11.50 | < .001
#> Species [versicolor] |        1.12 | 0.12 | [ 0.88,  1.37] |   9.03 | < .001
#> Species [virginica]  |        1.91 | 0.12 | [ 1.66,  2.16] |  15.37 | < .001
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a Wald t-distribution approximation.

Created on 2024-06-23 with reprex v2.1.0