David A. Kenny

December 1, 2009

 

Mediation Macro

 

This mediation macro, called MedText, was written by David A. Kenny, Department of Psychology, University of Connecticut (please email me).  This is Version 1e, completed on December 1, 2009.  This macro has not been extensively tested and will almost certainly be revised, and so it is advisable to return for updates.

 

Thank You!

I thank Andrew Hayes and Kris Preacher for allowing me to adapt their bootstrapping macro into MedText.  I also thank Dave MacKinnon, Tamar Saguy, and Amanda Snook for suggestions.  Finally, I thank my good friend Bob Calsyn for the sample data.

 

Download:

MedText.SPS (You need SPSS to open this and the next 3 files.)

Sample Data File

Macro Call

SPSS Output

Macro Output (You do not need SPSS to open this file.  But if you do not use “wordwrap” it will look ugly.)   

 

To understand how to run a macro return to the DataToText page. The macro takes a few minutes to run and so be patient.  Make sure to backup the raw data file, as sometimes an error in the macro can alter the data file. Note the output (the text file) cannot be viewed in SPSS.

 

The Macro Call

 

This is the statement for the sample data:

 

MedText x = Treatment/y = Housing/m = sq_hous

/xn ='Treatment' yn ='Days Housed'

mn='Housing Contacts' xm ='yes'

ofile= 'Medtext.txt' directory='C:\'.

 

The defaults are as follows:

 

x = X

y = Y

m = M

xn ='Causal Variable'

yn ='Outcome'

mn ='Mediator' 

alpha =.05

xm='no'

ofile ='medtext.txt'

ncov = 0

clist =

trials = 5000

directory = 'C:\'

 

That is, if you just say "MedText.", the program will assume that are variables in the SPSS data file with variables named X, Y, and M.

 

MedText was written on SPSS 16 and there is no guarantee that it work on earlier or later versions of SPSS. It appears that the two tables at the end of the file are not correct if SPSS 14 or 15 is run. The macro appears to work with SPSS 17.

 

The macro:

allows for only a single causal variable, mediator, and outcome (however, if you have a multiple causal variables you can treat all but one of them as a "covariate"; also, separate runs can be conducted for each outcomes; multiple mediators are problematic),

presumes that the mediator and the outcome are measured on an interval scale,

uses listwise deletion, and

does not do a moderator analysis (though a new macro has been released).

 

Variables in the macro:

 

   x = name of the causal variable in the SPSS data set (do not use quotes)

   y = name of the outcome variable in the SPSS data set

   m = name of the mediating variable in the SPSS data set

   xn = name of the causal variable in the text output (use quotes; spaces are allowed)

   yn = name of the outcome variable in the text output (use quotes; spaces are allowed)

   mn = name of the mediating variable in the text output  (use quotes; spaces are allowed)

(For the above three variables, it is advised to use English names and not SPSS acronyms. Also it is advised to use capitals.)

   alpha  = significance level (defaults to .05)

   xm = whether the causal variable is manipulated (yes) or not (no) (use quotes and all lower case)

   ofile = the name of the output file (use quotes); this is where you go to find the text

   ncov = the number of covariates

   clist = the SPSS names of the covariates separated by spaces (make sure the number of names is equal the number of covariates).

   directory = the name of the directory where temporary files are written (use quotes); this must be a directory you are allowed to write on; MedText will leave some files on this directory when it is done; I am working on finding a way to erase them.   

   trials = the number of trials for bootstrapping (Do not set to zero!)

 

Note carefully what terms have quotes and what do not and where the slashes are where they are not.

 

There is no guarantee for accuracy.  Examine not only DataToText output file, but also the SPSS output file.  The user needs to carefully edit the MedText output in research reports.  Please cite MedText if you do use it.

 

If a non-English version of SPSS is being used, ModText changes the language to English.  It does not currently change the language back to the original language.

 

Warnings

 

ModText provides 8 possible warnings.  The user needs to pay careful attention to them.

 

1.  The outcome variable is dichotomous and logistic regression, not multiple regression, should be used.  The output from MedText in this case is wrong!

 

2.  The mediator is dichotomous and logistic regression, not multiple regression, should be used.  The output from MedText in this case is wrong!

 

3.  Given the large sample size, you might want to consider lowering alpha.

 

4.  The small sample size might preclude a mediational analysis.

 

5.   As zero does not appear to be meaningful value for mediator, you might consider grand mean centering the mediator.

 

6.   As zero does not appear to be meaningful value for causal variable, you might consider grand mean centering the causal variable.

 

7. There are outliers in the dataset.  Examine the output to see what cases are considered to be outliers.  MedText uses an the SPSS definition of plus or minus three standard deviations to determine if a case is an outlier.  It should be noted that this procedure is very conservative and not a very robust way of determining outliers.

 

8.  There is evidence that the effect of the mediator or the causal variable is nonlinear and either a data transformation or a nonlinear term might be advisable.

 

Again the user needs to pay special attention to these warnings and make the necessary modification.  For instance, based on a prior analysis of the data and warnings obtained, the mediator was transformed using a square root transformation.

 

Details on the Output

 

Some of the output might not be clear.  If so, the user should consult relevant references.

 

Power analysis: MedText takes the sample size and the number of covariates and does a power analysis for a “medium” effect size, r = .3. 

 

Tests of non-linearity:  MedText reports the quadratic main effects of the mediator and the causal variable.  The user needs to examine the output.  Certainly, sometimes the finding of nonlinearity may just be a Type I error.

 

 

Macro Output

 

If Notepad is used make sure you use the wordwrap option in formal. Also for the tables to align use Courier font.

 

 

