做调节中介效应时,使用自举法 (Bootstrapping) 获得标准误和置信区间,以stata样例数据进行分析,命令如下:
use"https://stats.idre.ucla.edu/stat/data/hsb2", clear
rename science y // 被解释变量
rename math x // 解释变量
rename read m // 中介变量
capture program drop bootm1
program bootm1, rclass
sem(m <- x)(y <- m x mx)
return scalar cielw = _b[m:x]*(_b[y:m]+($m-$s)*_b[y:mx])
return scalar ciemn = _b[m:x]*(_b[y:m]+($m)*_b[y:mx])
return scalar ciehi = _b[m:x]*(_b[y:m]+($m+$s)*_b[y:mx])
end
bootstrap r(cielw) r(ciemn) r(ciehi), reps(500) nodots: bootm1
请问如何在bootstrap命令中加入其他控制变量?
检验中介效应是放在sem命令里,调节中介效应应该也一样?
《HOW CAN I DO MEDIATION ANALYSIS WITH THE SEM COMMAND?》:
“A note about covariates
If your model contains control variables, i.e., covariates, you must include these in each of the sem equations. Thus, your sem model will look something like this:
sem (MV <- IV CV1 CV2)(DV <- MV IV CV1 CV2)”