This AutoMC-based function demonstration including following 6 sections:
Section 2: Mediation for MONO-LEVEL
Section 3: Mediation for MULTILEVEL-LEVEL
Section 4: Mediated moderation for MONO-LEVEL (NO CONTROL)
Section 5: Mediated moderation for MONO-LEVEL (WITH CONTROL)
Section 6: Mediated moderation for MULTILEVEL-LEVEL (NO CONTROL)
Section 7: Mediated moderation for MULTILEVEL-LEVEL (WITH CONTROL)
wrapTextForChinese <- function(text, maxWidth = 40) {
# PURPOSE: This function is used to bring the Chinese text when knit rmd for html format.
#EXAMPLE: For illustrative example, please refer to the section "1.3.5 AutoMC.Me()" of 'Auto.Me Illustration' file in this link: https://rpubs.com/EasonZhang.
lines <- unlist(strsplit(text, split = "\n")) # 首先按原有换行符分割文本
wrappedLines <- c()
for (line in lines) {
while (nchar(line, type = "width") > maxWidth) {
# 查找在 maxWidth 限制内的最后一个可能的断行点
breakPosition <- maxWidth
if (grepl("!", substr(line, 1, maxWidth))) {
# 如果在当前行的前maxWidth个字符中存在"!",找到最后一个"!"的位置作为断行点
breakPosition <- max(unlist(gregexpr("!", substr(line, 1, maxWidth))))
}
# 添加当前断行点之前的文本到wrappedLines
wrappedLines <- c(wrappedLines, substr(line, 1, breakPosition))
# 移除已经添加的部分
line <- substr(line, breakPosition + 1, nchar(line))
}
# 添加剩余的部分(如果有)
if (nchar(line) > 0) {
wrappedLines <- c(wrappedLines, line)
}
}
# 使用cat打印最终结果
cat(paste(wrappedLines, collapse = "\n"))
}
wrapText <- function(text, width = 80) {
# PURPOSE: This function is used to bring the English text when knit rmd for html format.
#EXAMPLE: For illustrative example, please refer to the section "1.3.5 AutoMC.Me()" of 'Auto.Me Illustration' file in this link: https://rpubs.com/EasonZhang.
words <- unlist(strsplit(text, split = " ")) # 将文本拆分为单词
wrappedText <- ""
currentLineLength <- 0
for (word in words) {
# 检查添加当前单词是否会超过宽度限制
if (currentLineLength + nchar(word, type="width") <= width) {
# 当前行添加单词
wrappedText <- ifelse(currentLineLength > 0, paste0(wrappedText, " ", word), paste0(wrappedText, word))
currentLineLength <- currentLineLength + nchar(word, type="width") + 1 # 加1因为空格
} else {
# 超过宽度限制,从新行开始
wrappedText <- paste0(wrappedText, "\n", word)
currentLineLength <- nchar(word, type="width")
}
}
cat(wrappedText)
}
# 定义函数
getRNames <- function(model, rows = NULL) {
# PURPOSE: This function is used to get variables name of model based on lm()/lmer()
#EXAMPLE: For illustrative example, please refer to the section "2.3.2 AutoMC.Me with getRNames()" of 'Auto.Me Illustration' file in this link: https://rpubs.com/EasonZhang.
# 获取模型系数的行名
coefficientRowNames <- rownames(summary(model)$coefficients)
# 如果指定了rows,则仅返回指定行的行名
if (!is.null(rows)) {
# 确保rows中的索引不超出行名向量的长度
rows <- rows[rows <= length(coefficientRowNames)]
coefficientRowNames <- coefficientRowNames[rows]
}
# 返回行名或指定行的行名
return(coefficientRowNames)
}
### https://rdrr.io/cran/bruceR/src/R/deprecated.R
med_mc=function(a, SEa, b, SEb,cov_ab=0, seed=NULL, rep=5000, conf=0.95) {
# http://www.quantpsy.org/medmc/medmc.htm
if(!is.null(seed)) set.seed(seed)
acov=matrix(c(
SEa^2, cov_ab,
cov_ab, SEb^2
), 2, 2)
mcmc=MASS::mvrnorm(rep, c(a, b), acov, empirical=FALSE)
abMC=mcmc[,1]*mcmc[,2]
ab=mean(abMC)
SEab=stats::sd(abMC)
# z=ab/SEab
# p=p.z(z)
abLLCI=as.numeric(stats::quantile(abMC, (1-conf)/2)) # 0.025
abULCI=as.numeric(stats::quantile(abMC, 1-(1-conf)/2)) # 0.975
sig=ifelse(abLLCI>0 | abULCI<0, "yes", "no")
out=data.frame(ab, SEab, a, SEa, b, SEb, abLLCI, abULCI, sig)
row.names(out)="Monte Carlo"
#Print("Mediation (rep=5000):")
#print_table(out)#, digits=3)
return(out)
}
#EXAMPLE: med_mc(a=.348, SEa=.078, b=.145, SEb=.057)
#print_table(pmacro)
#covar=list(names=c("C"),site=list(c("M","Y")))
pmacroModel(4,labels=list(X="Predictor", M="Mediator", Y="Outcome"))#covar=covar,
#note=F, Cnote=F,
AutoMC.Me <- function(aModel, bModel, pathA=c(labels(terms(aModel))[1]), pathB=c(labels(terms(bModel))[1]), note=F, Cnote=F, OutTable = T, OutReg = T, cov_ab=0, seed=1223, rep=5000, conf=0.95) {
if (Cnote) {
CinstructionText <- "AutoMC.Me() 的使用范围:
- Xs=>M=>Y:AutoMC.Me()可应用于一个或多个X,通过一个M影响一个Y的模型。
- X=>M=>Ys:AutoMC.Me()也可应用于一个X,通过一个M影响一个或多个Y的模型,但此时就要互换aModel和bModel的位置。这种通过灵巧变化扩展函数的应用范围是非常常见的(如,Hayes 2013:小节11.3通过把X作为控制变量用model1估计model14的第二阶段调节效应;附录B关于“在同一模型中将调节变量作为协变量”)。\n
使用要点:
- 默认设定pathA and pathB: 默认设定会计算一个X通过一个M对Y的中介效应。这种情况下不需对路径上的预测因子做任何的设定,此时,必须要参Cnote里关于aModel和bModel的模型自动设定说明。
- 手动设定pathA:但是如果要计算多个pathA上面的预测因子的中介效应。可以通过cc()直接输入需要的pathA的预测因子,或通过getRNames()来选择需要的预测因子。
- 手动设定pathB:99%的情况下pathB都应该使用默认设定,若要手动设定,则和pathA的设定方式一样。
- 自动设定aModel:M ~ X 的模型,如需使用默认设定,X 必须是 aModel 中的第一个预测变量,例如 `lm(M~X+Control1+Control2...)`。
- 自动设定bModel:Y ~ M 的模型,如需使用默认设定,M 必须是 bModel 中的第一个预测变量,例如 `lm(Y~M+X+Control1+Control2...)` \n
\n---------------------------------------------------- \n "
# 使用函数处理并打印文本
wrapTextForChinese(CinstructionText, maxWidth = 55)
}
if (note) {
instructionText <- " INSTRUCTION: AutoMC.Me() is an R function developed by Prof. Yucheng Zhang (University of Southampton), adapted from the Selig & Preacher's (2008) web (http://www.quantpsy.org/medmc/medmc.htm) and bruceR package (https://github.com/psychbruce/bruceR/blob/main/R/deprecated.R), for conducting straightforward lm() based single-level and lmerTest::lmer() based multilevel mediation or mediated moderation analysis. The overall structure of the function is as follows: 'function(aModel, bModel, pathA=c(labels(terms(aModel))[1]), pathB=c(labels(terms(bModel))[1]), note=F, Cnote=F, OutTable = T, OutReg = T, cov_ab=0, seed=1223, rep=5000, conf=0.95)'. This function includes FOUR key parameters (aModel, bModel, pathA=c(labels(terms(aModel))[1]), pathB=c(labels(terms(bModel))[1])) and EIGHT supportive parameters (note=F, Cnote=F, OutTable = T, OutReg = T, cov_ab=0, seed=1223, rep=5000, conf=0.95)
\n EIGHT supportive parameters
- Cnote=F: This parameter has default settings to NOT read the key instruction of this function in Chinese and do not need to be explicitly set. However, if instruction is desired, pls set note=T.
- note=F: This parameter has default settings to NOT read the instruction of this function and do not need to be explicitly set. However, if instruction is desired, pls set note=T.
- OutTable=T: This parameter has default settings to print the output using bruceR::print_table(). However, if the table is NOT desired, pls set it to F.
- OutReg=T: This parameter has default settings to print the output of aModel and bModel using bruceR::model_summary(). However, if the table is NOT desired, pls set it to F.
- seed=1223: The seed parameter is used to set the seed for random number generation. In statistical analyses that involve random processes or simulations, setting a seed ensures reproducibility. When the same seed is used, the sequence of random numbers generated remains the same, allowing others to replicate the analysis exactly. In the context of this function, seed=1223 sets the seed to the specific value 1223, which can be reset to the value user prefer.
- rep=5000: The rep parameter stands for repetitions. In statistical simulations or bootstrap analyses, it represents the number of times a particular process or analysis is repeated. In this function, rep=5000 indicates that the specified analysis or computation will be repeated 5000 times, which can be reset to the value user prefer.
- conf=0.95: The conf parameter typically refers to the confidence level. In statistical terms, the confidence level represents the probability that a parameter (e.g., a mean or an effect size) falls within a certain interval. In this context, conf=0.95 suggests a 95% confidence level, meaning that there is a 95% probability that the results or estimates produced by the function are within a specific range, which can be reset to the value user prefer.
- cov_ab=0: If you use SEM, path analysis, multilevel modeling, or some other multivariate method to obtain both a and b from a single model, then cov(a,b) can be found in the asymptotic covariance matrix of the parameter estimates. If on lm() or lmer() is applied, you use regression to obtain a and b in separate steps, then cov(a,b) = 0, which is the default setting.\n
EXAMPLES
For application examples and comparative results with the bruceR::PROCESS() function, please refer to the 'AutoMC.Me Illustration' file for different types of mediation analysis (section 2.1.3, 2.2.2, 2.3.2, 3.2.2, and 3.3.2) and mediated moderation analysis (section xxx and xxx) in this link: https://rpubs.com/EasonZhang.\n
----------------------------------------------------
"
wrapText(instructionText, width = 80)
}
# 提取a路径系数和标准误
aCoefficients <- summary(aModel)$coefficients
a <- aCoefficients[pathA, "Estimate"] # 使用变量名提取系数估计值
SEa <- aCoefficients[pathA, "Std. Error"] # 使用变量名提取标准误
# 提取b路径系数和标准误
bCoefficients <- summary(bModel)$coefficients
b <- bCoefficients[pathB, "Estimate"] # 使用变量名提取系数估计值
SEb <- bCoefficients[pathB, "Std. Error"] # 使用变量名提取标准误
# 初始化一个空的数据框用于存储所有结果
allMediationResults <- data.frame()
# 确保a和b是向量
a <- as.numeric(a)
SEa <- as.numeric(SEa)
b <- as.numeric(b)
SEb <- as.numeric(SEb)
# 对每个a和b的组合进行循环计算
for(i in 1:length(a)) {
# 计算协方差,默认为0(此部分可根据实际情况进行调整)
cov_ab <- 0 # 在这个简化的例子中,我们假设协方差为0
# 调用med_mc函数计算当前组合的中介效应
mediationResult <- med_mc(a[i], SEa[i], b, SEb, cov_ab, seed=seed, rep=rep, conf=conf)
# 创建Effects变量,每行都填充"Monte Carlo based Mediation"
mediationResult$Effects <- "Monte Carlo based Mediation"
# 将当前结果合并到allMediationResults数据框中
allMediationResults <- rbind(allMediationResults, mediationResult)
}
# 将Effects列移动到数据框的第一列
allMediationResults <- allMediationResults[, c("Effects", setdiff(names(allMediationResults), "Effects"))]
row.names(allMediationResults)=NULL
#
if (OutReg) {model_summary(list(aModel, bModel))}
if (OutTable) {print_table(allMediationResults,title = "Effects of Mediation (rep=5000, seed=1223 if not preset):")}
# 返回合并后的数据框
return(allMediationResults)
}
##
## ****************** PART 1. Regression Model Summary ******************
##
## PROCESS Model Code : 4 (Hayes, 2018; www.guilford.com/p/hayes3)
## PROCESS Model Type : Simple Mediation
## - Outcome (Y) : Y
## - Predictor (X) : X
## - Mediators (M) : M
## - Moderators (W) : -
## - Covariates (C) : C1
## - HLM Clusters : -
##
## Formula of Mediator:
## - M ~ C1 + X
## Formula of Outcome:
## - Y ~ C1 + X + M
##
## CAUTION:
## Fixed effect (coef.) of a predictor involved in an interaction
## denotes its "simple effect/slope" at the other predictor = 0.
## Only when all predictors in an interaction are mean-centered
## can the fixed effect denote the "main effect"!
##
## Model Summary
##
## ─────────────────────────────────────────────────────
## (1) Y (2) M (3) Y
## ─────────────────────────────────────────────────────
## (Intercept) 48.790 *** 8.424 *** 39.663 ***
## (0.154) (0.036) (0.385)
## C1Male 1.474 *** 0.108 * 1.358 ***
## (0.188) (0.044) (0.182)
## X 5.537 *** 1.793 *** 3.594 ***
## (0.190) (0.044) (0.199)
## M 1.083 ***
## (0.042)
## ─────────────────────────────────────────────────────
## R^2 0.087 0.146 0.145
## Adj. R^2 0.086 0.146 0.145
## Num. obs. 9679 9679 9679
## ─────────────────────────────────────────────────────
## Note. * p < .05, ** p < .01, *** p < .001.
##
## ************ PART 2. Mediation/Moderation Effect Estimate ************
##
## Package Use : ‘mediation’ (v4.5.0)
## Effect Type : Simple Mediation (Model 4)
## Sample Size : 9679
## Random Seed : set.seed(1223)
## Simulations : 1000 (Monte Carlo)
##
## Running 1000 simulations...
## Indirect Path: "X" (X) ==> "M" (M) ==> "Y" (Y)
## ─────────────────────────────────────────────────────────────
## Effect S.E. z p [MCMC 95% CI]
## ─────────────────────────────────────────────────────────────
## Indirect (ab) 1.949 (0.091) 21.412 <.001 *** [1.772, 2.134]
## Direct (c') 3.586 (0.201) 17.816 <.001 *** [3.192, 3.998]
## Total (c) 5.534 (0.190) 29.203 <.001 *** [5.147, 5.908]
## ─────────────────────────────────────────────────────────────
## Monte Carlo (Quasi-Bayesian) Confidence Interval
## (Effect, SE, and CI are estimated based on 1000 Monte Carlo samples.)
##
## Note. The results based on bootstrapping or other random processes
## are unlikely identical to other statistical software (e.g., SPSS).
## To make results reproducible, you need to set a seed (any number).
## Please see the help page for details: help(PROCESS)
## Ignore this note if you have already set a seed. :)
aModel=lm(M ~ X + C1,data=Me.data)
#summary(aModel)$coefficients
bModel=lm(Y ~ M + X + C1,data=Me.data)
#Me=AutoMC.Me(aModel,bModel,note=T,Cnote=T)
Me=AutoMC.Me(aModel,bModel,seed=3232,rep = 1000,note=T,Cnote=T)#,cc("X"),cc("M"))
## AutoMC.Me() 的使用范围:
## - Xs=>M=>Y:AutoMC.Me()可应用于一个或多个X,通过一个M影响一个Y的模型。
## - X=>M=>Ys:AutoMC.Me()也可应用于一个X,通过一个M影响一个或多个Y的模型,但此时
## 就要互换aModel和bModel的位置。这种通过灵巧变化扩展函数的应用范围是非常常见的(如,Hayes 20
## 13:小节11.3通过把X作为控制变量用model1估计model14的第二阶段调节效应;附录B关于“在同一模
## 型中将调节变量作为协变量”)。
##
## 使用要点:
## - 默认设定pathA and pathB: 默认设定会计算一个X通过一个M对Y的中介效应。这种情况下
## 不需对路径上的预测因子做任何的设定,此时,必须要参Cnote里关于aModel和bModel的模型自动设定说明
## 。
## - 手动设定pathA:但是如果要计算多个pathA上面的预测因子的中介效应。可以通过cc()直接输入
## 需要的pathA的预测因子,或通过getRNames()来选择需要的预测因子。
## - 手动设定pathB:99%的情况下pathB都应该使用默认设定,若要手动设定,则和pathA的设定
## 方式一样。
## - 自动设定aModel:M ~ X 的模型,如需使用默认设定,X 必须是 aModel 中的第一个预
## 测变量,例如 `lm(M~X+Control1+Control2...)`。
## - 自动设定bModel:Y ~ M 的模型,如需使用默认设定,M 必须是 bModel 中的第一个预
## 测变量,例如 `lm(Y~M+X+Control1+Control2...)`
## ----------------------------------------------------
## INSTRUCTION: AutoMC.Me() is an R function developed by Prof. Yucheng Zhang
## (University of Southampton), adapted from the Selig & Preacher's (2008) web
## (http://www.quantpsy.org/medmc/medmc.htm) and bruceR package
## (https://github.com/psychbruce/bruceR/blob/main/R/deprecated.R), for conducting
## straightforward lm() based single-level and lmerTest::lmer() based multilevel
## mediation or mediated moderation analysis. The overall structure of the function
## is as follows: 'function(aModel, bModel, pathA=c(labels(terms(aModel))[1]),
## pathB=c(labels(terms(bModel))[1]), note=F, Cnote=F, OutTable = T, OutReg = T,
## cov_ab=0, seed=1223, rep=5000, conf=0.95)'. This function includes FOUR key
## parameters (aModel, bModel, pathA=c(labels(terms(aModel))[1]),
## pathB=c(labels(terms(bModel))[1])) and EIGHT supportive parameters (note=F,
## Cnote=F, OutTable = T, OutReg = T, cov_ab=0, seed=1223, rep=5000, conf=0.95)
##
##
## EIGHT supportive parameters
## - Cnote=F: This parameter has default settings to
## NOT read the key instruction of this function in Chinese and do not need to be
## explicitly set. However, if instruction is desired, pls set note=T.
## - note=F:
## This parameter has default settings to NOT read the instruction of this function
## and do not need to be explicitly set. However, if instruction is desired, pls set
## note=T.
## - OutTable=T: This parameter has default settings to print the output
## using bruceR::print_table(). However, if the table is NOT desired, pls set it to
## F.
## - OutReg=T: This parameter has default settings to print the output of
## aModel and bModel using bruceR::model_summary(). However, if the table is NOT
## desired, pls set it to F.
## - seed=1223: The seed parameter is used to set the
## seed for random number generation. In statistical analyses that involve random
## processes or simulations, setting a seed ensures reproducibility. When the same
## seed is used, the sequence of random numbers generated remains the same, allowing
## others to replicate the analysis exactly. In the context of this function,
## seed=1223 sets the seed to the specific value 1223, which can be reset to the
## value user prefer.
## - rep=5000: The rep parameter stands for repetitions. In
## statistical simulations or bootstrap analyses, it represents the number of times
## a particular process or analysis is repeated. In this function, rep=5000
## indicates that the specified analysis or computation will be repeated 5000 times,
## which can be reset to the value user prefer.
## - conf=0.95: The conf parameter
## typically refers to the confidence level. In statistical terms, the confidence
## level represents the probability that a parameter (e.g., a mean or an effect
## size) falls within a certain interval. In this context, conf=0.95 suggests a 95%
## confidence level, meaning that there is a 95% probability that the results or
## estimates produced by the function are within a specific range, which can be
## reset to the value user prefer.
## - cov_ab=0: If you use SEM, path analysis,
## multilevel modeling, or some other multivariate method to obtain both a and b
## from a single model, then cov(a,b) can be found in the asymptotic covariance
## matrix of the parameter estimates. If on lm() or lmer() is applied, you use
## regression to obtain a and b in separate steps, then cov(a,b) = 0, which is the
## default setting.
##
##
## EXAMPLES
## For application examples and comparative results with the
## bruceR::PROCESS() function, please refer to the 'AutoMC.Me Illustration' file for
## different types of mediation analysis (section 2.1.3, 2.2.2, 2.3.2, 3.2.2, and
## 3.3.2) and mediated moderation analysis (section xxx and xxx) in this link:
## https://rpubs.com/EasonZhang.
##
## ----------------------------------------------------
##
## Model Summary
##
## ───────────────────────────────────────
## (1) M (2) Y
## ───────────────────────────────────────
## (Intercept) 8.424 *** 39.663 ***
## (0.036) (0.385)
## X 1.793 *** 3.594 ***
## (0.044) (0.199)
## C1Male 0.108 * 1.358 ***
## (0.044) (0.182)
## M 1.083 ***
## (0.042)
## ───────────────────────────────────────
## R^2 0.146 0.145
## Adj. R^2 0.146 0.145
## Num. obs. 9679 9679
## ───────────────────────────────────────
## Note. * p < .05, ** p < .01, *** p < .001.
##
## Effects of Mediation (rep=5000, seed=1223 if not preset):
## ────────────────────────────────────────────────────────────────────────────────────
## Effects ab SEab a SEa b SEb abLLCI abULCI sig
## ────────────────────────────────────────────────────────────────────────────────────
## 1 Monte Carlo based Mediation 1.939 0.088 1.793 0.044 1.083 0.042 1.780 2.112 yes
## ────────────────────────────────────────────────────────────────────────────────────
PROCESS(Me.data, y="Y", x="W",
meds="M", covs=cc("C1,X"),
ci="mcmc", nsim=1000, seed=1223,center = F)
##
## ****************** PART 1. Regression Model Summary ******************
##
## PROCESS Model Code : 4 (Hayes, 2018; www.guilford.com/p/hayes3)
## PROCESS Model Type : Simple Mediation
## - Outcome (Y) : Y
## - Predictor (X) : W
## - Mediators (M) : M
## - Moderators (W) : -
## - Covariates (C) : C1, X
## - HLM Clusters : -
##
## Formula of Mediator:
## - M ~ C1 + X + W
## Formula of Outcome:
## - Y ~ C1 + X + W + M
##
## CAUTION:
## Fixed effect (coef.) of a predictor involved in an interaction
## denotes its "simple effect/slope" at the other predictor = 0.
## Only when all predictors in an interaction are mean-centered
## can the fixed effect denote the "main effect"!
##
## Model Summary
##
## ─────────────────────────────────────────────────────
## (1) Y (2) M (3) Y
## ─────────────────────────────────────────────────────
## (Intercept) 53.246 *** 9.687 *** 45.144 ***
## (0.231) (0.053) (0.478)
## C1Male 1.366 *** 0.077 1.302 ***
## (0.183) (0.042) (0.179)
## X 4.265 *** 1.433 *** 3.067 ***
## (0.191) (0.044) (0.197)
## W -1.288 *** -0.365 *** -0.983 ***
## (0.051) (0.012) (0.052)
## M 0.836 ***
## (0.043)
## ─────────────────────────────────────────────────────
## R^2 0.143 0.224 0.175
## Adj. R^2 0.143 0.224 0.174
## Num. obs. 9679 9679 9679
## ─────────────────────────────────────────────────────
## Note. * p < .05, ** p < .01, *** p < .001.
##
## ************ PART 2. Mediation/Moderation Effect Estimate ************
##
## Package Use : ‘mediation’ (v4.5.0)
## Effect Type : Simple Mediation (Model 4)
## Sample Size : 9679
## Random Seed : set.seed(1223)
## Simulations : 1000 (Monte Carlo)
##
## Running 1000 simulations...
## Indirect Path: "W" (X) ==> "M" (M) ==> "Y" (Y)
## ────────────────────────────────────────────────────────────────
## Effect S.E. z p [MCMC 95% CI]
## ────────────────────────────────────────────────────────────────
## Indirect (ab) -0.306 (0.018) -16.843 <.001 *** [-0.342, -0.271]
## Direct (c') -0.982 (0.051) -19.114 <.001 *** [-1.086, -0.882]
## Total (c) -1.287 (0.049) -26.154 <.001 *** [-1.390, -1.192]
## ────────────────────────────────────────────────────────────────
## Monte Carlo (Quasi-Bayesian) Confidence Interval
## (Effect, SE, and CI are estimated based on 1000 Monte Carlo samples.)
##
## Note. The results based on bootstrapping or other random processes
## are unlikely identical to other statistical software (e.g., SPSS).
## To make results reproducible, you need to set a seed (any number).
## Please see the help page for details: help(PROCESS)
## Ignore this note if you have already set a seed. :)
aModel=lm(M ~ X + W + C1,data=Me.data)
#summary(aModel)$coefficients
bModel=lm(Y ~ M + X + W + C1,data=Me.data)
#Me=AutoMC.Me(aModel,bModel,note=T,Cnote=T)
Me=AutoMC.Me(aModel,bModel,cc("X,W"))#,cc("M"))
##
## Model Summary
##
## ───────────────────────────────────────
## (1) M (2) Y
## ───────────────────────────────────────
## (Intercept) 9.687 *** 45.144 ***
## (0.053) (0.478)
## X 1.433 *** 3.067 ***
## (0.044) (0.197)
## W -0.365 *** -0.983 ***
## (0.012) (0.052)
## C1Male 0.077 1.302 ***
## (0.042) (0.179)
## M 0.836 ***
## (0.043)
## ───────────────────────────────────────
## R^2 0.224 0.175
## Adj. R^2 0.224 0.174
## Num. obs. 9679 9679
## ───────────────────────────────────────
## Note. * p < .05, ** p < .01, *** p < .001.
##
## Effects of Mediation (rep=5000, seed=1223 if not preset):
## ──────────────────────────────────────────────────────────────────────────────────────
## Effects ab SEab a SEa b SEb abLLCI abULCI sig
## ──────────────────────────────────────────────────────────────────────────────────────
## 1 Monte Carlo based Mediation 1.197 0.071 1.433 0.044 0.836 0.043 1.062 1.339 yes
## 2 Monte Carlo based Mediation -0.306 0.018 -0.365 0.012 0.836 0.043 -0.343 -0.271 yes
## ──────────────────────────────────────────────────────────────────────────────────────
## Error in PROCESS(Me.data, y = "Y", x = "Xc", meds = "M", covs = "C1", : "x" should be a numeric variable or a factor variable with only 2 levels.
If you run a model using PROCESS() for a categorical predictor that has more than two levels, PROCESS() will show:“Error in PROCESS()”x” should be a numeric variable or a factor variable with only 2 levels.” This is because PROCESS() can not run this model, because “x” in PROCESS() should be a numeric variable or a factor variable with only 2 levels.
aModel=lm(M ~ Xc + C1,data=Me.data)
bModel=lm(Y ~ M + Xc + C1,data=Me.data)
#Me=AutoMC.Me(aModel,bModel,note=T,Cnote=T)
pathA <- getRNames(aModel, rows = c(2:6))
Me=AutoMC.Me(aModel,bModel,pathA) #,cc("X"),cc("M"))
##
## Model Summary
##
## ───────────────────────────────────────
## (1) M (2) Y
## ───────────────────────────────────────
## (Intercept) 9.342 *** 40.283 ***
## (0.050) (0.417)
## Xc2 -0.096 -1.411 ***
## (0.059) (0.228)
## Xc3 -0.214 ** -2.246 ***
## (0.068) (0.263)
## Xc4 -0.394 *** -3.457 ***
## (0.116) (0.449)
## Xc5 -0.620 *** -3.697 ***
## (0.100) (0.389)
## C1Male 0.129 ** 1.361 ***
## (0.047) (0.184)
## M 1.343 ***
## (0.039)
## ───────────────────────────────────────
## R^2 0.006 0.130
## Adj. R^2 0.005 0.129
## Num. obs. 9679 9679
## ───────────────────────────────────────
## Note. * p < .05, ** p < .01, *** p < .001.
##
## Effects of Mediation (rep=5000, seed=1223 if not preset):
## ──────────────────────────────────────────────────────────────────────────────────────
## Effects ab SEab a SEa b SEb abLLCI abULCI sig
## ──────────────────────────────────────────────────────────────────────────────────────
## 1 Monte Carlo based Mediation -0.129 0.078 -0.096 0.059 1.343 0.039 -0.283 0.029 no
## 2 Monte Carlo based Mediation -0.288 0.091 -0.214 0.068 1.343 0.039 -0.466 -0.104 yes
## 3 Monte Carlo based Mediation -0.530 0.154 -0.394 0.116 1.343 0.039 -0.835 -0.218 yes
## 4 Monte Carlo based Mediation -0.833 0.135 -0.620 0.100 1.343 0.039 -1.103 -0.560 yes
## 5 Monte Carlo based Mediation 0.173 0.063 0.129 0.047 1.343 0.039 0.048 0.300 yes
## ──────────────────────────────────────────────────────────────────────────────────────
#print_table(pmacro) #covar=list(names=c("C"),site=list(c("M","Y")))
pmacroModel(4,labels=list(X="Predictor", M="Mediators", Y="Outcome"))#covar=covar,
PROCESS(Me.data, y="Y", x="X",
meds="M", clusters="clus",
ci="mcmc", covs="C1", nsim=1000, seed=1223,center = F)
##
## ****************** PART 1. Regression Model Summary ******************
##
## PROCESS Model Code : 4 (Hayes, 2018; www.guilford.com/p/hayes3)
## PROCESS Model Type : Simple Mediation
## - Outcome (Y) : Y
## - Predictor (X) : X
## - Mediators (M) : M
## - Moderators (W) : -
## - Covariates (C) : C1
## - HLM Clusters : clus
##
## Formula of Mediator:
## - M ~ C1 + X + (1 | clus)
## Formula of Outcome:
## - Y ~ C1 + X + M + (1 | clus)
##
## CAUTION:
## Fixed effect (coef.) of a predictor involved in an interaction
## denotes its "simple effect/slope" at the other predictor = 0.
## Only when all predictors in an interaction are mean-centered
## can the fixed effect denote the "main effect"!
##
## Model Summary
##
## ──────────────────────────────────────────────────────────────────
## (1) Y (2) M (3) Y
## ──────────────────────────────────────────────────────────────────
## (Intercept) 49.321 *** 8.580 *** 42.181 ***
## (0.219) (0.049) (0.416)
## C1Male 1.458 *** 0.071 1.403 ***
## (0.180) (0.042) (0.178)
## X 3.922 *** 1.398 *** 2.878 ***
## (0.190) (0.045) (0.196)
## M 0.828 ***
## (0.042)
## ──────────────────────────────────────────────────────────────────
## Marginal R^2 0.048 0.093 0.094
## Conditional R^2 0.207 0.225 0.213
## AIC 69749.830 41706.336 69395.406
## BIC 69785.718 41742.224 69438.472
## Num. obs. 9679 9679 9679
## Num. groups: clus 568 568 568
## Var: clus (Intercept) 14.509 0.686 10.613
## Var: Residual 72.425 4.020 70.638
## ──────────────────────────────────────────────────────────────────
## Note. * p < .05, ** p < .01, *** p < .001.
##
## ************ PART 2. Mediation/Moderation Effect Estimate ************
##
## Package Use : ‘mediation’ (v4.5.0)
## Effect Type : Simple Mediation (Model 4)
## Sample Size : 9679
## Random Seed : set.seed(1223)
## Simulations : 1000 (Monte Carlo)
##
## Running 1000 simulations...
## Indirect Path: "X" (X) ==> "M" (M) ==> "Y" (Y)
## ─────────────────────────────────────────────────────────────
## Effect S.E. z p [MCMC 95% CI]
## ─────────────────────────────────────────────────────────────
## Indirect (ab) 1.162 (0.070) 16.697 <.001 *** [1.028, 1.299]
## Direct (c') 2.879 (0.193) 14.945 <.001 *** [2.502, 3.244]
## Total (c) 4.042 (0.190) 21.283 <.001 *** [3.671, 4.400]
## ─────────────────────────────────────────────────────────────
## Monte Carlo (Quasi-Bayesian) Confidence Interval
## (Effect, SE, and CI are estimated based on 1000 Monte Carlo samples.)
##
## Note. The results based on bootstrapping or other random processes
## are unlikely identical to other statistical software (e.g., SPSS).
## To make results reproducible, you need to set a seed (any number).
## Please see the help page for details: help(PROCESS)
## Ignore this note if you have already set a seed. :)
MLM.aModel=lmer(M ~ X + C1 + (1 | clus), na.action = na.exclude, data = Me.data, control=lmerControl(optimizer="bobyqa"))
MLM.bModel=lmer(Y ~ M+ X + C1 + (1 | clus), na.action = na.exclude, data = Me.data, control=lmerControl(optimizer="bobyqa"))
MLM.Me=AutoMC.Me(MLM.aModel,MLM.bModel)#,cc("M"))
##
## Model Summary
##
## ───────────────────────────────────────────────────
## (1) M (2) Y
## ───────────────────────────────────────────────────
## (Intercept) 8.580 *** 42.181 ***
## (0.049) (0.416)
## X 1.398 *** 2.878 ***
## (0.045) (0.196)
## C1Male 0.071 1.403 ***
## (0.042) (0.178)
## M 0.828 ***
## (0.042)
## ───────────────────────────────────────────────────
## Marginal R^2 0.093 0.094
## Conditional R^2 0.225 0.213
## AIC 41706.336 69395.406
## BIC 41742.224 69438.472
## Num. obs. 9679 9679
## Num. groups: clus 568 568
## Var: clus (Intercept) 0.686 10.613
## Var: Residual 4.020 70.638
## ───────────────────────────────────────────────────
## Note. * p < .05, ** p < .01, *** p < .001.
##
## Effects of Mediation (rep=5000, seed=1223 if not preset):
## ────────────────────────────────────────────────────────────────────────────────────
## Effects ab SEab a SEa b SEb abLLCI abULCI sig
## ────────────────────────────────────────────────────────────────────────────────────
## 1 Monte Carlo based Mediation 1.157 0.069 1.398 0.045 0.828 0.042 1.026 1.294 yes
## ────────────────────────────────────────────────────────────────────────────────────
#ZmTitle=data.frame("Effects" = "Mono-level mediation")
#ZyTitle=data.frame("Effects" = "Multilevel mediation")
#SurfaceValues=rbindlist(list(ZmTitle,Me,ZyTitle,MLM.Me),fill = TRUE)%>%print_table()#%>%as.data.table()
MLM.summary=Combine.AutoMC(list(Me,MLM.Me),cc("MONO-LEVEL MEDIATION,MLM-BASED MEDIATION"),note=T)
##
## INSTRUCTION: CombineMultipleAutoMC() is an R function for combining MULTIPLE
## OUTPUTS based on AutoMC-Related function (e.g., AutoMC.Me). It takes a list of
## data frames as input along with their titles.
##
## EXAMPLES: For illustrative example,
## please refer to the section '3.2.3 Summary of mediation using Combine.AutoMC() of
## 'Auto.Me Illustration' file in this link: https://rpubs.com/EasonZhang.
##
##
## PARAMETERS:
## - autoMCList: A list of data frames, each being the output of an
## AutoMC-related function.
## - titles: A vector of titles for each data frame in
## autoMCList.
## - note: Whether to print the instructional note.
## - OutTable: Whether
## to print the combined output as a
## table.
## ---------------------------------------------------------------------
## Effects of Mediation (rep=5000, seed=1223 if not preset):
## ───────────────────────────────────────────────────────────────────────────────
## Effects ab SEab a SEa b SEb abLLCI abULCI sig
## ───────────────────────────────────────────────────────────────────────────────
## 1 MONO-LEVEL MEDIATION -0.129 0.078 -0.096 0.059 1.343 0.039 -0.283 0.029 no
## 2 MONO-LEVEL MEDIATION -0.288 0.091 -0.214 0.068 1.343 0.039 -0.466 -0.104 yes
## 3 MONO-LEVEL MEDIATION -0.530 0.154 -0.394 0.116 1.343 0.039 -0.835 -0.218 yes
## 4 MONO-LEVEL MEDIATION -0.833 0.135 -0.620 0.100 1.343 0.039 -1.103 -0.560 yes
## 5 MONO-LEVEL MEDIATION 0.173 0.063 0.129 0.047 1.343 0.039 0.048 0.300 yes
## 6 MLM-BASED MEDIATION 1.157 0.069 1.398 0.045 0.828 0.042 1.026 1.294 yes
## ───────────────────────────────────────────────────────────────────────────────
PROCESS(Me.data, y="Y", x="X.GroC",
meds="M.GroC", clusters="clus",
ci="mcmc", covs=cc("C1, X_mean, M_mean"), nsim=1000, seed=1223,center = F)
##
## ****************** PART 1. Regression Model Summary ******************
##
## PROCESS Model Code : 4 (Hayes, 2018; www.guilford.com/p/hayes3)
## PROCESS Model Type : Simple Mediation
## - Outcome (Y) : Y
## - Predictor (X) : X.GroC
## - Mediators (M) : M.GroC
## - Moderators (W) : -
## - Covariates (C) : C1, X_mean, M_mean
## - HLM Clusters : clus
##
## Formula of Mediator:
## - M.GroC ~ C1 + X_mean + M_mean + X.GroC + (1 | clus)
## Formula of Outcome:
## - Y ~ C1 + X_mean + M_mean + X.GroC + M.GroC + (1 | clus)
##
## CAUTION:
## Fixed effect (coef.) of a predictor involved in an interaction
## denotes its "simple effect/slope" at the other predictor = 0.
## Only when all predictors in an interaction are mean-centered
## can the fixed effect denote the "main effect"!
##
## Model Summary
##
## ──────────────────────────────────────────────────────────────────
## (1) Y (2) M.GroC (3) Y
## ──────────────────────────────────────────────────────────────────
## (Intercept) 28.140 *** -0.013 28.136 ***
## (1.346) (0.200) (1.346)
## C1Male 1.406 *** 0.047 1.372 ***
## (0.178) (0.040) (0.176)
## X_mean 5.329 *** 0.005 5.323 ***
## (0.919) (0.136) (0.919)
## M_mean 2.238 *** -0.001 2.240 ***
## (0.175) (0.026) (0.174)
## X.GroC 3.339 *** 1.237 *** 2.491 ***
## (0.195) (0.045) (0.200)
## M.GroC 0.685 ***
## (0.044)
## ──────────────────────────────────────────────────────────────────
## Marginal R^2 0.168 0.074 0.187
## Conditional R^2 0.232 0.074 0.252
## AIC 69414.839 40370.082 69180.941
## BIC 69465.083 40420.326 69238.363
## Num. obs. 9679 9679 9679
## Num. groups: clus 568 568 568
## Var: clus (Intercept) 6.049 0.000 6.170
## Var: Residual 72.358 3.780 70.481
## ──────────────────────────────────────────────────────────────────
## Note. * p < .05, ** p < .01, *** p < .001.
##
## ************ PART 2. Mediation/Moderation Effect Estimate ************
##
## Package Use : ‘mediation’ (v4.5.0)
## Effect Type : Simple Mediation (Model 4)
## Sample Size : 9679
## Random Seed : set.seed(1223)
## Simulations : 1000 (Monte Carlo)
##
## Running 1000 simulations...
## Indirect Path: "X.GroC" (X) ==> "M.GroC" (M) ==> "Y" (Y)
## ─────────────────────────────────────────────────────────────
## Effect S.E. z p [MCMC 95% CI]
## ─────────────────────────────────────────────────────────────
## Indirect (ab) 0.849 (0.063) 13.402 <.001 *** [0.732, 0.975]
## Direct (c') 2.497 (0.189) 13.201 <.001 *** [2.124, 2.866]
## Total (c) 3.346 (0.184) 18.231 <.001 *** [2.987, 3.702]
## ─────────────────────────────────────────────────────────────
## Monte Carlo (Quasi-Bayesian) Confidence Interval
## (Effect, SE, and CI are estimated based on 1000 Monte Carlo samples.)
##
## Note. The results based on bootstrapping or other random processes
## are unlikely identical to other statistical software (e.g., SPSS).
## To make results reproducible, you need to set a seed (any number).
## Please see the help page for details: help(PROCESS)
## Ignore this note if you have already set a seed. :)
PROCESS(Me.data, y="Y", x="X_mean",
meds="M_mean", clusters="clus",
ci="mcmc", covs=cc("C1, X.GroC, M.GroC"), nsim=1000, seed=1223,center = F)
##
## ****************** PART 1. Regression Model Summary ******************
##
## PROCESS Model Code : 4 (Hayes, 2018; www.guilford.com/p/hayes3)
## PROCESS Model Type : Simple Mediation
## - Outcome (Y) : Y
## - Predictor (X) : X_mean
## - Mediators (M) : M_mean
## - Moderators (W) : -
## - Covariates (C) : C1, X.GroC, M.GroC
## - HLM Clusters : clus
##
## Formula of Mediator:
## - M_mean ~ C1 + X.GroC + M.GroC + X_mean + (1 | clus)
## Formula of Outcome:
## - Y ~ C1 + X.GroC + M.GroC + X_mean + M_mean + (1 | clus)
##
## CAUTION:
## Fixed effect (coef.) of a predictor involved in an interaction
## denotes its "simple effect/slope" at the other predictor = 0.
## Only when all predictors in an interaction are mean-centered
## can the fixed effect denote the "main effect"!
##
## Model Summary
##
## ────────────────────────────────────────────────────────────────────
## (1) Y (2) M_mean (3) Y
## ────────────────────────────────────────────────────────────────────
## (Intercept) 44.941 *** 8.088 *** 28.136 ***
## (0.347) (0.019) (1.346)
## C1Male 1.432 *** -0.000 1.372 ***
## (0.177) (0.000) (0.176)
## X.GroC 2.491 *** 0.000 2.491 ***
## (0.200) (0.000) (0.200)
## M.GroC 0.685 *** 0.000 0.685 ***
## (0.044) (0.000) (0.044)
## X_mean 14.149 *** 3.361 *** 5.323 ***
## (0.692) (0.039) (0.919)
## M_mean 2.240 ***
## (0.174)
## ────────────────────────────────────────────────────────────────────
## Marginal R^2 0.154 0.924 0.187
## Conditional R^2 0.251 1.000 0.252
## AIC 69323.889 -236113.057 69180.941
## BIC 69374.133 -236062.813 69238.363
## Num. obs. 9679 9679 9679
## Num. groups: clus 568 568 568
## Var: clus (Intercept) 9.177 0.046 6.170
## Var: Residual 70.523 0.000 70.481
## ────────────────────────────────────────────────────────────────────
## Note. * p < .05, ** p < .01, *** p < .001.
##
## ************ PART 2. Mediation/Moderation Effect Estimate ************
##
## Package Use : ‘mediation’ (v4.5.0)
## Effect Type : Simple Mediation (Model 4)
## Sample Size : 9679
## Random Seed : set.seed(1223)
## Simulations : 1000 (Monte Carlo)
##
## Running 1000 simulations...
## Indirect Path: "X_mean" (X) ==> "M_mean" (M) ==> "Y" (Y)
## ───────────────────────────────────────────────────────────────
## Effect S.E. z p [MCMC 95% CI]
## ───────────────────────────────────────────────────────────────
## Indirect (ab) 7.540 (0.578) 13.042 <.001 *** [ 6.438, 8.649]
## Direct (c') 5.336 (0.874) 6.103 <.001 *** [ 3.697, 7.027]
## Total (c) 12.876 (0.589) 21.844 <.001 *** [11.701, 14.060]
## ───────────────────────────────────────────────────────────────
## Monte Carlo (Quasi-Bayesian) Confidence Interval
## (Effect, SE, and CI are estimated based on 1000 Monte Carlo samples.)
##
## Note. The results based on bootstrapping or other random processes
## are unlikely identical to other statistical software (e.g., SPSS).
## To make results reproducible, you need to set a seed (any number).
## Please see the help page for details: help(PROCESS)
## Ignore this note if you have already set a seed. :)
CEMw.aModel=lmer(M ~ X.GroC + X_mean + C1 + (1 | clus), na.action = na.exclude, data = Me.data, control=lmerControl(optimizer="bobyqa"))
CEMw.bModel=lmer(Y ~ M.GroC+ X.GroC + M_mean + X_mean + C1 + (1 | clus), na.action = na.exclude, data = Me.data, control=lmerControl(optimizer="bobyqa"))
CEMw.Me=AutoMC.Me(CEMw.aModel,CEMw.bModel)
##
## Model Summary
##
## ───────────────────────────────────────────────────
## (1) M (2) Y
## ───────────────────────────────────────────────────
## (Intercept) 7.484 *** 28.136 ***
## (0.074) (1.346)
## X.GroC 1.236 *** 2.491 ***
## (0.046) (0.200)
## X_mean 3.939 *** 5.323 ***
## (0.146) (0.919)
## C1Male 0.080 1.372 ***
## (0.042) (0.176)
## M.GroC 0.685 ***
## (0.044)
## M_mean 2.240 ***
## (0.174)
## ───────────────────────────────────────────────────
## Marginal R^2 0.198 0.187
## Conditional R^2 0.262 0.252
## AIC 41457.936 69180.941
## BIC 41501.002 69238.363
## Num. obs. 9679 9679
## Num. groups: clus 568 568
## Var: clus (Intercept) 0.350 6.170
## Var: Residual 4.019 70.481
## ───────────────────────────────────────────────────
## Note. * p < .05, ** p < .01, *** p < .001.
##
## Effects of Mediation (rep=5000, seed=1223 if not preset):
## ────────────────────────────────────────────────────────────────────────────────────
## Effects ab SEab a SEa b SEb abLLCI abULCI sig
## ────────────────────────────────────────────────────────────────────────────────────
## 1 Monte Carlo based Mediation 0.846 0.062 1.236 0.046 0.685 0.044 0.729 0.970 yes
## ────────────────────────────────────────────────────────────────────────────────────
#print_table(CEMw.Me)
CEMb.aModel=lmer(M ~ X_mean + X.GroC + C1 + (1 | clus), na.action = na.exclude, data = Me.data, control=lmerControl(optimizer="bobyqa"))
CEMb.bModel=lmer(Y ~ M_mean + X_mean + M.GroC+ X.GroC + C1 + (1 | clus), na.action = na.exclude, data = Me.data, control=lmerControl(optimizer="bobyqa"))
CEMb.Me=AutoMC.Me(CEMb.aModel,CEMb.bModel)#,note=F)
##
## Model Summary
##
## ───────────────────────────────────────────────────
## (1) M (2) Y
## ───────────────────────────────────────────────────
## (Intercept) 7.484 *** 28.136 ***
## (0.074) (1.346)
## X_mean 3.939 *** 5.323 ***
## (0.146) (0.919)
## X.GroC 1.236 *** 2.491 ***
## (0.046) (0.200)
## C1Male 0.080 1.372 ***
## (0.042) (0.176)
## M_mean 2.240 ***
## (0.174)
## M.GroC 0.685 ***
## (0.044)
## ───────────────────────────────────────────────────
## Marginal R^2 0.198 0.187
## Conditional R^2 0.262 0.252
## AIC 41457.936 69180.941
## BIC 41501.002 69238.363
## Num. obs. 9679 9679
## Num. groups: clus 568 568
## Var: clus (Intercept) 0.350 6.170
## Var: Residual 4.019 70.481
## ───────────────────────────────────────────────────
## Note. * p < .05, ** p < .01, *** p < .001.
##
## Effects of Mediation (rep=5000, seed=1223 if not preset):
## ────────────────────────────────────────────────────────────────────────────────────
## Effects ab SEab a SEa b SEb abLLCI abULCI sig
## ────────────────────────────────────────────────────────────────────────────────────
## 1 Monte Carlo based Mediation 8.825 0.757 3.939 0.146 2.240 0.174 7.346 10.329 yes
## ────────────────────────────────────────────────────────────────────────────────────
CEM.summary=Combine.AutoMC(list(CEMw.Me,CEMb.Me),cc("CEM-based within-level mediation","CEM-based between-level mediation"))
## Effects of Mediation (rep=5000, seed=1223 if not preset):
## ──────────────────────────────────────────────────────────────────────────────────────────
## Effects ab SEab a SEa b SEb abLLCI abULCI sig
## ──────────────────────────────────────────────────────────────────────────────────────────
## 1 CEM-based within-level mediation 0.846 0.062 1.236 0.046 0.685 0.044 0.729 0.970 yes
## 2 CEM-based between-level mediation 8.825 0.757 3.939 0.146 2.240 0.174 7.346 10.329 yes
## ──────────────────────────────────────────────────────────────────────────────────────────
MED.summary=Combine.AutoMC(list(MLM.summary,CEM.summary),cc("MONO and MLM MEDIATION","CEM-BASED MEDIATION"))
## Effects of Mediation (rep=5000, seed=1223 if not preset):
## ─────────────────────────────────────────────────────────────────────────────────
## Effects ab SEab a SEa b SEb abLLCI abULCI sig
## ─────────────────────────────────────────────────────────────────────────────────
## 1 MONO and MLM MEDIATION -0.129 0.078 -0.096 0.059 1.343 0.039 -0.283 0.029 no
## 2 MONO and MLM MEDIATION -0.288 0.091 -0.214 0.068 1.343 0.039 -0.466 -0.104 yes
## 3 MONO and MLM MEDIATION -0.530 0.154 -0.394 0.116 1.343 0.039 -0.835 -0.218 yes
## 4 MONO and MLM MEDIATION -0.833 0.135 -0.620 0.100 1.343 0.039 -1.103 -0.560 yes
## 5 MONO and MLM MEDIATION 0.173 0.063 0.129 0.047 1.343 0.039 0.048 0.300 yes
## 6 MONO and MLM MEDIATION 1.157 0.069 1.398 0.045 0.828 0.042 1.026 1.294 yes
## 7 CEM-BASED MEDIATION 0.846 0.062 1.236 0.046 0.685 0.044 0.729 0.970 yes
## 8 CEM-BASED MEDIATION 8.825 0.757 3.939 0.146 2.240 0.174 7.346 10.329 yes
## ─────────────────────────────────────────────────────────────────────────────────