My Macros and Code for SPSS, SAS, and R
On this page you will find information about many of the macros for SPSS and SAS that I have written. Most of these are described in various publications, and I recommend you read the corresponding publication before using the macro.
As with all statistical software, all attempts are made to make sure that the computations programmed into these procedures are performed correctly. When bugs are found and reported, I attempt to eliminate them as quickly as possible. I offer this procedures to the research community "as is" and accept no responsibility for any negative consequences that might result from their use.
As with all statistical software, all attempts are made to make sure that the computations programmed into these procedures are performed correctly. When bugs are found and reported, I attempt to eliminate them as quickly as possible. I offer this procedures to the research community "as is" and accept no responsibility for any negative consequences that might result from their use.
PROCESS
Hayes, A. F. (2022). Introduction to mediation, moderation, and conditional process analysis: A regression-based approach (3rd edition). New York: The Guilford Press.
PROCESS is a macro for SPSS, SAS, and R that conducts observed-variable mediation, moderation, and conditional process analysis. It is documented in Appendices A and B of Hayes (2022).
PROCESS can be found at www.processmacro.org
Hayes, A. F. (2022). Introduction to mediation, moderation, and conditional process analysis: A regression-based approach (3rd edition). New York: The Guilford Press.
PROCESS is a macro for SPSS, SAS, and R that conducts observed-variable mediation, moderation, and conditional process analysis. It is documented in Appendices A and B of Hayes (2022).
PROCESS can be found at www.processmacro.org
MEDYAD
Coutts, J., Hayes, A. F., & Jiang, T. (2019). Easy statistical mediation analysis with distinguishable dyadic data. Journal of Communication, 69, 612-549. [PDF]
MEDYAD is an easy-to-use regression-based computational tool for SPSS, SAS, and R that conducts mediation analysis with distinguishable dyadic data. In its most general form, it implements the Actor-Partner Independence Model extended to Mediation (APIMeM), but it is capable of simpler and more complex variants of the basic APIMeM. MEDYAD estimates the direct and indirect effects of each actor’s X on their own and their partner’s Y through their own and their partner’s mediator M. Options are available for conducting all possible pairwise comparisons between indirect effects that can be constructed linking an X to a Y through an M. Bootstrapping methods are available for inference about indirect effects and differences between them. MEDYAD allows up to twelve mediators (up to six measured on each member of the dyad, or twelve if each mediator measures an aspect of the relationship or a single member of the dyad) and can conduct contrasts between indirect effects within and between dyads and between and within mediators. MEDYAD also allows for the specification of an X or Y that measures a property of the dyad rather than of the individual member of the dyad. Numerous additional options are available, including options for controlling for covariates and saving bootstrap estimates of effects for further analysis.
Download MEDYAD from Jacob's web page.
Coutts, J., Hayes, A. F., & Jiang, T. (2019). Easy statistical mediation analysis with distinguishable dyadic data. Journal of Communication, 69, 612-549. [PDF]
MEDYAD is an easy-to-use regression-based computational tool for SPSS, SAS, and R that conducts mediation analysis with distinguishable dyadic data. In its most general form, it implements the Actor-Partner Independence Model extended to Mediation (APIMeM), but it is capable of simpler and more complex variants of the basic APIMeM. MEDYAD estimates the direct and indirect effects of each actor’s X on their own and their partner’s Y through their own and their partner’s mediator M. Options are available for conducting all possible pairwise comparisons between indirect effects that can be constructed linking an X to a Y through an M. Bootstrapping methods are available for inference about indirect effects and differences between them. MEDYAD allows up to twelve mediators (up to six measured on each member of the dyad, or twelve if each mediator measures an aspect of the relationship or a single member of the dyad) and can conduct contrasts between indirect effects within and between dyads and between and within mediators. MEDYAD also allows for the specification of an X or Y that measures a property of the dyad rather than of the individual member of the dyad. Numerous additional options are available, including options for controlling for covariates and saving bootstrap estimates of effects for further analysis.
Download MEDYAD from Jacob's web page.
OMEGA
Hayes, A. F., & Coutts, J. J. (2020). Use omega rather than Cronbach's alpha for estimating reliability. But... Communication Methods and Measures, 14, 1-24. [PDF]
Cronbach's alpha is the most widely-used measure of reliability when estimating the amount of random measurement error that exists in a sum score or average generated by a multi-item measurement scale. Yet methodologists have warned that a is not an optimal measure of reliability relative to its more general form, McDonald's omega. Hindering its more widespread adoption is the fact that the computation of omega heretofore has required the estimation of item factor loadings and error variances in a confirmatory factor analysis (CFA). Omega is an easy-to use macro for SPSS and SAS that calculates McDonald's omega without relying on the estimation of factor loadings or error variances using CFA. The OMEGA macro also generates all possible subscales of at least three items from an additive scale containing k items. For each possible subscale, it generates omega and the subscale-full scale correlation and displays information about each subscale in a data spread sheet. It also generates summary statistics making it easy to find the most psychometrically appealing brief form of a longer measurement instrument. Most of the features available for omega are also available for Cronbach's alpha, which the OMEGA macro can also generate.
Download OMEGA here: omega.zip
(Note: The archive also contains the "blirt" data files mentioned in the paper)
Hayes, A. F., & Coutts, J. J. (2020). Use omega rather than Cronbach's alpha for estimating reliability. But... Communication Methods and Measures, 14, 1-24. [PDF]
Cronbach's alpha is the most widely-used measure of reliability when estimating the amount of random measurement error that exists in a sum score or average generated by a multi-item measurement scale. Yet methodologists have warned that a is not an optimal measure of reliability relative to its more general form, McDonald's omega. Hindering its more widespread adoption is the fact that the computation of omega heretofore has required the estimation of item factor loadings and error variances in a confirmatory factor analysis (CFA). Omega is an easy-to use macro for SPSS and SAS that calculates McDonald's omega without relying on the estimation of factor loadings or error variances using CFA. The OMEGA macro also generates all possible subscales of at least three items from an additive scale containing k items. For each possible subscale, it generates omega and the subscale-full scale correlation and displays information about each subscale in a data spread sheet. It also generates summary statistics making it easy to find the most psychometrically appealing brief form of a longer measurement instrument. Most of the features available for omega are also available for Cronbach's alpha, which the OMEGA macro can also generate.
Download OMEGA here: omega.zip
(Note: The archive also contains the "blirt" data files mentioned in the paper)
MEMORE
(MEdiation and MOderation in REpeated-measures designs)
Montoya, A. K., & Hayes, A. F. (2017). Two condition within-participant statistical mediation analysis: A path-analytic framework. Psychological Methods, 22, 6-27. [PDF]
MEMORE is a macro for SPSS and SAS that estimates the total, direct, and indirect effects of X on Y through one or more mediators M in the two-condition or two-occasion within-subjects/repeated measures design. In a path-analytic form using OLS regression, it implements the method described by Judd, Kenny, and McClelland (2001, Psychological Methods), extended to multiple mediators. Along with an estimate of the indirect effect(s), MEMORE generates confidence intervals for inference about the indirect effect(s) using bootstrapping, Monte Carlo, or normal theory approaches. MEMORE also provides an option that conducts pairwise contrasts between specific indirect effects in models with multiple mediators.
Download MEMORE from Amanda Montoya's web page.
If you have questions about the use of MEMORE, email Amanda Montoya at UCLA (akmontoya@psych.ucla.edu)
(MEdiation and MOderation in REpeated-measures designs)
Montoya, A. K., & Hayes, A. F. (2017). Two condition within-participant statistical mediation analysis: A path-analytic framework. Psychological Methods, 22, 6-27. [PDF]
MEMORE is a macro for SPSS and SAS that estimates the total, direct, and indirect effects of X on Y through one or more mediators M in the two-condition or two-occasion within-subjects/repeated measures design. In a path-analytic form using OLS regression, it implements the method described by Judd, Kenny, and McClelland (2001, Psychological Methods), extended to multiple mediators. Along with an estimate of the indirect effect(s), MEMORE generates confidence intervals for inference about the indirect effect(s) using bootstrapping, Monte Carlo, or normal theory approaches. MEMORE also provides an option that conducts pairwise contrasts between specific indirect effects in models with multiple mediators.
Download MEMORE from Amanda Montoya's web page.
If you have questions about the use of MEMORE, email Amanda Montoya at UCLA (akmontoya@psych.ucla.edu)
RLM
Darlington, R. B. & Hayes, A. F. (2017). Regression analysis and linear models: Concepts, application, and implementation. New York: The Guilford Press [purchase]
The RLM macro was released with the publication of Regression Analysis and Linear Models in the summer of 2016. It can be downloaded from the book's web page and is documented in Appendix A of the book. Available for SPSS and SAS, RLM is a supplement to SAS and SPSS's regression modules. In addition to the usual regression program output, it has options for heteroscedasticity-consistent inference (using either the HC0, HC1, HC2, HC3, or HC4 variance-covariance matrix), automatic coding of a multicategorical categorical regressor, options for estimating and probing interactions involving a multicategorical regressor, all subsets regression, spline regression, crossvalidation indices for the multiple correlation, an implementation of a limited form of dominance analysis, contrasts between regression coefficients, and a few other features.
Darlington, R. B. & Hayes, A. F. (2017). Regression analysis and linear models: Concepts, application, and implementation. New York: The Guilford Press [purchase]
The RLM macro was released with the publication of Regression Analysis and Linear Models in the summer of 2016. It can be downloaded from the book's web page and is documented in Appendix A of the book. Available for SPSS and SAS, RLM is a supplement to SAS and SPSS's regression modules. In addition to the usual regression program output, it has options for heteroscedasticity-consistent inference (using either the HC0, HC1, HC2, HC3, or HC4 variance-covariance matrix), automatic coding of a multicategorical categorical regressor, options for estimating and probing interactions involving a multicategorical regressor, all subsets regression, spline regression, crossvalidation indices for the multiple correlation, an implementation of a limited form of dominance analysis, contrasts between regression coefficients, and a few other features.
MLMED
Rockwood, N. J. & Hayes, A. F. (2017, May). MLmed: An SPSS macro for multilevel mediation and conditional process analysis. Poster presented at the annual meeting of the Association of Psychological Science (APS), Boston, MA. [PDF]
Hayes, A. F., & Rockwood, N. J. (2020). Conditional process analysis: Concepts, computation, and advances in the modeling of the contingencies of mechanisms. American Behavioral Scientist [PDF]
MLMED is an SPSS macro that conducts multilevel mediation and conditional process analysis. You can learn about MLMED by downloading the documentation and Nick Rockwood's MA thesis at www.njrockwood.com. MLMED and multilevel mediation and conditional process analysis is also discussed in Hayes and Rockwood (2020).
Download MLMED from Nick Rockwood's web page.
If you have questions about the use of MLMED, email Nick Rockwood at nrockwood@llu.edu
Rockwood, N. J. & Hayes, A. F. (2017, May). MLmed: An SPSS macro for multilevel mediation and conditional process analysis. Poster presented at the annual meeting of the Association of Psychological Science (APS), Boston, MA. [PDF]
Hayes, A. F., & Rockwood, N. J. (2020). Conditional process analysis: Concepts, computation, and advances in the modeling of the contingencies of mechanisms. American Behavioral Scientist [PDF]
MLMED is an SPSS macro that conducts multilevel mediation and conditional process analysis. You can learn about MLMED by downloading the documentation and Nick Rockwood's MA thesis at www.njrockwood.com. MLMED and multilevel mediation and conditional process analysis is also discussed in Hayes and Rockwood (2020).
Download MLMED from Nick Rockwood's web page.
If you have questions about the use of MLMED, email Nick Rockwood at nrockwood@llu.edu
OGRS
Hayes, A. F., & Montoya, A. K. (2017). A tutorial on estimating, visualizing and probing an interaction involving a multicategorical independent variable in linear regression analysis. Communication Methods and Measures, 11, 1-30 [PDF]
OGRS (Omnibus Groups Regions of Significance) is a macro for SPSS and SAS that implements the Johnson-Neyman technique (via iterative approximation) for probing an interaction when the independent variable is multicategorical (i.e., three or more groups) and the moderator is continuous. It was written by Amanda Montoya and is described, tested, and documented in Montoya (2016). The paper referenced above illustrates its use.
Download OGRS from Amanda Montoya's web page.
If you have questions about the use of OGRS, email Amanda Montoya at UCLA (akmontoya@psych.ucla.edu)
Hayes, A. F., & Montoya, A. K. (2017). A tutorial on estimating, visualizing and probing an interaction involving a multicategorical independent variable in linear regression analysis. Communication Methods and Measures, 11, 1-30 [PDF]
OGRS (Omnibus Groups Regions of Significance) is a macro for SPSS and SAS that implements the Johnson-Neyman technique (via iterative approximation) for probing an interaction when the independent variable is multicategorical (i.e., three or more groups) and the moderator is continuous. It was written by Amanda Montoya and is described, tested, and documented in Montoya (2016). The paper referenced above illustrates its use.
Download OGRS from Amanda Montoya's web page.
If you have questions about the use of OGRS, email Amanda Montoya at UCLA (akmontoya@psych.ucla.edu)
INDIRECT, SOBEL, MEDIATE, MODMED, and MODPROBE
These macros are all obsolete with the release of PROCESS, which can do pretty much everything that these five macros can do and a whole lot more. PROCESS can be found at www.processmacro.org and is documented in Introduction to Mediation, Moderation, and Conditional Process Analysis
If you still want to use one of these macros, they can be downloaded in one archive right here. The archive contains five folders, one for each macro. I no longer support or respond to questions about these macros.
These macros are all obsolete with the release of PROCESS, which can do pretty much everything that these five macros can do and a whole lot more. PROCESS can be found at www.processmacro.org and is documented in Introduction to Mediation, Moderation, and Conditional Process Analysis
If you still want to use one of these macros, they can be downloaded in one archive right here. The archive contains five folders, one for each macro. I no longer support or respond to questions about these macros.
MEDCURVE
Hayes, A. F., & Preacher, K. J. (2010). Quantifying and testing indirect effects in simple mediation models when the constituent paths are nonlinear. Multivariate Behavioral Research, 45, 627-660. [PDF]
This macro for SPSS and SAS estimates instantaneous indirect effects in simple mediation models with nonlinear paths, as discussed in Hayes and Preacher (2010), and produces bootstrap confidence intervals for inference. The X->M, M|X->Y, and X|M->Y paths can be estimated as linear, quadratic, exponential, log, or inverse, in any combination, thereby allowing for the estimation of 125 different models.
Download MEDCURVE: medcurve.zip
Note: There is an error in the equation for Y-hat at the bottom of page 640 of Preacher and Hayes (2010). This equation should read Y-hat = -2.0823 + 1.1197(X) - 0.1292(X*X) + 0.7896(M). This does not affect any of the computations anywhere in the manuscript.
Hayes, A. F., & Preacher, K. J. (2010). Quantifying and testing indirect effects in simple mediation models when the constituent paths are nonlinear. Multivariate Behavioral Research, 45, 627-660. [PDF]
This macro for SPSS and SAS estimates instantaneous indirect effects in simple mediation models with nonlinear paths, as discussed in Hayes and Preacher (2010), and produces bootstrap confidence intervals for inference. The X->M, M|X->Y, and X|M->Y paths can be estimated as linear, quadratic, exponential, log, or inverse, in any combination, thereby allowing for the estimation of 125 different models.
Download MEDCURVE: medcurve.zip
Note: There is an error in the equation for Y-hat at the bottom of page 640 of Preacher and Hayes (2010). This equation should read Y-hat = -2.0823 + 1.1197(X) - 0.1292(X*X) + 0.7896(M). This does not affect any of the computations anywhere in the manuscript.
MEDTHREE and MED3C
Hayes, A. F., Preacher, K. J., & Myers, T. A. (2010). Mediation and the estimation of indirect effects in political communication research. In E. P. Bucy & R. Lance Holbert (Eds), Sourcebook for political communication research: Methods, measures, and analytical techniques. New York: Routledge. [at the publisher's page]
MEDTHREE and MED3C have been discontinued. PROCESS is capable of doing everything these can do and PROCESS provides much more detailed output and many more options. MEDTHREE and MED3C are thus obsolete. For a discussion of the serial mediation model described in this book chapter, see Hayes (2022).
Hayes, A. F., Preacher, K. J., & Myers, T. A. (2010). Mediation and the estimation of indirect effects in political communication research. In E. P. Bucy & R. Lance Holbert (Eds), Sourcebook for political communication research: Methods, measures, and analytical techniques. New York: Routledge. [at the publisher's page]
MEDTHREE and MED3C have been discontinued. PROCESS is capable of doing everything these can do and PROCESS provides much more detailed output and many more options. MEDTHREE and MED3C are thus obsolete. For a discussion of the serial mediation model described in this book chapter, see Hayes (2022).
HCREG
Hayes, A. F., & Cai, L. (2007). Using heteroscedasticity-consistent standard error estimators in OLS regression: An introduction and software implementation. Behavior Research Methods, 39, 709-722.
New to HCREG in November 2019: Newey-West standard errors!
This macro for SPSS and SAS is used for estimating OLS regression models but with heteroscedasticity-consistent standard errors using the HC0, HC1, HC2, HC3, HC4, and Newey-West procedures as described by MacKinnon and White (1985), Long and Ervin (2000), and Cribari-Neto (2004).
NOTE: This macro is mostly obsolete with the release of RLM, which is available for both SPSS and SAS and implements the HC0, HC1, HC2, HC3, and HC4 standard error estimators discussed in this article. RLM is documented in Darlington and Hayes (2017). Unlike HCREG, RLM can also estimate and probe interactions involving a multicategorical variable.
Download HCREG: hcreg.zip
Documentation: see the Appendix of the article
Hayes, A. F., & Cai, L. (2007). Using heteroscedasticity-consistent standard error estimators in OLS regression: An introduction and software implementation. Behavior Research Methods, 39, 709-722.
New to HCREG in November 2019: Newey-West standard errors!
This macro for SPSS and SAS is used for estimating OLS regression models but with heteroscedasticity-consistent standard errors using the HC0, HC1, HC2, HC3, HC4, and Newey-West procedures as described by MacKinnon and White (1985), Long and Ervin (2000), and Cribari-Neto (2004).
NOTE: This macro is mostly obsolete with the release of RLM, which is available for both SPSS and SAS and implements the HC0, HC1, HC2, HC3, and HC4 standard error estimators discussed in this article. RLM is documented in Darlington and Hayes (2017). Unlike HCREG, RLM can also estimate and probe interactions involving a multicategorical variable.
Download HCREG: hcreg.zip
Documentation: see the Appendix of the article
KALPHA
Hayes, A. F., & Krippendorff, K. (2007). Answering the call for a standard reliability measure for coding data. Communication Methods and Measures, 1, 77-89.
This macro computes Krippendorff's alpha reliability estimate for subjective judgments made at any level of measurement, any number of judges, with or without missing data.
Download KALPHA: kalpha.zip
Here is a document that describes the bootstrapping algorithm.
Hayes, A. F., & Krippendorff, K. (2007). Answering the call for a standard reliability measure for coding data. Communication Methods and Measures, 1, 77-89.
This macro computes Krippendorff's alpha reliability estimate for subjective judgments made at any level of measurement, any number of judges, with or without missing data.
Download KALPHA: kalpha.zip
Here is a document that describes the bootstrapping algorithm.
HETREG
Cai, L., & Hayes, A. F. (2007). A new test of linear hypotheses under heteroscedasticity of unknown form. Journal of Educational and Behavioral Statistics, 33, 21-40. [PDF]
This SAS macro implements a new test for the regression coefficients in OLS regression that does not assume homoscedasticity. The paper includes some simulation results showing its superiority over the heteroscedasticity-consistent standard error estimators summarized by Long & Ervin (2000).
Documentation: See Appendix B of the article.
Macro: hetreg.sas
Cai, L., & Hayes, A. F. (2007). A new test of linear hypotheses under heteroscedasticity of unknown form. Journal of Educational and Behavioral Statistics, 33, 21-40. [PDF]
This SAS macro implements a new test for the regression coefficients in OLS regression that does not assume homoscedasticity. The paper includes some simulation results showing its superiority over the heteroscedasticity-consistent standard error estimators summarized by Long & Ervin (2000).
Documentation: See Appendix B of the article.
Macro: hetreg.sas