This is the web
page to support
Preacher, K. J., Rucker,
UPDATED VERSION
Uploaded September
3, 2008
This updated version eliminates the construction of temporary data files
which produced numerous user difficulties.
It also produces better formatting of output when one or more of the
moderator variables is dichotomous. It
also renders obsolete the MODMEDC command described in the paper and the
original web page, as the updated version can handle covariates. The syntax structure differs slightly from as
described in Preacher, Rucker, and Hayes (2007). The updated version requires SPSS version 14
or later.
NOTE: Some users of SPSS 18 have reported problems with macros
and scripts. Click here for more information and a possible
solution.
This macro implements the normal theory and bootstrap approaches to testing conditional indirect effects as described in Preacher, Rucker, & Hayes (2007). Using the syntax for the macro described here, analyses corresponding to each of the 5 models described in Preacher et al. can be conducted in SPSS. On this web page you will find the syntax for estimating each model and the various subcommands for doing focuses analyses. As with all macros, you must first run the macro command set to “activate” the macro. Do not modify the macro in any way. Simply run the command set as is. Once each macro is activated, the MODMED command will be available for your use until you quit SPSS.
To download the MODMED macro click here.
Here is the MODMED Syntax Reference
Can’t get the macro to work or have questions? Check here for some macro rules and answers to frequently asked questions.
Join the new Statistical Mediation and Moderation Analysis group on Facebook.
Download my new macro and script for probing interactions in OLS and logistic regression.
Can an effect that doesn’t exist be “mediated”? Click here.
The five path models the macro fits are depicted graphically below.

