Using INDIRECT macro with SPSS

TU Eindhoven \ 21-10-2010

I write the following tutorial for a Master subject on data analysis using SPSS. This text is about mediation analysis based on bootstrapping, thus not the well documented method by Baron and Kenny. Because my findings may be relevant to a wider public I placed the tutorial online here. Just so my loyal readers do not confuse this with the expected juicy stories...


For some running the mediation analysis INDIRECT script by Preacher & Hayes does not work in SPSS 18. This could be for various reasons of which I understand little (if not to say nothing). But fortunately there is another way to get the same results: just use the macro version of the same script!

Preacher and Hayes have made two varieties of INDIRECT; a script (with the extension of .SBS) and a macro syntax file (extension is .SPS like normal SPSS syntax files). The difference is the way both work. The script gives you a GUI so you can just click to assign variables and setup the analysis. The macro syntax requires some extra work as it uses just SPSS syntax. But in case the easier scripting method does not work the syntax method might work (at least it did for me using SPSS 18.0.2 on Mac OS X 10.6).

In short, with the macro you first have to run its generic syntax to set up SPSS and then use some syntax specific for your analysis. The latter part is similar to assigning variables in the script GUI and looks quite like the average ANOVA or regression syntax. So it’s not all that scary and difficult…

Before starting

Using the INDIRECT macro syntax in steps

Step 1

Open your database in SPSS.

Step 2

Open the indirect.sps syntax file and run it once to set up SPSS. The best solution is to select everything by pressing Command+A or CTRL+A and then click to run. Running should take just a few seconds. Check afterwards whether SPSS states in the bottom that ‘PASW Statistics Processor is ready,’ as I found that it may hang if the syntax is not fully selected due to a missed closing statement in the syntax (although it clearly is there). The only way to deal with that is to force quit SPSS (Command-Option-Esc on a Mac, CTRL-ALT-DEL for Windows) and restart SPSS.

This is the only awkward step!

Step 3

Open a new syntax window or use my template to assign your variables. For this you may refer to the guide on Hayes’ website to see the various options.

Simple example for effect of controlVersusConditionB on Safety, mediated by Escape:

INDIRECT Y = Safety
 /X = controlVersusB
 /M = Escape.

Same example as above - now using a different number of samples for bootstrapping and CI of 99%:

INDIRECT Y = Safety
 /X = controlVersusB
 /M = Escape
 /BOOT = 5000
 /CONF = 99.

Same example as above - now adding two covariates:

INDIRECT Y = Safety
 /X = controlVersusB
 /M = Escape age length
 /C = 2
 /BOOT = 5000
 /CONF = 95.

Same example as above - now using multiple mediators, percentile bootstrap method, and contrast of indirect effects:

INDIRECT Y = Safety
 /X = controlVersusB
 /M = Escape Prospect HidingCrim
 /BOOT = 5000
 /CONF = 95
 /PERCENT = 1
 /BCA = 0
 /CONTRAST = 1.

Step 4

Run your syntax as normal. Computation can take some time, especially for large numbers of bootstrapping samples taken.

Step 5

Output will appear as usual. It is exactly similar to the INDIRECT script output.

Final words

Hopefully this short explanation helped you to get the INDIRECT mediation analysis running. If not, you could also have a look at the Facebook group on mediation and moderation analysis, which is frequented by Preacher and Hayes themselves.

Update: in case SPSS gives memory errors

My experience so far shows this method works fine as long as you do not ask for results based on normality assumptions (add syntax /NORMAL=1 to enable). The issue is somehow due to freeing memory after all calculations have been done, so basically you do get the results but SPSS crashes immediately afterwards. You may not experience this if your computer has more memory available (in my case 2 Gb of which SPSS only desires to use 1 Gb for unknown reasons). The best way to deal with this is to run the analysis anyway, but first save the output window. Upon getting the error message which asks to restart SPSS choose No and check the output window. All the results will be there! Just save and now you should restart SPSS.