Standardized Model Parameters
Source:vignettes/model_parameters_standardized.Rmd
model_parameters_standardized.Rmd
The model_parameters()
function (also accessible via the shortcut parameters()
) can also be used to calculate standardized model parameters via the standardize
argument. Recall that standardizing data/variable (zscoring), i.e. centering and scaling, involves expressing data in terms of standard deviation (i.e., mean = 0, SD = 1). That is, it the process of subtracting the mean and dividing the quantity by standard deviation. Standardization can help avoid multicollinearity issues when more complex (polynomial, for instance) terms are included in the model.
There are different methods of standardizing model parameters (see also ?effectsize::standardize_parameters
):

"refit"
, "posthoc"
"smart"
"basic"
If you are interested in more statistical and technical details, and how standardization methods relate to different (standardized) effect size measures, read the following vignette from effectsize package, from whence this functionality comes: https://easystats.github.io/effectsize/articles/standardize_parameters.html
Standardization by refitting the model
standardize = "refit"
is based on a complete model refit with a standardized version of data. Hence, this method is equal to standardizing the variables before fitting the model. It is the most accurate (Neter et al., 1989), but it is also the most computationally costly and long (especially for heavy models such as, for instance, Bayesian models). This method is particularly recommended for complex models that include interactions or transformations (e.g., polynomial or spline terms).
When standardize = "refit"
, model_parameters()
internally calls effectsize::standardize()
to standardize the data that was used to fit the model and updates the model with the standardized data. Note that effectsize::standardize()
tries to detect which variables should be standardized and which not. For instance, having a log(x)
in the model formula would exclude x
from being standardized, because x
might get negative values, and thus log(x)
would no longer be defined. Factors or dates will also not be standardized. Response variables will be standardized, if appropriate.
library(lme4)
data(iris)
set.seed(1234)
iris$grp < as.factor(sample(1:3, nrow(iris), replace = TRUE))
# fit example model
model < lme4::lmer(
Sepal.Length ~ Species * Sepal.Width + Petal.Length + (1  grp),
data = iris
)
# classic model parameters
model_parameters(model)
#> # Fixed Effects
#>
#> Parameter  Coefficient  SE  95% CI  t(141)  p
#> 
#> (Intercept)  1.55  0.40  [ 0.76, 2.35]  3.87  < .001
#> Species [versicolor]  0.41  0.55  [0.67, 1.50]  0.75  0.454
#> Species [virginica]  0.41  0.58  [1.56, 0.74]  0.70  0.483
#> Sepal Width  0.66  0.11  [ 0.44, 0.89]  5.83  < .001
#> Petal Length  0.82  0.07  [ 0.69, 0.95]  12.52  < .001
#> Species [versicolor] * Sepal Width  0.48  0.19  [0.85, 0.12]  2.60  0.010
#> Species [virginica] * Sepal Width  0.36  0.18  [0.71, 0.00]  1.99  0.048
#>
#> # Random Effects
#>
#> Parameter  Coefficient  SE  95% CI
#> 
#> SD (Intercept: grp)  0.08  0.05  [0.02, 0.29]
#> SD (Residual)  0.30  0.02  [0.27, 0.33]
# standardized model parameters
model_parameters(model, standardize = "refit")
#> # Fixed Effects
#>
#> Parameter  Coefficient  SE  95% CI  t(141)  p
#> 
#> (Intercept)  0.97  0.20  [ 0.57, 1.37]  4.74  < .001
#> Species [versicolor]  1.29  0.26  [1.80, 0.77]  4.91  < .001
#> Species [virginica]  1.81  0.34  [2.49, 1.14]  5.33  < .001
#> Sepal Width  0.35  0.06  [ 0.23, 0.47]  5.83  < .001
#> Petal Length  1.74  0.14  [ 1.47, 2.02]  12.52  < .001
#> Species [versicolor] * Sepal Width  0.25  0.10  [0.45, 0.06]  2.60  0.010
#> Species [virginica] * Sepal Width  0.19  0.09  [0.38, 0.00]  1.99  0.048
#>
#> # Random Effects
#>
#> Parameter  Coefficient  SE  95% CI
#> 
#> SD (Intercept: grp)  0.10  0.06  [0.03, 0.35]
#> SD (Residual)  0.36  0.02  [0.32, 0.40]
The second output is identical to following:
# standardize continuous variables manually
model2 < lme4::lmer(
scale(Sepal.Length) ~ Species * scale(Sepal.Width) + scale(Petal.Length) + (1  grp),
data = iris
)
model_parameters(model2)
#> # Fixed Effects
#>
#> Parameter  Coefficient  SE  95% CI  t(141)  p
#> 
#> (Intercept)  0.97  0.20  [ 0.57, 1.37]  4.74  < .001
#> Species [versicolor]  1.29  0.26  [1.80, 0.77]  4.91  < .001
#> Species [virginica]  1.81  0.34  [2.49, 1.14]  5.33  < .001
#> Sepal Width  0.35  0.06  [ 0.23, 0.47]  5.83  < .001
#> Petal Length  1.74  0.14  [ 1.47, 2.02]  12.52  < .001
#> Species [versicolor] * Sepal Width  0.25  0.10  [0.45, 0.06]  2.60  0.010
#> Species [virginica] * Sepal Width  0.19  0.09  [0.38, 0.00]  1.99  0.048
#>
#> # Random Effects
#>
#> Parameter  Coefficient  SE  95% CI
#> 
#> SD (Intercept: grp)  0.10  0.06  [0.03, 0.35]
#> SD (Residual)  0.36  0.02  [0.32, 0.40]
Posthoc standardization
standardize = "posthoc"
aims at emulating the results obtained by "refit"
without refitting the model. The coefficients are divided by the standard deviation of the outcome (which becomes their expression unit). Then, the coefficients related to numeric variables are additionally multiplied by the standard deviation of the related terms, so that they correspond to changes of 1 SD of the predictor (e.g., “a change in 1 SD of x
is related to a change of 0.24 of the SD of y
”). This does not apply to binary variables or factors, so the coefficients are still related to changes in levels.
This method is not accurate and tends to give aberrant results when interactions are specified. However, this method of standardization is the “classic” result obtained by many statistical packages when standardized coefficients are requested.
When standardize = "posthoc"
, model_parameters()
internally calls effectsize::standardize_parameters(method = "posthoc")
. Test statistic and pvalues are not affected, i.e. they are the same as if no standardization would be applied.
model_parameters(model, standardize = "posthoc")
#> # Fixed Effects
#>
#> Parameter  Std. Coef.  SE  95% CI  t(141)  p
#> 
#> (Intercept)  0.00  0.00  [ 0.00, 0.00]  3.87  < .001
#> Species [versicolor]  0.50  0.66  [0.81, 1.81]  0.75  0.454
#> Species [virginica]  0.49  0.70  [1.88, 0.89]  0.70  0.483
#> Sepal Width  0.35  0.06  [ 0.23, 0.47]  5.83  < .001
#> Petal Length  1.74  0.14  [ 1.47, 2.02]  12.52  < .001
#> Species [versicolor] * Sepal Width  0.25  0.10  [0.45, 0.06]  2.60  0.010
#> Species [virginica] * Sepal Width  0.19  0.09  [0.38, 0.00]  1.99  0.048
standardize = "basic"
also applies posthoc standardization, however, factors are converted to numeric, which means that it also scales the coefficient by the standard deviation of model’s matrix’ parameter of factor levels (transformed to integers) or binary predictors.
model_parameters(model, standardize = "basic")
#> # Fixed Effects
#>
#> Parameter  Std. Coef.  SE  95% CI  t(141)  p
#> 
#> (Intercept)  0.00  0.00  [ 0.00, 0.00]  3.87  < .001
#> Species [versicolor]  0.23  0.31  [0.38, 0.85]  0.75  0.454
#> Species [virginica]  0.23  0.33  [0.89, 0.42]  0.70  0.483
#> Sepal Width  0.35  0.06  [ 0.23, 0.47]  5.83  < .001
#> Petal Length  1.74  0.14  [ 1.47, 2.02]  12.52  < .001
#> Species [versicolor] * Sepal Width  0.77  0.30  [1.36, 0.19]  2.60  0.010
#> Species [virginica] * Sepal Width  0.61  0.31  [1.22, 0.00]  1.99  0.048
Compare the two outputs above and notice how coefficient estimates, standard errors, confidence intervals, and pvalues change for main effect and interaction effect terms containing Species
variable, the only factor variable in our model.
This method is the one implemented by default in other software packages, such as lm.beta::lm.beta()
:
library(lm.beta)
data(iris)
model3 < lm(Sepal.Length ~ Species * Sepal.Width + Petal.Length, data = iris)
mp < model_parameters(model3, standardize = "basic")
out < lm.beta(model3)
data.frame(model_parameters = mp$Std_Coefficient, lm.beta = coef(out))
#> model_parameters lm.beta
#> (Intercept) 0.00 NA
#> Speciesversicolor 0.16 0.16
#> Speciesvirginica 0.37 0.37
#> Sepal.Width 0.33 0.33
#> Petal.Length 1.75 1.75
#> Speciesversicolor:Sepal.Width 0.72 0.72
#> Speciesvirginica:Sepal.Width 0.49 0.49
Smart standardization
standardize = "smart"
is similar to standardize = "posthoc"
in that it does not involve model refitting. The difference is that the SD of the response is computed on the relevant section of the data. For instance, if a factor with 3 levels A (the intercept), B and C is entered as a predictor, the effect corresponding to B versus A will be scaled by the variance of the response at the intercept only. As a results, the coefficients for effects of factors are similar to a Glass’ delta.
model_parameters(model, standardize = "smart")
#> # Fixed Effects
#>
#> Parameter  Std. Coef.  SE  95% CI  t(141)  p
#> 
#> (Intercept)  0.00  0.00  [ 0.00, 0.00]  3.87  < .001
#> Species [versicolor]  1.17  1.56  [1.91, 4.24]  0.75  0.454
#> Species [virginica]  1.16  1.65  [4.42, 2.10]  0.70  0.483
#> Sepal Width  0.35  0.06  [ 0.23, 0.47]  5.83  < .001
#> Petal Length  1.74  0.14  [ 1.47, 2.02]  12.52  < .001
#> Species [versicolor] * Sepal Width  1.13  0.43  [1.98, 0.27]  2.60  0.010
#> Species [virginica] * Sepal Width  0.83  0.42  [1.66, 0.01]  1.99  0.048