strengejacke / sjPlot

sjPlot - Data Visualization for Statistics in Social Science
https://strengejacke.github.io/sjPlot
603 stars 91 forks source link

tab_model: show.std support for all options given by effectsize? #767

Open mattansb opened 3 years ago

mattansb commented 3 years ago

Currently the show.std arg in tab_model allows only for standardization of parameters via re-fitting. I suggest using and supporting the options in effectsize:

  1. When interaction are involved, the can cause the standardized coefs to not corespond to the same simple slopes as the raw coef:
m <- lm(mpg ~ cyl * hp, data = mtcars)

sjPlot::tab_model(m, show.std = TRUE)
  mpg
Predictors Estimates std. Beta CI standardized CI p std. p
(Intercept) 50.75 -0.32 37.41 – 64.09 -0.67 – 0.02 <0.001 0.065
cyl -4.12 -0.36 -6.14 – -2.09 -0.79 – 0.07 <0.001 0.097
hp -0.17 -0.55 -0.31 – -0.03 -1.00 – -0.10 0.020 0.018
cyl \* hp 0.02 0.40 0.00 – 0.04 0.03 – 0.77 0.033 0.033
Observations 32
R2 / R2 adjusted 0.780 / 0.757
effectsize::standardize_parameters(m, method = "refit")
#> # Standardization method: refit
#> 
#> Parameter   | Coefficient (std.) |         95% CI
#> -------------------------------------------------
#> (Intercept) |              -0.32 | [-0.67,  0.02]
#> cyl         |              -0.36 | [-0.79,  0.07]
#> hp          |              -0.55 | [-1.00, -0.10]
#> cyl:hp      |               0.40 | [ 0.03,  0.77]

# These DO correspond to the same simple slopes!
effectsize::standardize_parameters(m, method = "basic")
#> # Standardization method: basic
#> 
#> Parameter   | Coefficient (std.) |         95% CI
#> -------------------------------------------------
#> (Intercept) |               0.00 | [ 0.00,  0.00]
#> cyl         |              -1.22 | [-1.82, -0.62]
#> hp          |              -1.94 | [-3.55, -0.33]
#> cyl:hp      |               2.21 | [ 0.19,  4.23]

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

  1. For mixed models, it could be nice to support the "pseudo" method (:

  2. I'm sure there are more use cases (:

mattansb commented 3 years ago

(Okay, I just noticed that there are two p values and two sets of CIs... And still I think using the methods provided by effectsize would be awesome 😁 + having the raw and std parameters match would make more sense).