|
|
|
||||
|
Help the Stat Consulting Group by
giving a gift
| |||||
|
Loading
|
|||||
Here is the full citation to the article:
Preacher, K.J., Rucker, D.D. and Hayes, A.F. 2007. Addressing moderated mediation hypotheses:
Theory, methods, and prescriptions. Multivariate Behavioral Research, 42(1), 185-227.
We will begin with a few definitions. A mediator variable is a variable that sits between an independent variable and the dependent variable such that some of the effect of the independent variable on the dependent variable passes through the mediator variable. This is known as the indirect effect.
A moderator variable is a variable involved in an interaction with another variable in the model such that the effect of the other variable depends upon the value of the moderator variable, i.e., the effect of the other variable changes depending on the value of the moderator.
Moderated mediation occurs when a moderator variable interacts with a mediator variable such that the value of the indirect effect changes depending on the value of the moderator variable. This is known as a conditional indirect effect, i.e., the value of the indirect effect is conditional on the value of the moderator variable.
Preacher et al (2007) provide the theoretical background and framework for moderated mediation. They also provide an SPSS script that computes conditional indirect effects and their standard errors in two different ways. In both methods the value of the conditional indirect effects are obtained using the product of coefficients method, i.e., the condition indirect effect coefficients are computed as the product of ordinary regression coefficients. While it can be somewhat tedious, it is not a difficult process. Standard errors, on the other hand, can be much more difficult to compute.
The first method in Preacher et al is normal theory based. This method is fairly efficient but suffers from the fact that the distribution of conditional indirect effects are known to be nonnormal, most usually skewed and kurtotic. Confidence intervals and hypothesis tests using normal theory based approaches are not recommended for final models in your research.
The second approach is to use bootstrapping to obtain standard errors and confidence intervals. Although this approach can be much slower the standard errors are not normal theory based. In particular, the biased corrected and percentile confidence intervals are nonsymmetric and better reflect the sampling distribution of the conditional indirect effects.
The remainder of this FAQ page is devoted to showing how to compute conditional indirect effects, standard errors and confidence intervals using Stata. We will show an example for each of the five models from Preacher et al. For each model there is a section using a normal theory based approach that uses sureg and nlcom. Also, for each of the Preacher et al models we will show how to obtain the bootstrap estimates of standard errors and confidence intervals.
In order to compute the conditional indirect effects we need to have access to regression coefficients from two different models; one model with the mediator as the response variables and another model with the dependent variable as the response variable. The easiest way to do this in Stata is to use the sureg command. When set up correctly, it will have all of the coefficients that we need. In configuring the sureg command, all the effects from the mediator variable to the left goes into the first sureg equation, while everything from the dependent variable to the left goes into the second sureg equation. We will make use of the sureg for both the normal based estimation and for bootstrapping.
Conditional indirect effects are obtained by multiplying coefficients from the sureg model along with selected values of the moderator variable. For four of the five models, we will compute the conditional indirect effects for three different values of the moderator variable; mean(m1) - 1 sd(m1) {low moderator}, mean(m1) {medium moderator}, mean(m1) + 1 sd(m1) {high moderator}. For model 4 there will be nine combinations of moderator values because the are two moderator variables in the model. Each of the three levels of the first moderator are used in combination with the three levels of the second moderator variable thus yielding the nine combinations.
For the normal based approach we use the nlcom command to compute the conditional indirect effects and their standard errors. nlcom uses the delta method to obtain the standard errors. Each coefficient in the sureg model is identified in nlcom using both the equation name (generally the response variable for that equation) and the predictor name. Thus, in a model with read as the response variable and math as the predictor, the coefficient would by entered as [read]_b[math].
Before trying any of the models, run the Stata code below to read in the data and to rename the variables to be consistent with the variable names in the images of the models. The simplified naming also assists in quickly recognizing the role of each variable in the model.
Click on the image of the model you want to go to.use http://www.ats.ucla.edu/stat/data/hsb2, clear rename science y /* dependent variable */ rename math x /* independent variable */ rename read m /* mediator variable */ rename write w /* moderator variable 1 */ rename socst z /* moderator variable 2 */
Model 1 illustrates the situation in which the independent variable is also the moderator variable which effects the path between the mediator and the dependent variable.