The syntax [PDF] for each of the macros is as follows
MODMED vars = variablelist/dv = depend/med = mediator/dvmodel = dvmodlist/mmodel = mmodlist[/mmodv = mval ][/dvmodv = dvval][/varord = var][/covmat = z] [/boot = bootn]/ [/jn = j].
The subcommands in brackets are optional and can be listed in any order.
where
variablelist is a list of all the variables being included in the model, including covariates if used,
depend is the dependent variable (Y in the paper),
mediator is the mediator variable (M in the paper),
dvmodlist and mmodlist are both one or two variables in order described below,
mval is a single specific value of the moderator in the mediator model,
dvval is a single specific value of the moderator in the dependent variable model,
var is the order of the variance estimate (1 or 2) (default is 2),
z is set to 1 to print the variance-covariance matrix of the model estimates (default is 0),
bootn is the number of bootstrap samples desired, in intervals of 1000 (default is 0),
j is set to 1 to produce regions of significance, if they exist, using the Johnson-Neyman method (default is 0).
dvmodlist and mmodlist should be a list of one or two variables. The first variable in the dvmodlist should be the mediator variable (M). If a second variable is provided following the mediator variable in dvmodlist, it should be a variable in the data file hypothesized to be moderating the relationship between the mediator and the dependent variable. Using the same logic, the first variable in mmodlist should be the independent variable (X in the paper). If a second variable is provided following the independent variable, it should be a variable in the data file hypothesized to be moderating the relationship between the independent variable and the mediator. If more than two variables is listed in either dvmodlist or mmodlist, an error will result. Any variable in the variables list but not included in either depend, dvmodlist, or mmodlist is treated as a covariate and partialled out of M and Y.
Using this logic, models 1 through 5 can be specified. For instance, suppose the independent variable (X) is attitude, the mediator (M) variable is shyness, the dependent variable (Y) is happy, and there are two additional potential moderator variables: activity (W) and iq (Z). The syntax below would set up the models:
Model 1
modmed vars = happy shyness attitude/dv = happy/med = shyness/dvmodel = shyness attitude/mmodel = attitude.
Model 2
modmed vars = happy shyness attitude activity/dv = happy/med = shyness/dvmodel = shyness/mmodel = attitude activity.
Model 3
modmed vars = happy shyness activity attitude/dv = happy/med = shyness/dvmodel = shyness activity/mmodel = attitude.
Model 4
modmed vars = happy shyness iq attitude activity/dv= happy/med = shyness/dvmodel = shyness iq/mmodel = attitude activity.
Model 5
modmed vars = happy shyness activity attitude/dv = happy/med = shyness/dvmodel = shyness activity/mmodel = attitude activity.
There is no need to specify the direct path from the independent variable to the dependent variable (X → Y, not shown in the Figure above), as this is included by default (and cannot be overridden).
If there were covariates (age and sex, for instance), the syntax for model 5 would look like this:
modmed vars = happy shyness activity attitude sex age /dv = happy/med = shyness/dvmodel = shyness activity/mmodel = attitude activity.
In all models with covariates, the covariates listed are included in both the mediator variable and the dependent variable models.
By default, the macro will print conditional indirect effects at the moderator mean as well as plus and minus one standard deviation, unless the moderator is dichotomous, in which case it will print the conditional indirect effects for each group defined by the moderator. If the Johnson-Neyman output is requested, it will print the conditional indirect effect across a wide range of moderator values from the minimum to the maximum moderator values in the data. It will also print, if they exist, the values of the moderator within the minimum and maximum observed values of the moderator for which the p-value for the conditional indirect effect is exactly 0.05.
As an option, you can request a conditional indirect effect at a specific value of the moderator by specifying that moderator value in the mmodv or dvmodv option. For instance, for model 3, the command
modmed vars = happy shyness activity attitude/dv = happy/med = shyness/dvmodel = shyness activity/mmodel = attitude/dvmodv = 3.
would specify model 3 and the conditional indirect effect of attitude on happiness through shyness at activity = 3.
For model 4, the command
modmed vars = happy shyness activity attitude iq/ dv= happy/med = shyness/dvmodel = shyness iq/mmodel = attitude activity/dvmodv = 3/mmodv = 2.
would specify model 4 and the conditional indirect effect of attitude on happiness through shyness at iq = 3 and activity = 2.
If you specify a specific conditional indirect effect, the macro will not print the conditional indirect effects for the mean and plus and minus one SD for the moderator.
About the bootstrapping option
When bootn is set to 1000 or larger, the bootstrapping procedure is enabled. The number of bootstrap samples, if not an interval of 1000, will be truncated to the next smallest thousand. The bootstrapping procedure estimates the conditional indirect effect as the mean conditional indirect effect calculated across the bootn bootstrap sample estimates (listed as “BootInd” in the output) and the standard error of the conditional indirect effect as the standard deviation of those bootn estimates (listed as “Boot SE” in the output). “Boot Z” in the output is the ratio of the conditional indirect effect to the estimated standard error, and the p-value (“Boot p”) is based on the standard normal distribution. As there is reason to be suspicious of the appropriateness of the standard normal distribution as the null reference distribution, interpret these p-values with caution. A percentile based, bias-corrected, and bias-corrected and accelerate bootstrap confidence interval for any conditional indirect effect that does not assume normality of the sampling distribution can be obtained by requesting a specific conditional value of the moderator using the mmodv or dvmodv options. If no specific moderator value is provided, no confidence intervals are generated in the output. For model 4, you must specify specific moderator values for BOTH moderators in order to get a bootstrap confidence interval.
When bootstrapping is combined with a request for a specific conditional indirect effect, the macro will output the bootn estimates of the indirect effect to a file name on the C drive named “bootind.sav.”
When bootstrapping is enabled, the “regions of significance” computations using the Johnson-Neyman technique are disabled.
Example
To illustrate the use of the macro, SPSS syntax corresponding to the example presented in the paper is presented below. The SPSS syntax is
modmed vars = math8 perctal scmath intrint/dv = math8/med = perctal/dvmodel = perctal scmath/mmodel = intrint/jn = 1.
and the output is
You specified model number:
3
Variables in System:
IV: intrint
DV: math8
Med Var: perctal
Mod Var: scmath
Sample size:
609
----------
MEDIATOR VARIABLE MODEL
Coeff SE
t P>|t|
Constant 3.5968
.1544 23.2938 .0000
intrint
.2105 .0301
6.9954 .0000
----------
DEPENDENT VARIABLE MODEL
Coeff
SE
t P>|t|
Constant 3.0203 1.3272 2.2757 .0232
intrint .0214 .0661 .3243 .7458
perctal .1307 .3129 .4177 .6763
scmath .5501 .2764 1.9902 .0470
Inter2 .1418 .0603 2.3507 .0191
----------
Interaction Terms:
Inter2: perctal * scmath
----------
Conditional indirect effect at specific value(s) of the moderator(s)
scmath Ind Eff SE Z P>|Z|
3.6044 .1351 .0320 4.2223 .0000
4.9245 .1745 .0310 5.6298 .0000
6.2446 .2139 .0392 5.4602 .0000
Moderator values listed are the sample mean and +/- 1 SD
----------
Conditional indirect effect at range of values of the moderator(s)
scmath Ind Eff SE Z P>|Z|
1.0000 .0574 .0549 1.0444 .2963
1.3000 .0663 .0516 1.2857 .1986
1.6000 .0753 .0484 1.5568 .1195
1.9000 .0842 .0453 1.8614 .0627
1.9902 .0869 .0444 1.9600 .0500
2.2000 .0932 .0423 2.2023 .0276
2.5000 .1021 .0396 2.5810 .0099
2.8000 .1111 .0371 2.9964 .0027
3.1000 .1201 .0349 3.4424 .0006
3.4000 .1290 .0330 3.9064 .0001
3.7000 .1380 .0316 4.3672 .0000
4.0000 .1469 .0306 4.7966 .0000
4.3000 .1559 .0302 5.1634 .0000
4.6000 .1648 .0303 5.4421 .0000
4.9000 .1738 .0309 5.6198 .0000
5.2000 .1828 .0321 5.6992 .0000
5.5000 .1917 .0337 5.6954 .0000
5.8000 .2007 .0356 5.6293 .0000
6.1000 .2096 .0380 5.5216 .0000
6.4000 .2186 .0406 5.3897 .0000
6.7000 .2275 .0434 5.2462 .0000
7.0000 .2365 .0464 5.0999 .0000
The first part of the output is the OLS regression models for the mediator and dependent variable. These are estimated independently, unlike in an SEM context in which the coefficients would be estimated simultaneously. For Model 3, the mediator model is a simple regression predicting the mediator variable (M: PERCTAL) from the independent variable (X: INTRINT), whereas the dependent variable model is a multiple regression predicting the dependent variable (Y: MATH8) from the mediator, the moderator (W: SCMATH), the independent variable, and the interaction between the moderator and the mediator. As can be seen, the independent variable significantly predicts the mediator (coefficient = 0.211, p < .001), and the effect of the mediator on the dependent variable depends on the moderator (interaction coefficient = 0.142, p = .019). The command above provides no information to the macro about specific conditional effects of interest, so the macro by default generates the conditional indirect effect of the independent variable on the dependent variable through the mediator at the mean as well as ±1SD from the mean of the moderator variable. The conditional indirect effect is statistically significant (using second-order SEs by default and assuming normality of the sampling distribution) at all these specific values of SCMATH (e.g., at SCMATH = 3.604, the conditional indirect effect is 0.135), but the conditional effect is larger for higher values (e.g., the conditional indirect effect is 0.214 when SCMATH = 6.245, compared to 0.175 when SCMATH = 4.925). The last section of the output provides conditional indirect effects at increments of the moderator, as well as SEs and p-values, ranging from the lowest observed value of the moderator to the highest observed value. When they exist, the macro also inserts the upper and/or lower bounds of values of the moderator variable for which the indirect effect is statistically significant using the Johnson-Neyman technique. When SCMATH = 1.9902, the p-value for the indirect effect is 0.05. Because there is no larger value of SCMATH in the output for which the p-value for the conditional indirect effect is larger than 0.05 within the range of the data, we conclude that the effect of early intrinsic interest in math on future performance through teacher perceptions is statistically significant when math self-concept is at least 1.99.
Using the defaults, the macro may not produce the conditional indirect effect for a specific value of the moderator of interest. Optional subcommands can be used to produce the conditional indirect effect at any desired value of the moderator. For instance, adding the subcommand "/dvmodv = 4" to the syntax line above, producing the command
modmed vars = math8 perctal scmath intrint/dv = math8/med = perctal/dvmodel = perctal scmath/mmodel = intrint/dvmodv = 4.
overrides the printing of estimates for the mean and ±1SD and instead the macro prints the conditional indirect effect at the specific value of the moderator requested (in this case, SCMATH = 4):
Conditional indirect effect at specific value(s) of the moderator(s)
scmath Ind Eff SE Z P>|Z|
4.0000 .1469 .0306 4.7966 .0000
To obtain bootstrap estimates and 95% confidence intervals, the user may add an optional bootstrap subcommand to the syntax. For example, adding "dvmodv = 4/boot = 5000", producing the command
modmed vars = math8 perctal scmath intrint/dv = math8/med = perctal/dvmodel = perctal scmath/mmodel = intrint/dvmodv = 4/boot = 5000/jn = 1.
will generate percentile, bias corrected, and bias corrected and accelerated 95% CIs for the conditional indirect effect at SCMATH = 4 using 5000 bootstrap resamples, as below:
Conditional indirect effect at specific value(s) of the moderator(s)
scmath Boot Ind Boot SE Boot Z Boot P
4.0000
.1472 .0305 4.8230 .0000
Bootstrap 95%
Confidence Intervals for Conditional Indirect Effect
Percentile
Lower
Upper
.0919
.2109
Bias Corrected
Lower
Upper
.0938
.2212
Bias Corrected
and Accelerated
Lower
Upper
.0936
.2140
----------
Conditional indirect effect at range of values of the moderator(s)
scmath Boot Ind Boot SE Boot Z Boot P
1.0000 .0592 .0633 .9355 .3495
1.3000 .0680 .0591 1.1496 .2503
1.6000 .0768 .0551 1.3935 .1635
1.9000 .0856 .0512 1.6723 .0945
2.2000 .0944 .0474 1.9915 .0464
2.5000 .1032 .0438 2.3566 .0184
2.8000 .1120 .0404 2.7720 .0056
3.1000 .1208 .0373 3.2387 .0012
3.4000 .1296 .0346 3.7507 .0002
3.7000 .1384 .0323 4.2901 .0000
4.0000 .1472 .0305 4.8230 .0000
4.3000 .1560 .0294 5.3004 .0000
4.6000 .1648 .0291 5.6695 .0000
4.9000 .1736 .0295 5.8935 .0000
5.2000 .1824 .0306 5.9672 .0000
5.5000 .1912 .0323 5.9146 .0000
5.8000 .2000 .0346 5.7743 .0000
6.1000 .2088 .0374 5.5838 .0000
6.4000 .2176 .0405 5.3717 .0000
6.7000 .2264 .0439 5.1567 .0000
7.0000 .2352 .0475 4.9495 .0000
As can be seen, the mean of 5000 bootstrap estimates of the conditional indirect effect when SCMATH = 4 is 0.147, with SD = 0.031. Assuming normality of the sampling distribution, the bootstrap Z and p-values are 4.823 and p < .001. As discussed in the paper, one advantage of bootstrapping CIs is the relaxing of this often unwarranted assumption. From the output, the percentile-based bootstrap CI for this conditional indirect effect is 0.092 to 0.210, 0.094 to 0.221 using the bias corrected method, or 0.094 to 0.214 using bias correction and acceleration. In addition, the macro produces bootstrap estimates and SEs for a range of moderator values. Because SPSS’s matrix language has no built-in sorting routine and because of the extensive computational time required to sort large vectors in SPSS Matrix, bootstrap intervals are provided only for the specific moderator value requested. This section of the output produces bootstrap p-values assuming normality of the sampling distribution of the indirect effect. These should be considered approximations trusted only in large samples.
DISCLAIMER: As with all statistical software, all attempts are made to make sure that the computations programmed into this macro are being performed correctly. When bugs are found and reported, I attempt to eliminate them as quickly as possible. I offer these macros to the research community “as is” and accept no responsibility for any negative consequences that might result from their use. In other words, use your own risk.