Also see SPSS Moderation Regression Tutorial.
- Regression with Moderation Effect
- Downloading and Installing the Mean Centering Tool
- Using the Mean Centering Tool
- Mean Centering Tool - Results
A sports doctor wants to know if and how training and age relate to body muscle percentage. His data on 243 male patients are in muscle-percent-males.sav, part of which is shown below.
Regression with Moderation Effect
The basic way to go with these data is to run multiple regression with age and training hours as predictors. However, our doctor expects a moderation interaction effect between age and training. Precisely, he believes that the effect of training on muscle percentage diminishes with age. The diagram below illustrates the basic idea.
The moderation effect can be tested by creating a new variable that represents this interaction effect. We'll do just that in 3 steps:
- mean center both predictors: subtract the variable means from all individual scores. This results in centered predictors having zero means.
- compute the interaction predictor as the product of the mean centered predictors;
- run a multiple regression analysis with 3 predictors: the mean centered predictors and the interaction predictor.
Steps 1 and 2 can be done with basic syntax as covered in How to Mean Center Predictors in SPSS? However, we'll present a simple tool below that does these steps for you.
Downloading and Installing the Mean Centering Tool
First off, you need SPSS with the SPSS-Python-Essentials for installing this tool. The tool is downloadable from SPSS_TUTORIALS_MEAN_CENTER.spe.
After downloading it, open SPSS and navigate to
as shown below.
For older SPSS versions, try You may need to run SPSS as an administrator (by right-clicking its desktop shortcut) in order to install any tools.
Using the Mean Centering Tool
First open some data such as muscle-percent-males.sav. After installing the mean centering tool, you'll find it in the menu.
This opens a dialog as shown below. Note that string variables don't show up here: these need to be converted to numeric variable before they can be mean centered.
Variable names for the centered predictors consist of a prefix + the original variable names. In this example, mean centered age and thours will be named cent_age and cent_thours.
Optionally, create new variables holding all 2-way interaction effects among the centered predictors. For 2 predictors, this results in only 1 interaction predictor.
Clicking results in the syntax below. Let's run it.
SPSS_TUTORIALS_MEAN_CENTER VARIABLES = "age thours"
/OPTIONS PREFIX = cent_ CHECKTABLE INTERACTIONS.
Mean Centering Tool - Results
In variable view, note that 3 new variables have been created (and labeled). Precisely these 3 variables should be entered as predictors into our regression model.
If a checktable was requested, you'll find a basic Descriptive Statistics table in the output window.
Note that the mean centered predictors have exactly zero means. Their standard deviations, however, are left unaltered by the mean centering -which is precisely how this procedure differs from computing z-scores.
Right, so that'll do for our mean centering tool. We'll cover a regression analysis with a moderation interaction effect in 1 or 2 weeks or so.
Thanks for reading!
THIS TUTORIAL HAS 40 COMMENTS:
By Emily on June 30th, 2015
Hi, I I have run the macro without problem for a few select variables and now would like to perform it on all variables in a dataset by typing ALL in the variable list in the utility box. I keep getting an error stating that the aggregate command cannot run because there are string variables in the dataset.
>Error # 10938. Command name: aggregate
>A function which requires a numeric variable has been used with a string
>variable.
How can I get the syntax to skip over string variables or ignore them altogether? Thanks.
Emily
(I run SPSS 22.)
By Ruben Geert van den Berg on July 4th, 2015
The simplest option is adjusting the variable specification: note that you can use TO here and your data having a mixture of numeric and string variables is the exact reason we wrote it like we did. For instance, if you have n1 n2 n3 s1 n4 in your data where "n" denotes "numeric" and "s" denotes "string",
n1 to n3 n4
will specify the numeric variables only.Alternatively, you could move all string variables to the end of your file by a tiny Python script.
HTH,
Ruben
By Ema on August 19th, 2015
Hi, I am running into the same problem as described by Stephanie below and getting the following erro: Error # 6890. Command name: begin program
Configuration file spssdxcfg.ini is invalid.
Execution of this command stops.
Configration file spssdxcfg.ini is invalid because the LIB_NAME is NULL.
I am running SPSS 22 which should have the Python installed automatically, how do I hence uninstall it as you suggested to her? Many thanks!
By Ruben Geert van den Berg on August 20th, 2015
"I am running SPSS 22 which should have the Python installed automatically" No, that's not entirely correct. During SPSS' installation process, you need to select a tick box for installing the Python Essentials as well. If you don't do so, you'll have SPSS 22 without the Python Essentials.
I think uninstalling and reinstalling SPSS altogether from scratch -and making sure the Python Essentials are selected- may be the only way to get things up and running but I can't say for sure. Another visitor recently had similar problems and posted them here. To my surprise, however, it seems he didn't receive help yet -at least not publicly.
I'll contact him personally to see whether perhaps he got instructions in a private message. If that doesn't help, I'll contact somebody from SPSS support myself. I've seen this issue too many times and I can perhaps better support my visitors by writing a tutorial on resolving this problem.
By Yunyi on August 21st, 2015
Hello,
I use spss21. The output shows error message like: >Error # 6890. Command name: begin program
>Configuration file spssdxcfg.ini is invalid.
>Execution of this command stops.
Configration file spssdxcfg.ini is invalid because the LIB_NAME is NULL.
I didn't save the "mean center variables" custom dialog at the same place of the SPSS. Could that be the reason that lead to it doesn't work?