MEDIATION MODEL

 

        The causal variable or X is Treatment, a dichotomy and is a manipulated variable, 42.2% Controls and 57.8% Experimentals, the outcome variable or Y variable is Days Housed, and the mediator variable or M is Housing Contacts.  The causal model is as follows: The variable Treatment is presumed to cause Housing Contacts which in turn is presumed to cause Days Housed.  If there were complete mediation, then the causal effect of Treatment on Days Housed would be zero. For the estimates below to be valid, it must be assumed that there is no measurement error in Housing Contacts.  Additionally, it must be assumed that there are no unmeasured common causes of Housing Contacts and Days Housed.  Finally, it must be assumed that Days Housed does not cause Housing Contacts.

 

RESULTS

 

Descriptives

 

        There are a total of 109 cases.  The means and standard deviations are presented in Table 1.  The unexplained standard deviation in Treatment is equal to .554, and the multiple correlation for the regression equation is .251.  The unexplained standard deviation in Days Housed is equal to 11.345, and the multiple correlation for the regression equation is .514.  The power of the Step 1 test assuming that path c' is zero and that paths a and b have a moderate effect size (r = .3) is .15, the power of the Step 2 test assuming that effect size is moderate (r = .3) is .89, and the power of the Step 3 and Step 4 tests assuming that paths a, b, and c' have a moderate effect size (r = .3) is .86.

 

The Four Steps

 

        The results of the four Baron and Kenny (1986) steps, which are summarized in Table 2, are as follows. The effect of Treatment on Days Housed or path c is equal to 6.558 (p = .009), with a 95% confidence interval of 1.654 to 11.462 and a medium effect size (d = .514). The mean for Experimentals is equal to 12.784 and the mean for Controls is equal to 19.342. Step 1 has been passed.  The effect of Treatment on Housing Contacts or path a is equal to .289 (p = .008), with a 95% confidence interval of .076 to .502 and a medium effect size (d = .521). The mean for Controls is equal to .616 and the mean for Experimentals is equal to .904.  Step 2 has been passed.  The effect of Housing Contacts on Days Housed controlling for Treatment or path b is equal to 10.710 (p < .001), with a 95% confidence interval of 6.785 to 14.635 and a medium effect size (r = .465). Step 3 has been passed.  The effect of Treatment on Days Housed controlling for Housing Contacts or path c' is equal to 3.468 (p = .130), with a 95% confidence interval of -1.039 to 7.974 and a small effect size (d = .306). The least squares mean for Treatment Controls is equal to 12.784 and the least squares mean for Treatment Experimentals is equal to 16.252. Step 4 has been passed.  A mediational diagram is contained in Figure 1.

 

Indirect Effects

 

        The indirect effect is equal to 3.091, with a medium effect size (d*r = .239), and the direct effect is equal to 6.558. The percentage of the total effect that is mediated is equal to 47.13.  The mediator is said to be "distal" (Hoyle & Kenny, 1999) in that standardized path b is greater than standardized path a.  Thus, Housing Contacts is "closer" to Days Housed than to Treatment.  The Sobel standard error is equal to 1.285, which makes the Z test of the indirect effect equal to 2.406 (p = .016). Because the Sobel test is statistically significant, we conclude that the indirect effect is significantly different from zero. The bootstrap estimated indirect effect is 3.067 (p = .008) with a standard error of 1.233 (Preacher & Hayes, 2008). The 95 percent bootstrap confidence interval (5000 trials) is from .932 to 5.825, and because zero is not in the confidence interval, it is concluded that the indirect effect is different from zero.

 

Tests of Nonlinearity

 

        The tests of nonlinearity are as follows:  The quadratic effect of Housing Contacts is -1.765 and is not statistically significant (p = .568).

 

                        Table 1: Descriptive Statistics

 

 

Variable                  Mean        Standard Deviation

--------------------------------------------------------

Treatment                 .422              .496

Days Housed             15.552            13.107

Housing Contacts          .737              .570

 

                         Table 2: Baron & Kenny Steps

 

 

 Step       Path       Estimate        95% CI        Beta        p

------------------------------------------------------------------

   1         c          6.558     1.654 to 11.462    .248     .009

   2         a           .289        .076 to .502    .251     .008

   3         b         10.710     6.785 to 14.635    .466    <.001

   4         c'         3.468     -1.039 to 7.974    .131     .130

 

 

Figure 1

 

Mediation Diagram

 

                                Housing Contacts

                                    /\       \

                                    /          \

                                  /              \

                                /                  \

                       .289*  /                      \  10.710*

                            /                          \

                          /                              \

                        /                                  \

                      /                                    \/

                 Treatment ______________________________> Days Housed

                                    3.468 (6.558*)

 

                                      * p < .050

 

                               References

 

      Baron, R. M., & Kenny, D. A. (1986).  The moderator-mediator variable distinction in social psychological research: Conceptual, strategic and statistical considerations. Journal of Personality and Social Psychology, 51, 1173-1182.

      Hoyle, R. H., & Kenny, D. A.  (1999).  Sample size, reliability, and tests of statistical mediation.  In R. H. Hoyle (Ed.), Statistical strategies for small sample research (pp. 195-222).  Thousand Oaks, CA:  Sage.

      Preacher, K. J., & Hayes, A. F. (2008).  Asymptotic and resampling strategies for assessing and comparing indirect effects in multiple mediator models.  Behavior Research Methods, 40, 879-891.

 

Note: Effect sizes are partial correlations (r) unless the predictor is a dichotomy and then it is Cohen's d.  Because an indirect effect is the product of two effect size, the effect size is the product of partial correlations (r*r) or Cohen's d times the partial correlation (d*r).  If the causal variable is a dichotomy, all predicted means are for the mediator and covariates equaling zero.                                                                                                                                                                                                                                                                                                                                                                                                                           

 

Return to the Top of the Page

 

 

Return to the DataToText Page