library(flextable)
library(manymome)
data(data_med_complicated)
lm_m11 <- lm(m11 ~ x1 + x2, data_med_complicated)
lm_m2 <- lm(m2 ~ x1 + x2, data_med_complicated)
lm_y1 <- lm(y1 ~ m11 + m2 + x1 + x2, data_med_complicated)
fit <- lm2list(lm_m11, lm_m2, lm_y1)
# All indirect paths
paths <- all_indirect_paths(fit,
x = c("x1", "x2"),
y = c("y1"))
# Indirect paths from x1 to y1
paths_x1y1 <- all_indirect_paths(fit,
x = c("x1"),
y = c("y1"))
# Indirect effect estimates
ind <- many_indirect_effects(paths,
fit = fit)
ft_ind <- as_flextable(ind)
ft_ind
ft_ind <- as_flextable(ind, group_by_x = FALSE)
ft_ind
ind_x1y1 <- many_indirect_effects(paths_x1y1,
fit = fit)
ft_ind_x1y1 <- as_flextable(ind_x1y1)
ft_ind_x1y1
# Should set R to 5000 or 10000 in real research
boot_out_lm <- do_boot(fit,
R = 100,
seed = 54532,
parallel = FALSE,
progress = FALSE)
ind_x1y1_ci <- many_indirect_effects(paths_x1y1,
fit = fit,
boot_ci = TRUE,
boot_out = boot_out_lm)
ft_ind_x1y1_ci <- as_flextable(ind_x1y1_ci)
ft_ind_x1y1_ci
Run the code above in your browser using DataLab