MODERATED_REGRESSION | R Documentation |
Conducts moderated regression analyses for two-way interactions with extensive options for interaction plots, including Johnson-Neyman regions of significance. The output includes the Anova Table (Type III tests), standardized coefficients, partial and semi-partial correlations, collinearity statistics, casewise regression diagnostics, plots of residuals and regression diagnostics, and detailed information about simple slopes. The output includes Bayes Factors and, if requested, regression coefficients from Bayesian Markov Chain Monte Carlo (MCMC) analyses.
MODERATED_REGRESSION(data, DV, IV, MOD,
IV_type = 'numeric', IV_range = 'tumble',
MOD_type='numeric', MOD_levels='quantiles', MOD_range=NULL,
quantiles_IV = c(.1, .9), quantiles_MOD = c(.25, .5, .75),
COVARS = NULL,
center = TRUE,
CI_level = 95,
MCMC = FALSE,
Nsamples = 10000,
plot_type = 'residuals', plot_title=NULL, DV_range = NULL,
Xaxis_label = NULL, Yaxis_label=NULL, legend_label=NULL,
JN_type = 'Huitema',
verbose = TRUE )
data |
A dataframe where the rows are cases and the columns are the variables. |
DV |
The name of the dependent variable.
|
IV |
The name of the independent variable.
|
MOD |
The name of the moderator variable
|
IV_type |
(optional) The type of independent variable. The
options are 'numeric' (the default) or 'factor'.
|
IV_range |
(optional) The independent variable range for a moderated regression plot. The options are:
Example: IV_range = 'AikenWest' |
MOD_type |
(optional) The type of moderator variable. The
options are 'numeric' (the default) or 'factor'.
|
MOD_levels |
(optional) The levels of the moderator variable to be used if MOD is continuous. The options are:
Example: MOD_levels = c(1, 10) |
MOD_range |
(optional) The range of the MOD values to be used in the Johnson-Neyman regions
of significance analyses. The options are:
NULL (the default), in which case the minimum and maximum MOD values will be used; and
a vector of two user-provided values.
|
quantiles_IV |
(optional) The quantiles of the independent variable to be used as the IV range for
a moderated regression plot.
|
quantiles_MOD |
(optional) The quantiles the moderator variable to be used as the MOD simple slope
values in the moderated regression analyses.
|
COVARS |
(optional) The name(s) of possible covariates.
|
center |
(optional) Logical, indicating whether the IV and MOD variables should be centered
(default = TRUE).
|
CI_level |
(optional) The confidence interval for the output, in whole numbers. CI_level is also used in the Johnson-Neyman regions of significance computations. The default is 95. |
MCMC |
(logical) Should Bayesian MCMC analyses be conducted? The default is FALSE. |
Nsamples |
(optional) The number of samples for MCMC analyses. The default is 10000. |
plot_type |
(optional) The kind of plot, if any. The options are:
Example: plot_type = 'diagnostics' |
plot_title |
(optional) The plot title.
|
DV_range |
(optional) The range of Y-axis values for the plot.
|
Xaxis_label |
(optional) A label for the X axis to be used in the requested plot.
|
Yaxis_label |
(optional) A label for the Y axis to be used in the requested plot.
|
legend_label |
(optional) A legend label for the plot.
|
JN_type |
(optional) The formula to be used in computing the critical F value for the
Johnson-Neyman regions of significance analyses. The options are 'Huitema' (the default),
or 'Pedhazur'.
|
verbose |
Should detailed results be displayed in console? The options are: TRUE (default) or FALSE. If TRUE, plots of residuals are also produced. |
The Bayesian MCMC analyses can be time-consuming for larger datasets. The MCMC analyses are conducted using functions, and their default settings, from the BayesFactor package (Morey & Rouder, 2024). The MCMC results can be verified using the model checking functions in the rstanarm package (e.g., Muth, Oravecz, & Gabry, 201).
An object of class "MODERATED_REGRESSION". The object is a list containing the following possible components:
modelMAINsum |
All of the summary.lm function output for the regression model without interaction terms. |
anova_table |
Anova Table (Type III tests). |
mainRcoefs |
Predictor coefficients for the model without interaction terms. |
modeldata |
All of the predictor and outcome raw data that were used in the model, along with regression diagnostic statistics for each case. |
collin_diags |
Collinearity diagnostic coefficients for models without interaction terms. |
modelXNsum |
Regression model statistics with interaction terms. |
RsqchXn |
Rsquared change for the interaction. |
fsquaredXN |
fsquared change for the interaction. |
xnRcoefs |
Predictor coefficients for the model with interaction terms. |
simslop |
The simple slopes. |
simslopZ |
The standardized simple slopes. |
plotdon |
The plot data for a moderated regression. |
JN.data |
The Johnson-Neyman results for a moderated regression. |
ros |
The Johnson-Neyman regions of significance for a moderated regression. |
Brian P. O'Connor
Bodner, T. E. (2016). Tumble graphs: Avoiding misleading end point extrapolation when
graphing interactions from a moderated multiple regression analysis.
Journal of Educational and Behavioral Statistics, 41, 593-604.
Cohen, J., Cohen, P., West, S. G., & Aiken, L. S. (2003). Applied
multiple regression/correlation analysis for the behavioral sciences (3rd ed.).
Lawrence Erlbaum Associates.
Darlington, R. B., & Hayes, A. F. (2017). Regression analysis and linear models:
Concepts, applications, and implementation. Guilford Press.
Hayes, A. F. (2018a). Introduction to mediation, moderation, and conditional process
analysis: A regression-based approach (2nd ed.). Guilford Press.
Hayes, A. F., & Montoya, A. K. (2016). A tutorial on testing, visualizing, and probing
an interaction involving a multicategorical variable in linear regression analysis.
Communication Methods and Measures, 11, 1-30.
Lee M. D., & Wagenmakers, E. J. (2014) Bayesian cognitive modeling: A practical
course. Cambridge University Press.
Morey, R. & Rouder, J. (2024). BayesFactor: Computation of Bayes Factors for
Common Designs. R package version 0.9.12-4.7,
https://github.com/richarddmorey/bayesfactor.
Muth, C., Oravecz, Z., & Gabry, J. (2018). User-friendly Bayesian regression
modeling: A tutorial with rstanarm and shinystan. The Quantitative Methods
for Psychology, 14(2), 99119.
https://doi.org/10.20982/tqmp.14.2.p099
O'Connor, B. P. (1998). All-in-one programs for exploring interactions in moderated
multiple regression. Educational and Psychological Measurement, 58, 833-837.
Pedhazur, E. J. (1997). Multiple regression in behavioral research: Explanation
and prediction. (3rd ed.). Wadsworth Thomson Learning.
# moderated regression -- with IV_range = 'AikenWest'
MODERATED_REGRESSION(data=data_Lorah_Wong_2018, DV='suicidal', IV='burden', MOD='belong_thwarted',
IV_range='AikenWest',
MOD_levels='quantiles',
quantiles_IV=c(.1, .9), quantiles_MOD=c(.25, .5, .75),
center = TRUE, COVARS='depression',
plot_type = 'interaction', plot_title=NULL, DV_range = c(1,1.25))
# moderated regression -- with IV_range = 'tumble'
MODERATED_REGRESSION(data=data_Lorah_Wong_2018, DV='suicidal', IV='burden', MOD='belong_thwarted',
IV_range='tumble',
MOD_levels='quantiles',
quantiles_IV=c(.1, .9), quantiles_MOD=c(.25, .5, .75),
center = TRUE, COVARS='depression',
plot_type = 'interaction', plot_title=NULL, DV_range = c(1,1.25))
# moderated regression -- with numeric values for IV_range & MOD_levels='AikenWest'
MODERATED_REGRESSION(data=data_OConnor_Dvorak_2001, DV='Aggressive_Behavior',
IV='Maternal_Harshness', MOD='Resiliency',
IV_range=c(1,7.7),
MOD_levels='AikenWest', MOD_range=NULL,
quantiles_IV=c(.1, .9), quantiles_MOD=c(.25, .5, .75),
center = FALSE,
plot_type = 'interaction',
DV_range = c(1,6),
Xaxis_label='Maternal Harshness',
Yaxis_label='Adolescent Aggressive Behavior',
legend_label='Resiliency')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.