Description Usage Arguments Value Examples
Calculates a standardized two way or three way interaction and plots using ggplot2.
1 2 3 4 5 |
data |
an object of class 'data.frame' or 'imputationList'. |
outcome |
a string with the name of the outcome variable. |
predictor |
a string with the name of the predictor variable. |
moderator |
a vector of the names of up to two moderating variables. |
y.lim |
vector of numerals indicating y axis bounds. |
x.lim |
vector of numerals indicating x axis bounds. |
x.lab |
a string with the label of the x axis. |
y.lab |
a string with the label of the y axis. |
title |
a string containing title text. |
title.size |
a numeral containing the font size of the title. |
SDs |
a numeral indicating the standard deviations of the moderators. |
legend.name |
a character string indicating the title of the legend. |
colour |
a character string containing the colour of the data points. |
show.points |
logical to determine whether or not to include points. |
save |
logical as to whether or not to save the plot. |
path |
string containing path of where to save plot. Defaults to working directory. |
A ggplot
1 2 3 |
Call:
lm(formula = scale(data[, outcome]) ~ scale(data[, moderator]) *
scale(data[, predictor]))
Residuals:
Min 1Q Median 3Q Max
-0.67711 -0.26637 -0.04891 0.17498 0.96203
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.50879 0.17692 -2.876 0.007619 **
scale(cyl) 0.07485 0.25034 0.299 0.767156
scale(disp) -0.97535 0.25180 -3.873 0.000589 ***
scale(cyl)*scale(disp) 0.58225 0.18171 3.204 0.003369 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.4413 on 28 degrees of freedom
Multiple R-squared: 0.8241, Adjusted R-squared: 0.8052
F-statistic: 43.72 on 3 and 28 DF, p-value: 1.078e-10
Call:
lm(formula = scale(data[, outcome]) ~ scale(data[, moderator[1]]) *
scale(data[, moderator[2]]) * scale(data[, predictor]))
Residuals:
Min 1Q Median 3Q Max
-0.54507 -0.27873 -0.03879 0.22627 0.81471
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.5244 0.1858 -2.822 0.00944 **
scale(cyl) 0.1553 0.2780 0.559 0.58159
scale(am) -0.5448 0.1999 -2.725 0.01180 *
scale(disp) -0.8752 0.3198 -2.737 0.01149 *
scale(cyl)*scale(am) 0.7635 0.3073 2.485 0.02033 *
scale(cyl)*scale(disp) 0.3522 0.2175 1.619 0.11854
scale(am)*scale(disp) -0.9613 0.3425 -2.806 0.00978 **
scale(cyl)*scale(am)*scale(disp) 0.6823 0.2147 3.178 0.00405 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.3903 on 24 degrees of freedom
Multiple R-squared: 0.882, Adjusted R-squared: 0.8476
F-statistic: 25.64 on 7 and 24 DF, p-value: 1.144e-09
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.