# Load a sample data set
dat <- test_x_1_w_1_v_1_cat1_n_500
head(dat)
# Do a moderated regression by lm
lm_raw <- lm(dv ~ iv*mod + v1 + cat1, dat)
summary(lm_raw)
# Standardize all variables except for categorical variables.
# Interaction terms are formed after standardization.
lm_std <- std_selected(lm_raw, to_scale = ~ .,
to_center = ~ .)
summary(lm_std)
# Update the model
lm_std2 <- update(lm_std, . ~ . - v1)
summary(lm_std2)
Run the code above in your browser using DataLab