Compute standardized model parameters (coefficients).
standardize_parameters(
model,
method = "refit",
ci = 0.95,
robust = FALSE,
two_sd = FALSE,
include_response = TRUE,
verbose = TRUE,
parameters,
...
)
standardize_posteriors(
model,
method = "refit",
robust = FALSE,
two_sd = FALSE,
include_response = TRUE,
verbose = TRUE,
...
)
model  A statistical model. 

method  The method used for standardizing the parameters. Can be

ci  Confidence Interval (CI) level 
robust  Logical, if 
two_sd  If 
include_response  If 
verbose  Toggle warnings and messages on or off. 
parameters  Deprecated. 
...  For

A data frame with the standardized parameters (Std_*
, depending on
the model type) and their CIs (CI_low
and CI_high
). Where applicable,
standard errors (SEs) are returned as an attribute (attr(x, "standard_error")
).
refit: This method is based on a complete model refit with a
standardized version of the data. Hence, this method is equal to
standardizing the variables before fitting the model. It is the "purest" and
the most accurate (Neter et al., 1989), but it is also the most
computationally costly and long (especially for heavy models such as Bayesian
models). This method is particularly recommended for complex models that
include interactions or transformations (e.g., polynomial or spline terms).
The robust
(default to FALSE
) argument enables a robust standardization
of data, i.e., based on the median
and MAD
instead of the mean
and
SD
. See standardize()
for more details.
Note that standardize_parameters(method = "refit")
may not return
the same results as fitting a model on data that has been standardized with
standardize()
; standardize_parameters()
used the data used by the model
fitting function, which might not be same data if there are missing values.
see the remove_na
argument in standardize()
.
posthoc: Posthoc standardization of the parameters, aiming at
emulating the results obtained by "refit" without refitting the model. The
coefficients are divided by the standard deviation (or MAD if robust
) of
the outcome (which becomes their expression 'unit'). Then, the coefficients
related to numeric variables are additionally multiplied by the standard
deviation (or MAD if robust
) 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 tend to give aberrant results when
interactions are specified.
smart (Standardization of Model's parameters with Adjustment,
Reconnaissance and Transformation  experimental): Similar to method = "posthoc"
in that it does not involve model refitting. The difference is
that the SD (or MAD if robust
) 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
vs. 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.
basic: This method is similar to method = "posthoc"
, but treats all
variables as continuous: it also scales the coefficient by the standard
deviation of model's matrix' parameter of factors levels (transformed to
integers) or binary predictors. Although being inappropriate for these cases,
this method is the one implemented by default in other software packages,
such as lm.beta::lm.beta()
.
pseudo (for 2level (G)LMMs only): In this (posthoc) method, the
response and the predictor are standardized based on the level of prediction
(levels are detected with parameters::check_heterogeneity()
): Predictors
are standardized based on their SD at level of prediction (see also
parameters::demean()
); The outcome (in linear LMMs) is standardized based
on a fitted randominterceptmodel, where sqrt(randominterceptvariance)
is used for level 2 predictors, and sqrt(residualvariance)
is used for
level 1 predictors (Hoffman 2015, page 342). A warning is given when a
withingroup varialbe is found to have access betweengroup variance.
When the model's formula contains transformations (e.g. y ~ exp(X)
)
method = "refit"
might give different results compared to
method = "basic"
("posthoc"
and "smart"
do not support such
transformations): where "refit"
standardizes the data prior to the
transformation (e.g. equivalent to exp(scale(X))
), the "basic"
method
standardizes the transformed data (e.g. equivalent to scale(exp(X))
). See
standardize()
for more details on how different transformations are dealt
with.
The returned confidence intervals are rescaled versions of the unstandardized confidence intervals, and not "true" confidence intervals of the standardized coefficients (cf. Jones & Waller, 2015).
When standardizing coefficients of a generalized model (GLM, GLMM, etc), only the predictors are standardized, maintaining the interpretability of the coefficients (e.g., in a binomial model: the exponent of the standardized parameter is the OR of a change of 1 SD in the predictor, etc.)
Hoffman, L. (2015). Longitudinal analysis: Modeling withinperson fluctuation and change. Routledge.
Jones, J. A., & Waller, N. G. (2015). The normaltheory and asymptotic distributionfree (ADF) covariance matrix of standardized regression coefficients: theoretical extensions and finite sample behavior. Psychometrika, 80(2), 365378.
Neter, J., Wasserman, W., & Kutner, M. H. (1989). Applied linear regression models.
Gelman, A. (2008). Scaling regression inputs by dividing by two standard deviations. Statistics in medicine, 27(15), 28652873.
Other standardize:
standardize_info()
,
standardize()
Other effect size indices:
cohens_d()
,
effectsize()
,
eta_squared()
,
phi()
,
rank_biserial()
library(effectsize)
model < lm(len ~ supp * dose, data = ToothGrowth)
standardize_parameters(model, method = "refit")
#> # Standardization method: refit
#>
#> Parameter  Coefficient (std.)  95% CI
#> 
#> (Intercept)  0.24  [ 0.05, 0.44]
#> suppVC  0.48  [0.76, 0.21]
#> dose  0.64  [ 0.45, 0.84]
#> suppVC:dose  0.32  [ 0.04, 0.60]
# \donttest{
standardize_parameters(model, method = "posthoc")
#> # Standardization method: posthoc
#>
#> Parameter  Coefficient (std.)  95% CI
#> 
#> (Intercept)  0.00  [ 0.00, 0.00]
#> suppVC  1.08  [1.66, 0.49]
#> dose  0.64  [ 0.45, 0.84]
#> suppVC:dose  0.32  [ 0.04, 0.60]
standardize_parameters(model, method = "smart")
#> # Standardization method: smart
#>
#> Parameter  Coefficient (std.)  95% CI
#> 
#> (Intercept)  0.00  [ 0.00, 0.00]
#> suppVC  1.00  [1.54, 0.46]
#> dose  0.64  [ 0.45, 0.84]
#> suppVC:dose  0.55  [ 0.07, 1.02]
standardize_parameters(model, method = "basic")
#> # Standardization method: basic
#>
#> Parameter  Coefficient (std.)  95% CI
#> 
#> (Intercept)  0.00  [ 0.00, 0.00]
#> suppVC  0.54  [0.84, 0.25]
#> dose  0.64  [ 0.45, 0.84]
#> suppVC:dose  0.38  [ 0.05, 0.70]
# Robust and 2 SD
standardize_parameters(model, robust = TRUE)
#> # Standardization method: refit
#>
#> Parameter  Coefficient (std.)  95% CI
#> 
#> (Intercept)  0.01  [0.16, 0.18]
#> suppVC  0.48  [0.72, 0.24]
#> dose  0.64  [ 0.44, 0.84]
#> suppVC:dose  0.32  [ 0.04, 0.60]
#>
#>  Scaled by one MAD(s) from the median.
#>
standardize_parameters(model, two_sd = TRUE)
#> # Standardization method: refit
#>
#> Parameter  Coefficient (std.)  95% CI
#> 
#> (Intercept)  0.24  [ 0.05, 0.44]
#> suppVC  0.48  [0.76, 0.21]
#> dose  1.28  [ 0.89, 1.68]
#> suppVC:dose  0.64  [ 0.09, 1.20]
#>
#>  Scaled by two SD(s) from the mean.
#>
model < glm(am ~ cyl * mpg, data = mtcars, family = "binomial")
standardize_parameters(model, method = "refit")
#> # Standardization method: refit
#>
#> Parameter  Coefficient (std.)  95% CI
#> 
#> (Intercept)  0.58  [1.98, 0.70]
#> cyl  0.25  [1.54, 2.10]
#> mpg  2.10  [0.19, 5.28]
#> cyl:mpg  0.36  [2.57, 1.54]
#>
#> (Response is unstandardized)
#>
standardize_parameters(model, method = "posthoc")
#> # Standardization method: posthoc
#>
#> Parameter  Coefficient (std.)  95% CI
#> 
#> (Intercept)  0.00  [ 0.00, 0.00]
#> cyl  1.46  [4.63, 9.37]
#> mpg  3.36  [2.31, 12.59]
#> cyl:mpg  0.20  [1.44, 0.86]
#>
#> (Response is unstandardized)
#>
standardize_parameters(model, method = "basic", exponentiate = TRUE)
#> # Standardization method: basic
#>
#> Parameter  Odds Ratio (std.)  95% CI
#> 
#> (Intercept)  1.00  [1.00, 1.00]
#> cyl  4.32  [0.01, 11681.98]
#> mpg  28.80  [0.10, 2.92e+05]
#> cyl:mpg  0.54  [0.01, 13.94]
#>
#> (Response is unstandardized)
#>
# }
# \donttest{
if (require("lme4")) {
m < lmer(mpg ~ cyl + am + vs + (1  cyl), mtcars)
standardize_parameters(m, method = "pseudo", df_method = "satterthwaite")
}
#> boundary (singular) fit: see ?isSingular
#> Warning: The following withingroup terms have betweengroup variance:
#> am, vs
#> This can inflate standardized withingroup parameters associated with
#> these terms. See help("demean", package = "parameters") for modeling
#> between and withinsubject effects.
#> # Standardization method: pseudo
#>
#> Parameter  Coefficient (std.)  95% CI
#> 
#> (Intercept)  0.00  [ 0.00, 0.00]
#> cyl  0.74  [1.23, 0.26]
#> am  0.47  [ 0.01, 0.93]
#> vs  0.20  [0.47, 0.87]
if (FALSE) {
if (require("rstanarm")) {
model < stan_glm(rating ~ critical + privileges, data = attitude, refresh = 0)
standardize_posteriors(model, method = "refit")
standardize_posteriors(model, method = "posthoc")
standardize_posteriors(model, method = "smart")
head(standardize_posteriors(model, method = "basic"))
}
}
# }