std.coef | R Documentation |
This function computes standardized coefficients for linear models estimated by using the lm()
function.
std.coef(model, print = c("all", "stdx", "stdy", "stdyx"), digits = 3, p.digits = 4,
write = NULL, append = TRUE, check = TRUE, output = TRUE)
model |
a fitted model of class |
print |
a character vector indicating which results to show, i.e. |
digits |
an integer value indicating the number of decimal places to be used for displaying results. |
p.digits |
an integer value indicating the number of decimal places to be used for displaying the p-value. |
write |
a character string naming a text file with file extension
|
append |
logical: if |
check |
logical: if |
output |
logical: if |
The slope \beta
can be standardized with respect to only x
, only y
, or both y
and x
:
StdX(\beta_1) = \beta_1 SD(x)
StdX(\beta_1)
standardizes with respect to x
only and is interpreted as the change in
y
when x
changes one standard deviation referred to as SD(x)
.
StdY(\beta_1) = \frac{\beta_1}{SD(x)}
StdY(\beta_1)
standardizes with respect to y
only and is interpreted as the change in
y
standard deviation units, referred to as SD(y)
, when x
changes one unit.
StdYX(\beta_1) = \beta_1 \frac{SD(x)}{SD(y)}
StdYX(\beta_1)
standardizes with respect to both y
and x
and is interpreted as the change
in y
standard deviation units when x
changes one standard deviation.
Note that the StdYX(\beta_1)
and the StdY(\beta_1)
standardizations are not suitable for the
slope of a binary predictor because a one standard deviation change in a binary variable is generally
not of interest (Muthen, Muthen, & Asparouhov, 2016).
The standardization of the slope \beta_3
in a regression model with an interaction term uses the
product of standard deviations SD(x_1)SD(x_2)
rather than the standard deviation of the product
SD(x_1 x_2)
for the interaction variable x_1
x_2
(see Wen, Marsh & Hau, 2010). Likewise,
the standardization of the slope \beta_3
in a polynomial regression model with a quadratic term
uses the product of standard deviations SD(x)SD(x)
rather than the standard deviation of the
product SD(x x)
for the quadratic term x^2
.
Returns an object of class misty.object
, which is a list with following
entries:
call |
function call |
type |
type of analysis |
model |
model specified in |
args |
specification of function arguments |
result |
list with result tables, i.e., |
Takuya Yanagida takuya.yanagida@univie.ac.at
Muthen, B. O., Muthen, L. K., & Asparouhov, T. (2016). Regression and mediation analysis using Mplus. Muthen & Muthen.
Wen, Z., Marsh, H. W., & Hau, K.-T. (2010). Structural equation models of latent interactions: An appropriate standardized solution and its scale-free properties. Structural Equation Modeling: A Multidisciplinary Journal, 17, 1-22. https://doi.org/10.1080/10705510903438872
dat <- data.frame(x1 = c(3, 2, 4, 9, 5, 3, 6, 4, 5, 6, 3, 5),
x2 = c(1, 4, 3, 1, 2, 4, 3, 5, 1, 7, 8, 7),
x3 = c(0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1),
y = c(2, 7, 4, 4, 7, 8, 4, 2, 5, 1, 3, 8))
#-------------------------------------------------------------------------------
# Linear model
# Example 1: Regression model with continuous predictors
mod.lm1 <- lm(y ~ x1 + x2, data = dat)
std.coef(mod.lm1)
# Example 2: Print all standardized coefficients
std.coef(mod.lm1, print = "all")
# Example 3: Regression model with dichotomous predictor
mod.lm2 <- lm(y ~ x3, data = dat)
std.coef(mod.lm2)
# Example 4: Regression model with continuous and dichotomous predictors
mod.lm3 <- lm(y ~ x1 + x2 + x3, data = dat)
std.coef(mod.lm3)
# Example 5: Regression model with continuous predictors and an interaction term
mod.lm4 <- lm(y ~ x1*x2, data = dat)
# Example 6: Regression model with a quadratic term
mod.lm5 <- lm(y ~ x1 + I(x1^2), data = dat)
std.coef(mod.lm5)
#-------------------------------------------------------------------------------
# Example 7: Write Results into an Excel file
## Not run:
mod.lm1 <- lm(y ~ x1 + x2, data = dat)
std.coef(mod.lm1, write = "Std_Coef.xlsx", output = FALSE)
result <- std.coef(mod.lm1, output = FALSE)
write.result(result, "Std_Coef.xlsx")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.