# 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)
# Standardize all variables except for categorical variables.
# Interaction terms are formed after standardization.
lm_std <- std_selected(lm_raw, to_scale = ~ .,
to_center = ~ .)
# VCOV of lm output
vcov(lm_std)
# Standardize all variables as in std_selected above, and compute the
# nonparametric bootstrapping percentile confidence intervals.
lm_std_boot <- std_selected_boot(lm_raw,
to_scale = ~ .,
to_center = ~ .,
conf = .95,
nboot = 100)
# In real analysis, nboot should be at least 2000.
# VCOV of bootstrap estimates, default when bootstrap was conducted
vcov(lm_std_boot)
# For OLS VCOV
vcov(lm_std_boot, type = "lm")
Run the code above in your browser using DataLab