Learn R Programming

parameters (version 0.2.0)

parameters_standardize: Parameters standardization

Description

Compute standardized model parameters (coefficients).

Usage

parameters_standardize(model, robust = FALSE, method = "refit",
  verbose = TRUE, ...)

Arguments

model

A statistical model.

robust

Logical, if TRUE, centering is done by substracting the median from the variables and divide it by the median absolute deviation (MAD). If FALSE, variables are standardized by substracting the mean and divide it by the standard deviation (SD).

method

The method used for standardizing the parameters. Can be "refit" (default), "2sd", "smart" or "classic".

verbose

Toggle warnings on or off.

...

Arguments passed to or from other methods.

Value

Standardized parameters.

Details

Methods:

  • refit: This method is based on a complete model re-fit with a standardized version of 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 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.

  • 2sd: Same as method = "refit", however, standardization is done by dividing by two times the SD or MAD (depending on robust). This method is useful to obtain coefficients of continuous parameters comparable to coefficients related to binary predictors (see Gelman, 2008).

  • smart (Standardization of Model's parameters with Adjustment, Reconnaissance and Transformation): Post-hoc standardization of the parameters, aiming at emulating the results obtained by "refit". 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 term, 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.

  • classic: This method is similar to method = "smart", 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 sjstats::std_beta() or lm.beta::lm.beta().

References

  • 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), 2865-2873.

Examples

Run this code
# NOT RUN {
library(parameters)
data(iris)

model <- lm(Sepal.Length ~ Species * Petal.Width, data = iris)
parameters_standardize(model, method = "refit")
parameters_standardize(model, method = "refit", robust = TRUE)
parameters_standardize(model, method = "2sd")
parameters_standardize(model, method = "2sd", robust = TRUE)
parameters_standardize(model, method = "smart")
parameters_standardize(model, method = "smart", robust = TRUE)

iris$binary <- ifelse(iris$Sepal.Width > 3, 1, 0)
model <- glm(binary ~ Species * Sepal.Length, data = iris, family = "binomial")
parameters_standardize(model, method = "refit")
parameters_standardize(model, method = "refit", robust = TRUE)
parameters_standardize(model, method = "smart")
parameters_standardize(model, method = "smart", robust = TRUE)
# }
# NOT RUN {
library(rstanarm)
model <- stan_glm(Sepal.Length ~ Species * Petal.Width, data = iris, iter = 500, refresh = 0)
parameters_standardize(model, method = "smart", centrality = "all")
parameters_standardize(model, method = "smart", robust = TRUE, centrality = "all")
# }

Run the code above in your browser using DataLab