样本数据截图(企业数据):
use data.dta, clear
* 控制控制变量 ControlVariables
global ControlVariables SIZE ROA LEV ATTR TOP1 ACADEMIC MARKET i.IND i.year
* 链式中介命令
capture program drop mediationprogram mediation, rclass gsem (med1 <- x $ControlVariables) (med2 <- x $ControlVariables) (y <- med2 med1 x $ControlVariables), vce(cluster stkcd) nocaps return scalar cie1 = _b[med1:x]*_b[y:med1] return scalar cie2 = _b[med2:x]*_b[y:med2] return scalar direct_effect=_b[y:x] return scalar total_effect=_b[y:x]+_b[med1:x]*_b[y:med1]+_b[med2:x]*_b[y:med2] endset seed 12345
* 运行命令
mediation
*Bootstrap 中介效应
bootstrap r(direct_effect) r(cie1) r(cie2) r(total_effect), reps(20) : mediationestat boot, bc percentile