Help the Stat Consulting Group by giving a gift

How can I perform mediation with binary variables?

By defaultuse http://www.ats.ucla.edu/stat/data/hsbdemo, clear generate hiread=read>=50 /* create binary mediator */ summarize ses hiread science honors /* descriptive statistics */Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- ses | 200 2.055 .7242914 1 3 hiread | 200 .585 .4939585 0 1 science | 200 51.85 9.900891 26 74 honors | 200 .265 .4424407 0 1binary_mediation, dv(honors) mv(hiread science) iv(ses)Logit: hiread on iv (a1 path) Logistic regression Number of obs = 200 LR chi2(1) = 12.40 Prob > chi2 = 0.0004 Log likelihood = -129.52516 Pseudo R2 = 0.0457 ------------------------------------------------------------------------------ hiread | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- ses | .7204026 .2109932 3.41 0.001 .3068636 1.133942 _cons | -1.115341 .4465912 -2.50 0.013 -1.990643 -.2400381 ------------------------------------------------------------------------------ OLS regression: science on iv (a2 path) ------------------------------------------------------------------------------ science | Coef. Std. Err. t P>|t| Beta -------------+---------------------------------------------------------------- ses | 3.866564 .9317955 4.15 0.000 .2828553 _cons | 43.90421 2.029732 21.63 0.000 . ------------------------------------------------------------------------------ Logit: dv on iv (c path) Logistic regression Number of obs = 200 LR chi2(1) = 7.34 Prob > chi2 = 0.0068 Log likelihood = -111.97593 Pseudo R2 = 0.0317 ------------------------------------------------------------------------------ honors | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- ses | .6185825 .2344357 2.64 0.008 .159097 1.078068 _cons | -2.337778 .5417028 -4.32 0.000 -3.399496 -1.27606 ------------------------------------------------------------------------------ Logit: dv on mv & iv (b & c' paths) Logistic regression Number of obs = 200 LR chi2(3) = 51.61 Prob > chi2 = 0.0000 Log likelihood = -89.83923 Pseudo R2 = 0.2231 ------------------------------------------------------------------------------ honors | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- hiread | 1.597298 .5332837 3.00 0.003 .552081 2.642515 science | .0901672 .0253211 3.56 0.000 .0405389 .1397956 ses | .2516925 .266301 0.95 0.345 -.2702479 .7736328 _cons | -7.658069 1.456197 -5.26 0.000 -10.51216 -4.803975 ------------------------------------------------------------------------------ Indirect effects with binary response variable honors indir_1 = .09141282 (hiread, binary) indir_2 = .10582395 (science, continuous) total indirect = .19723677 direct effect = .07639769 total effect = .27363446 c_path = .23980637 proportion of total effect mediated = .72080384 ratio of indirect to direct effect = 2.5817112 Binary models use logit regression

Thequietly bootstrap r(indir_1) r(indir_2) r(tot_ind) r(dir_eff) r(tot_eff), /// reps(500): binary_mediation, dv(honors) iv(ses) mv(hiread science)estat bootstrap, percentile bcBootstrap results Number of obs = 200 Replications = 499 command: binary_mediation, dv(honors) iv(ses) mv(hiread science) _bs_1: r(indir_1) _bs_2: r(indir_2) _bs_3: r(tot_ind) _bs_4: r(dir_eff) _bs_5: r(tot_eff) ------------------------------------------------------------------------------ | Observed Bootstrap | Coef. Bias Std. Err. [95% Conf. Interval] -------------+---------------------------------------------------------------- _bs_1 | .09141282 -.0000552 .03717104 .0299178 .1781988 (P) | .0333105 .1959342 (BC) _bs_2 | .10582395 .001447 .03999136 .0421071 .1912641 (P) | .0443143 .1973525 (BC) _bs_3 | .19723677 .0013918 .05159597 .098798 .3049328 (P) | .107806 .3141167 (BC) _bs_4 | .07639769 -.0046966 .07954484 -.0831474 .2288187 (P) | -.0747334 .2309053 (BC) _bs_5 | .27363446 -.0033048 .09258509 .0802001 .4406839 (P) | .0739526 .4394651 (BC) ------------------------------------------------------------------------------ (P) percentile confidence interval (BC) bias-corrected confidence interval Note: one or more parameters could not be estimated in 1 bootstrap replicate; standard-error estimates include only complete replications.

The ratio of indirect to direct effect is larger for this probit example but most of the other values are very similar to the logit results from the first example. Please note that the reference diagram always shows the example of two mediators. The diagram does not change with the number of mediators in the command itself.binary_mediation, dv(honors) mv(hiread science) iv(ses) probit diagramProbit: hiread on iv (a1 path) Probit regression Number of obs = 200 LR chi2(1) = 12.37 Prob > chi2 = 0.0004 Log likelihood = -129.54145 Pseudo R2 = 0.0456 ------------------------------------------------------------------------------ hiread | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- ses | .4437993 .1279512 3.47 0.001 .1930196 .6945791 _cons | -.687353 .2744143 -2.50 0.012 -1.225195 -.1495109 ------------------------------------------------------------------------------ OLS regression: science on iv (a2 path) ------------------------------------------------------------------------------ science | Coef. Std. Err. t P>|t| Beta -------------+---------------------------------------------------------------- ses | 3.866564 .9317955 4.15 0.000 .2828553 _cons | 43.90421 2.029732 21.63 0.000 . ------------------------------------------------------------------------------ Probit: dv on iv (c path) Probit regression Number of obs = 200 LR chi2(1) = 7.05 Prob > chi2 = 0.0079 Log likelihood = -112.12049 Pseudo R2 = 0.0305 ------------------------------------------------------------------------------ honors | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- ses | .3500684 .1332785 2.63 0.009 .0888474 .6112894 _cons | -1.36609 .3001514 -4.55 0.000 -1.954376 -.7778043 ------------------------------------------------------------------------------ Probit: dv on mv & iv (b * c' paths) Probit regression Number of obs = 200 LR chi2(3) = 50.99 Prob > chi2 = 0.0000 Log likelihood = -90.149337 Pseudo R2 = 0.2205 ------------------------------------------------------------------------------ honors | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- hiread | .8613714 .2822841 3.05 0.002 .3081048 1.414638 science | .0510501 .0142893 3.57 0.000 .0230435 .0790566 ses | .1156009 .1543426 0.75 0.454 -.186905 .4181068 _cons | -4.250488 .7704867 -5.52 0.000 -5.760614 -2.740362 ------------------------------------------------------------------------------ Indirect effects with binary response variable honors indir_1 = .09911685 (hiread, binary) indir_2 = .10883112 (science, continuous) total indirect = .20794797 direct effect = .06373715 total effect = .27168512 c_path = .24577434 proportion of total effect mediated = .76540067 ratio of indirect to direct effect = 3.2625868 Binary models use probit regression Reference Mediation Diagram IV --- coef c --- DV MV1 / \ coef a1 coef b1 / \ IV --- coef c' --- DV \ / coef a2 coef b2 \ / MV2