#----------------------------------------------------------------------------
# Linear model
# Example 1: Regression model with continuous predictors
mod.lm1 <- lm(mpg ~ cyl + disp, data = mtcars)
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(mpg ~ vs, data = mtcars)
std.coef(mod.lm2)
# Example 4: Regression model with continuous and dichotomous predictors
mod.lm3 <- lm(mpg ~ disp + vs, data = mtcars)
std.coef(mod.lm3)
# Example 5: Regression model with continuous predictors and an interaction term
mod.lm4 <- lm(mpg ~ cyl*disp, data = mtcars)
std.coef(mod.lm4)
# Example 6: Regression model with a quadratic term
mod.lm5 <- lm(mpg ~ cyl + I(cyl^2), data = mtcars)
std.coef(mod.lm5)
if (FALSE) {
#----------------------------------------------------------------------------
# Example 7: Write Results into a Text of Excel file
# Example 7a: Text file
std.coef(mod.lm1, write = "Std_Coef.txt", output = FALSE, check = FALSE)
# Example 7b: Excel file
std.coef(mod.lm1, write = "Std_Coef.xlsx", output = FALSE, check = FALSE)}
Run the code above in your browser using DataLab