Formulas:
m = a0 + a1x y = b0 + b1m + b2x + b3mx conditional indirect effect = a1(b1 + b3x)
Normal theory estimation using the delta method for model 1.
quietly summarize x
global m=r(mean)
global s=r(sd)
generate mx=m*x /* mv by iv interaction */
sureg (m x)(y m x mx)
Seemingly unrelated regression
----------------------------------------------------------------------
Equation Obs Parms RMSE "R-sq" chi2 P
----------------------------------------------------------------------
m 200 1 7.662848 0.4386 156.26 0.0000
y 200 3 7.050527 0.4904 192.43 0.0000
----------------------------------------------------------------------
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
m |
x | .724807 .0579824 12.50 0.000 .6111636 .8384504
_cons | 14.07254 3.100201 4.54 0.000 7.996255 20.14882
-------------+----------------------------------------------------------------
y |
m | .9766164 .2875081 3.40 0.001 .4131109 1.540122
x | 1.03094 .2969707 3.47 0.001 .4488881 1.612992
mx | -.0115869 .0053091 -2.18 0.029 -.0219926 -.0011812
_cons | -20.83921 15.16952 -1.37 0.170 -50.57092 8.892495
------------------------------------------------------------------------------
nlcom [m]_b[x]*([y]_b[m]+($m-$s)*[y]_b[mx]) /* mean - 1 sd */
_nl_1: [m]_b[x]*([y]_b[m]+(52.645-9.368447794077296)*[y]_b[mx])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .3444105 .0656615 5.25 0.000 .2157163 .4731048
------------------------------------------------------------------------------
nlcom [m]_b[x]*([y]_b[m]+($m)*[y]_b[mx]) /* mean */
_nl_1: [m]_b[x]*([y]_b[m]+(52.645)*[y]_b[mx])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .2657319 .0517277 5.14 0.000 .1643474 .3671164
------------------------------------------------------------------------------
nlcom [m]_b[x]*([y]_b[m]+($m+$s)*[y]_b[mx]) /* mean + 1 sd */
_nl_1: [m]_b[x]*([y]_b[m]+(52.645+9.368447794077296)*[y]_b[mx])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1870532 .0609803 3.07 0.002 .067534 .3065724
------------------------------------------------------------------------------
In this example the conditional indirect effects gets smaller as the mediator variable, in this
case the independent variable gets larger. Next is the bootstrap code for model 1. The example
bootstrap command below uses 500 replications. You
will probably want to use at least 1,000 or even 5,000 in real research situations.
capture program drop bootm1
program bootm1, rclass
sureg (m x)(y m x mx)
return scalar cielw = [m]_b[x]*([y]_b[m]+($m-$s)*[y]_b[mx])
return scalar ciemn = [m]_b[x]*([y]_b[m]+($m)*[y]_b[mx])
return scalar ciehi = [m]_b[x]*([y]_b[m]+($m+$s)*[y]_b[mx])
end
bootstrap r(cielw) r(ciemn) r(ciehi), reps(500) nodots: bootm1
Bootstrap results Number of obs = 200
Replications = 500
command: bootm1
_bs_1: r(cielw)
_bs_2: r(ciemn)
_bs_3: r(ciehi)
------------------------------------------------------------------------------
| Observed Bootstrap Normal-based
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .3442437 .0596977 5.77 0.000 .2272384 .461249
_bs_2 | .2646401 .0531258 4.98 0.000 .1605154 .3687647
_bs_3 | .1850365 .0637424 2.90 0.004 .0601036 .3099693
------------------------------------------------------------------------------
estat boot, bc percentile
Bootstrap results Number of obs = 200
Replications = 500
command: bootm1
_bs_1: r(cielw)
_bs_2: r(ciemn)
_bs_3: r(ciehi)
------------------------------------------------------------------------------
| Observed Bootstrap
| Coef. Bias Std. Err. [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .34424374 -.0027403 .05969768 .2204353 .462091 (P)
| .2279064 .4661937 (BC)
_bs_2 | .2646401 -.0008873 .0531258 .1688669 .3666712 (P)
| .172691 .3837206 (BC)
_bs_3 | .18503645 .0009657 .06374241 .0658211 .3042314 (P)
| .0620927 .3027444 (BC)
------------------------------------------------------------------------------
(P) percentile confidence interval
(BC) bias-corrected confidence interval
In Model 2 the path between the independent variable and the mediator variable is moderated by W.

Formulas:
m = a0 + a1x + a2w + a3xw y = b0 + b1m + b2x + b3w + b4xw conditional indirect effect = b1(a1 + a3w)
quietly summarize w
global m=r(mean)
global s=r(sd)
generate wx=w*x /* moderator 1 by iv interaction */
sureg (m x w wx)(y m x w wx)
Seemingly unrelated regression
----------------------------------------------------------------------
Equation Obs Parms RMSE "R-sq" chi2 P
----------------------------------------------------------------------
m 200 3 7.255054 0.4968 197.44 0.0000
y 200 4 6.953251 0.5043 203.48 0.0000
----------------------------------------------------------------------
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
m |
x | .2707428 .3780083 0.72 0.474 -.4701398 1.011625
w | .1041694 .3417056 0.30 0.760 -.5655613 .7739002
wx | .0044859 .0066954 0.67 0.503 -.0086368 .0176087
_cons | 19.7711 18.53835 1.07 0.286 -16.56341 56.1056
-------------+----------------------------------------------------------------
y |
m | .3057916 .0677692 4.51 0.000 .1729665 .4386168
x | .7902703 .3627478 2.18 0.029 .0792976 1.501243
w | .6316515 .3275671 1.93 0.054 -.0103682 1.273671
wx | -.008533 .0064241 -1.33 0.184 -.021124 .0040579
_cons | -14.88752 17.81763 -0.84 0.403 -49.80943 20.03438
------------------------------------------------------------------------------
nlcom ([m]_b[x]+($m-$s)*[m]_b[wx])*[y]_b[m] /* mean - 1 sd */
_nl_1: ([m]_b[x]+(52.775-9.47858602138653)*[m]_b[wx])*[y]_b[m]
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1421829 .0455118 3.12 0.002 .0529814 .2313843
------------------------------------------------------------------------------
nlcom ([m]_b[x]+($m)*[m]_b[wx])*[y]_b[m] /* mean */
_nl_1: ([m]_b[x]+(52.775)*[m]_b[wx])*[y]_b[m]
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1551852 .0408543 3.80 0.000 .0751121 .2352582
------------------------------------------------------------------------------
nlcom ([m]_b[x]+($m+$s)*[m]_b[wx])*[y]_b[m] /* mean + 1 sd */
_nl_1: ([m]_b[x]+(52.775+9.47858602138653)*[m]_b[wx])*[y]_b[m]
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1681874 .0451294 3.73 0.000 .0797355 .2566394
------------------------------------------------------------------------------
In this example the conditional indirect effects increase slowly as the value of the moderator
variable increases.Bootstrap code for model 2. The example bootstrap command below uses 500 replications. You will probably want to use at least 1,000 or even 5,000 in real research situations.
capture program drop bootm2
program bootm2, rclass
sureg (m x w wx)(y m x w wx)
return scalar cielw = ([m]_b[x]+($m-$s)*[m]_b[wx])*[y]_b[m]
return scalar ciemn = ([m]_b[x]+($m)*[m]_b[wx])*[y]_b[m]
return scalar ciehi = ([m]_b[x]+($m+$s)*[m]_b[wx])*[y]_b[m]
end
bootstrap r(cielw) r(ciemn) r(ciehi), reps(500) nodots: bootm2
Bootstrap results Number of obs = 200
Replications = 500
command: bootm2
_bs_1: r(cielw)
_bs_2: r(ciemn)
_bs_3: r(ciehi)
------------------------------------------------------------------------------
| Observed Bootstrap Normal-based
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .1421829 .0461156 3.08 0.002 .051798 .2325677
_bs_2 | .1551852 .0411104 3.77 0.000 .0746102 .2357601
_bs_3 | .1681874 .0451104 3.73 0.000 .0797727 .2566022
------------------------------------------------------------------------------
estat boot, bc percentile
Bootstrap results Number of obs = 200
Replications = 500
command: bootm2
_bs_1: r(cielw)
_bs_2: r(ciemn)
_bs_3: r(ciehi)
------------------------------------------------------------------------------
| Observed Bootstrap
| Coef. Bias Std. Err. [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .14218287 -.0013606 .04611557 .0616222 .2375485 (P)
| .0660757 .2615341 (BC)
_bs_2 | .15518515 -.0012903 .04111043 .0771254 .2357809 (P)
| .0889802 .2574241 (BC)
_bs_3 | .16818743 -.00122 .04511041 .089876 .2598182 (P)
| .0918538 .2617774 (BC)
------------------------------------------------------------------------------
(P) percentile confidence interval
(BC) bias-corrected confidence interval
In Model 3 the path between the mediator variable and the dependent variable is moderated by W.

Formulas:
m = a0 + a1x y = b0 + b1m + b2x + b3w + b4mw conditional indirect effect = a1(b1 + b4w)
quietly summarize w
global m=r(mean)
global s=r(sd)
generate mw=m*w /* mv by moderator 1 interaction */
sureg (m x)(y m x w mw)
Seemingly unrelated regression
----------------------------------------------------------------------
Equation Obs Parms RMSE "R-sq" chi2 P
----------------------------------------------------------------------
m 200 1 7.662848 0.4386 156.26 0.0000
y 200 4 6.935529 0.5068 205.55 0.0000
----------------------------------------------------------------------
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
m |
x | .724807 .0579824 12.50 0.000 .6111636 .8384504
_cons | 14.07254 3.100201 4.54 0.000 7.996255 20.14882
-------------+----------------------------------------------------------------
y |
m | .8193599 .3169173 2.59 0.010 .1982135 1.440506
x | .33696 .0761398 4.43 0.000 .1877287 .4861913
w | .6739726 .2880423 2.34 0.019 .1094201 1.238525
mw | -.0095993 .00574 -1.67 0.094 -.0208495 .0016509
_cons | -17.23954 15.65376 -1.10 0.271 -47.92034 13.44126
------------------------------------------------------------------------------
nlcom [m]_b[x]*([y]_b[m]+($m-$s)*[y]_b[mw]) /* mean - 1 sd */
_nl_1: [m]_b[x]*([y]_b[m]+(52.775-9.47858602138653)*[y]_b[mw])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .2926372 .0700399 4.18 0.000 .1553616 .4299129
------------------------------------------------------------------------------
nlcom [m]_b[x]*([y]_b[m]+($m)*[y]_b[mw]) /* mean */
_nl_1: [m]_b[x]*([y]_b[m]+(52.775)*[y]_b[mw])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .2266887 .0524176 4.32 0.000 .1239522 .3294253
------------------------------------------------------------------------------
nlcom [m]_b[x]*([y]_b[m]+($m+$s)*[y]_b[mw]) /* mean + 1 sd */
_nl_1: [m]_b[x]*([y]_b[m]+(52.775+9.47858602138653)*[y]_b[mw])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1607402 .0612818 2.62 0.009 .04063 .2808504
------------------------------------------------------------------------------
In this example, the conditional indirect effects decreases as the value of the moderator
variable increases.Bootstrap code for model 3. The example bootstrap command below uses 500 replications. You will probably want to use at least 1,000 or even 5,000 in real research situations.
capture program drop bootm3
program bootm3, rclass
sureg (m x)(y m x w mw)
return scalar cielw = [m]_b[x]*([y]_b[m]+($m-$s)*[y]_b[mw])
return scalar ciemn = [m]_b[x]*([y]_b[m]+($m)*[y]_b[mw])
return scalar ciehi = [m]_b[x]*([y]_b[m]+($m+$s)*[y]_b[mw])
end
bootstrap r(cielw) r(ciemn) r(ciehi), reps(500) nodots: bootm3
Bootstrap results Number of obs = 200
Replications = 500
command: bootm3
_bs_1: r(cielw)
_bs_2: r(ciemn)
_bs_3: r(ciehi)
------------------------------------------------------------------------------
| Observed Bootstrap Normal-based
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .2926372 .0667373 4.38 0.000 .1618346 .4234399
_bs_2 | .2266887 .053735 4.22 0.000 .1213701 .3320073
_bs_3 | .1607402 .0637906 2.52 0.012 .035713 .2857674
------------------------------------------------------------------------------
estat boot, bc percentile
Bootstrap results Number of obs = 200
Replications = 500
command: bootm3
_bs_1: r(cielw)
_bs_2: r(ciemn)
_bs_3: r(ciehi)
------------------------------------------------------------------------------
| Observed Bootstrap
| Coef. Bias Std. Err. [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .29263724 .0013247 .06673727 .1594114 .424295 (P)
| .1435081 .4101441 (BC)
_bs_2 | .22668872 .003281 .05373495 .1295734 .3396748 (P)
| .1155926 .3257277 (BC)
_bs_3 | .1607402 .0052373 .06379058 .0455008 .29754 (P)
| .0166619 .291034 (BC)
------------------------------------------------------------------------------
(P) percentile confidence interval
(BC) bias-corrected confidence interval
Model 4 has two different moderator variables. One that moderates the path between the independent variable and mediator variable and one that moderates the path between the mediator variable and the dependent variable.

Formulas:
m = a0 + a1x + a2w + a3xw y = b0 + b1m + b2x + b3w + b4xw + b5z + b6mz conditional indirect effect = (b1 + b6z)(a1 + a3w)
quietly summarize w
global m1=r(mean)
global s1=r(sd)
quietly summarize z
global m2=r(mean)
global s2=r(sd)
capture generate wx=w*x /* moderator 1 by iv interaction */
gen mz=m*z /* mv by moderator 2 interaction */
sureg (m x w wx)(y m x w wx z mz)
Seemingly unrelated regression
----------------------------------------------------------------------
Equation Obs Parms RMSE "R-sq" chi2 P
----------------------------------------------------------------------
m 200 3 7.255054 0.4968 197.44 0.0000
y 200 6 6.948674 0.5050 204.02 0.0000
----------------------------------------------------------------------
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
m |
x | .2707428 .3780083 0.72 0.474 -.4701398 1.011625
w | .1041694 .3417056 0.30 0.760 -.5655613 .7739002
wx | .0044859 .0066954 0.67 0.503 -.0086368 .0176087
_cons | 19.7711 18.53835 1.07 0.286 -16.56341 56.1056
-------------+----------------------------------------------------------------
y |
m | .4013056 .282893 1.42 0.156 -.1531546 .9557658
x | .7571766 .3864076 1.96 0.050 -.0001684 1.514522
w | .6031543 .3562554 1.69 0.090 -.0950935 1.301402
wx | -.0078215 .0069183 -1.13 0.258 -.021381 .0057381
z | .0553245 .2661857 0.21 0.835 -.4663899 .5770389
mz | -.0015944 .0050813 -0.31 0.754 -.0115536 .0083647
_cons | -17.0724 19.0314 -0.90 0.370 -54.37327 20.22847
------------------------------------------------------------------------------
nlcom ([m]_b[x]+($m1-$s1)*[m]_b[wx])*([y]_b[m]+($m2-$s2)*[y]_b[mz]) /* mean1 - 1 sd1; mean2 - 1 sd2 */
_nl_1: ([m]_b[x]+(52.775-9.47858602138653)*[m]_b[wx])*([y]_b[m]+(52.405-10.7357934642267)*[y]_b[mz])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1557016 .0568792 2.74 0.006 .0442203 .2671828
------------------------------------------------------------------------------
nlcom ([m]_b[x]+($m1)*[m]_b[wx])*([y]_b[m]+($m2-$s2)*[y]_b[mz]) /* mean1; mean2 - 1 sd2 */
_nl_1: ([m]_b[x]+(52.775)*[m]_b[wx])*([y]_b[m]+(52.405-10.7357934642267)*[y]_b[mz])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1699401 .0538198 3.16 0.002 .0644552 .275425
------------------------------------------------------------------------------
nlcom ([m]_b[x]+($m1+$s1)*[m]_b[wx])*([y]_b[m]+($m2-$s2)*[y]_b[mz]) /* mean1 + 1 sd1; mean2 - 1 sd2 */
_nl_1: ([m]_b[x]+(52.775+9.47858602138653)*[m]_b[wx])*([y]_b[m]+(52.405-10.7357934642267)*[y]_b[mz])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1841786 .059107 3.12 0.002 .068331 .3000263
------------------------------------------------------------------------------
nlcom ([m]_b[x]+($m1-$s1)*[m]_b[wx])*([y]_b[m]+($m2)*[y]_b[mz]) /* mean1 - 1 sd1; mean2 */
_nl_1: ([m]_b[x]+(52.775-9.47858602138653)*[m]_b[wx])*([y]_b[m]+(52.405)*[y]_b[mz])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1477424 .04785 3.09 0.002 .0539581 .2415267
------------------------------------------------------------------------------
nlcom ([m]_b[x]+($m1)*[m]_b[wx])*([y]_b[m]+($m2)*[y]_b[mz]) /* mean1; mean2 */
_nl_1: ([m]_b[x]+(52.775)*[m]_b[wx])*([y]_b[m]+(52.405)*[y]_b[mz])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1612531 .0431911 3.73 0.000 .0766001 .2459061
------------------------------------------------------------------------------
nlcom ([m]_b[x]+($m1+$s1)*[m]_b[wx])*([y]_b[m]+($m2)*[y]_b[mz]) /* mean1 + 1 sd1; mean2 */
_nl_1: ([m]_b[x]+(52.775+9.47858602138653)*[m]_b[wx])*([y]_b[m]+(52.405)*[y]_b[mz])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1747638 .0476804 3.67 0.000 .081312 .2682156
------------------------------------------------------------------------------
nlcom ([m]_b[x]+($m1-$s1)*[m]_b[wx])*([y]_b[m]+($m2+$s2)*[y]_b[mz]) /* mean1 - 1 sd1; mean2 + 1 sd */
_nl_1: ([m]_b[x]+(52.775-9.47858602138653)*[m]_b[wx])*([y]_b[m]+(52.405+10.7357934642267)*[y]_b[mz])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1397833 .0513566 2.72 0.006 .0391261 .2404404
------------------------------------------------------------------------------
nlcom ([m]_b[x]+($m1)*[m]_b[wx])*([y]_b[m]+($m2+$s2)*[y]_b[mz]) /* mean1; mean2 + 1 sd */
_nl_1: ([m]_b[x]+(52.775)*[m]_b[wx])*([y]_b[m]+(52.405+10.7357934642267)*[y]_b[mz])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1525661 .0486854 3.13 0.002 .0571445 .2479878
------------------------------------------------------------------------------
nlcom ([m]_b[x]+($m1+$s1)*[m]_b[wx])*([y]_b[m]+($m2+$s2)*[y]_b[mz]) /* mean1 + 1 sd1; mean2 + 1 sd */
_nl_1: ([m]_b[x]+(52.775+9.47858602138653)*[m]_b[wx])*([y]_b[m]+(52.405+10.7357934642267)*[y]_b[mz])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .165349 .0534577 3.09 0.002 .0605738 .2701241
------------------------------------------------------------------------------
Bootstrap code for model 5. The example bootstrap command below uses 500 replications. You
will probably want to use at least 1,000 or even 5,000 in real research situations.
capture program drop bootm4
program bootm4, rclass
sureg (m x w wx)(y m x w wx z mz)
return scalar ciell = ([m]_b[x]+($m1-$s1)*[m]_b[wx])*([y]_b[m]+($m2-$s2)*[y]_b[mz])
return scalar cieml = ([m]_b[x]+($m1)*[m]_b[wx])*([y]_b[m]+($m2-$s2)*[y]_b[mz])
return scalar ciehl = ([m]_b[x]+($m1+$s1)*[m]_b[wx])*([y]_b[m]+($m2-$s2)*[y]_b[mz])
return scalar cielm = ([m]_b[x]+($m1-$s1)*[m]_b[wx])*([y]_b[m]+($m2)*[y]_b[mz])
return scalar ciemm = ([m]_b[x]+($m1)*[m]_b[wx])*([y]_b[m]+($m2)*[y]_b[mz])
return scalar ciehm = ([m]_b[x]+($m1+$s1)*[m]_b[wx])*([y]_b[m]+($m2)*[y]_b[mz])
return scalar cielh = ([m]_b[x]+($m1-$s1)*[m]_b[wx])*([y]_b[m]+($m2+$s2)*[y]_b[mz])
return scalar ciemh = ([m]_b[x]+($m1)*[m]_b[wx])*([y]_b[m]+($m2+$s2)*[y]_b[mz])
return scalar ciehh = ([m]_b[x]+($m1+$s1)*[m]_b[wx])*([y]_b[m]+($m2+$s2)*[y]_b[mz])
end
bootstrap r(ciell) r(cieml) r(ciehl) r(cielm) r(ciemm) r(ciehm) ///
r(cielh) r(ciemh) r(ciehh), reps(500) nodots: bootm4
Bootstrap results Number of obs = 200
Replications = 500
command: bootm4
_bs_1: r(ciell)
_bs_2: r(cieml)
_bs_3: r(ciehl)
_bs_4: r(cielm)
_bs_5: r(ciemm)
_bs_6: r(ciehm)
_bs_7: r(cielh)
_bs_8: r(ciemh)
_bs_9: r(ciehh)
------------------------------------------------------------------------------
| Observed Bootstrap Normal-based
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .1557016 .0653728 2.38 0.017 .0275733 .2838298
_bs_2 | .1699401 .0593524 2.86 0.004 .0536115 .2862687
_bs_3 | .1841786 .0615008 2.99 0.003 .0636393 .304718
_bs_4 | .1477424 .0509806 2.90 0.004 .0478222 .2476626
_bs_5 | .1612531 .0440242 3.66 0.000 .0749673 .2475389
_bs_6 | .1747638 .0471966 3.70 0.000 .0822602 .2672674
_bs_7 | .1397833 .0506432 2.76 0.006 .0405245 .239042
_bs_8 | .1525661 .0474933 3.21 0.001 .0594809 .2456513
_bs_9 | .165349 .0541863 3.05 0.002 .0591457 .2715522
------------------------------------------------------------------------------
estat boot, bc percentile
Bootstrap results Number of obs = 200
Replications = 500
command: bootm4
_bs_1: r(ciell)
_bs_2: r(cieml)
_bs_3: r(ciehl)
_bs_4: r(cielm)
_bs_5: r(ciemm)
_bs_6: r(ciehm)
_bs_7: r(cielh)
_bs_8: r(ciemh)
_bs_9: r(ciehh)
------------------------------------------------------------------------------
| Observed Bootstrap
| Coef. Bias Std. Err. [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .15570156 -.0050356 .06537276 .038003 .2984944 (P)
| .0532313 .3329171 (BC)
_bs_2 | .16994009 -.0051203 .05935243 .0518087 .2943635 (P)
| .0603415 .3129745 (BC)
_bs_3 | .18417863 -.0052049 .0615008 .0625556 .3007132 (P)
| .0674384 .3066082 (BC)
_bs_4 | .14774241 -.0031433 .05098063 .0525921 .2588338 (P)
| .0761787 .2761584 (BC)
_bs_5 | .1612531 -.0023717 .04402417 .0718803 .2565858 (P)
| .0877493 .2738494 (BC)
_bs_6 | .17476379 -.0016001 .04719657 .0827655 .2658843 (P)
| .0870276 .2766474 (BC)
_bs_7 | .13978326 -.0012511 .05064316 .0502567 .2436439 (P)
| .0610592 .2530425 (BC)
_bs_8 | .15256611 .0003768 .04749333 .0628939 .256847 (P)
| .0701415 .2570293 (BC)
_bs_9 | .16534895 .0020046 .05418632 .0740105 .282494 (P)
| .0740105 .282494 (BC)
------------------------------------------------------------------------------
(P) percentile confidence interval
(BC) bias-corrected confidence interval
Model 4 has a single moderator variable that moderates both the path between the independent variable and mediator variable and the path between the mediator variable and the dependent variable.

Formulas:
m = a0 + a1x + a2w + a3xw y = b0 + b1m + b2x + b3w + b4xw + b5mw conditional indirect effect = (b1 + b5w)(a1 + a3w)
quietly summarize w
global m=r(mean)
global s=r(sd)
capture generate wx=w*x /* moderator 1 by iv interaction */
capture generate mw=m*w /* mv by moderator 1 interaction */
sureg (m x w wx)(y m x w wx mw)
Seemingly unrelated regression
----------------------------------------------------------------------
Equation Obs Parms RMSE "R-sq" chi2 P
----------------------------------------------------------------------
m 200 3 7.255054 0.4968 197.44 0.0000
y 200 5 6.932239 0.5073 205.93 0.0000
----------------------------------------------------------------------
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
m |
x | .2707428 .3780083 0.72 0.474 -.4701398 1.011625
w | .1041694 .3417056 0.30 0.760 -.5655613 .7739002
wx | .0044859 .0066954 0.67 0.503 -.0086368 .0176087
_cons | 19.7711 18.53835 1.07 0.286 -16.56341 56.1056
-------------+----------------------------------------------------------------
y |
m | .7237774 .3852893 1.88 0.060 -.0313758 1.478931
x | .5236584 .4351217 1.20 0.229 -.3291644 1.376481
w | .7576026 .3460016 2.19 0.029 .079452 1.435753
wx | -.0034416 .0078974 -0.44 0.663 -.0189201 .012037
mw | -.0077956 .0070744 -1.10 0.270 -.0216612 .00607
_cons | -21.81586 18.84366 -1.16 0.247 -58.74876 15.11704
------------------------------------------------------------------------------
nlcom ([m]_b[x]+($m-$s)*[m]_b[wx])*([y]_b[m]+($m-$s)*[y]_b[mw]) /* mean - 1 sd */
_nl_1: ([m]_b[x]+(52.775-9.47858602138653)*[m]_b[wx])*([y]_b[m]+(52.775-9.47858602138653)*[y]_b[mw])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1795967 .0621316 2.89 0.004 .057821 .3013723
------------------------------------------------------------------------------
nlcom ([m]_b[x]+($m)*[m]_b[wx])*([y]_b[m]+($m)*[y]_b[mw]) /* mean */
_nl_1: ([m]_b[x]+(52.775)*[m]_b[wx])*([y]_b[m]+(52.775)*[y]_b[mw])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1585216 .0411369 3.85 0.000 .0778949 .2391484
------------------------------------------------------------------------------
nlcom ([m]_b[x]+($m+$s)*[m]_b[wx])*([y]_b[m]+($m+$s)*[y]_b[mw]) /* mean + 1 sd */
_nl_1: ([m]_b[x]+(52.775+9.47858602138653)*[m]_b[wx])*([y]_b[m]+(52.775+9.47858602138653)*[y]_b[mw])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1311629 .0538847 2.43 0.015 .0255509 .236775
------------------------------------------------------------------------------
Bootstrap code for model 5. The example bootstrap command below uses 500 replications. You
will probably want to use at least 1,000 or even 5,000 in real research situations.
capture program drop bootm5
program bootm5, rclass
sureg (m x w wx)(y m x w wx mw)
return scalar cielw = ([m]_b[x]+($m-$s)*[m]_b[wx])*([y]_b[m]+($m-$s)*[y]_b[mw])
return scalar ciemn = ([m]_b[x]+($m)*[m]_b[wx])*([y]_b[m]+($m)*[y]_b[mw])
return scalar ciehi = ([m]_b[x]+($m+$s)*[m]_b[wx])*([y]_b[m]+($m+$s)*[y]_b[mw])
end
bootstrap r(cielw) r(ciemn) r(ciehi), reps(500) nodots: bootm5
Bootstrap results Number of obs = 200
Replications = 500
command: bootm5
_bs_1: r(cielw)
_bs_2: r(ciemn)
_bs_3: r(ciehi)
------------------------------------------------------------------------------
| Observed Bootstrap Normal-based
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .1795967 .0771065 2.33 0.020 .0284706 .3307227
_bs_2 | .1585216 .0441431 3.59 0.000 .0720027 .2450406
_bs_3 | .1311629 .0557224 2.35 0.019 .021949 .2403769
------------------------------------------------------------------------------
estat boot, bc percentile
Bootstrap results Number of obs = 200
Replications = 500
command: bootm5
_bs_1: r(cielw)
_bs_2: r(ciemn)
_bs_3: r(ciehi)
------------------------------------------------------------------------------
| Observed Bootstrap
| Coef. Bias Std. Err. [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .17959665 .0055235 .07710652 .0587954 .3681718 (P)
| .0623453 .3723903 (BC)
_bs_2 | .15852165 .0005673 .04414311 .0710014 .2532528 (P)
| .0740012 .2558996 (BC)
_bs_3 | .13116295 -.0024743 .05572241 .0226505 .2418089 (P)
| .0258685 .2438461 (BC)
------------------------------------------------------------------------------
(P) percentile confidence interval
(BC) bias-corrected confidence interval
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services