How to Plot Moderation in R

Suppose one got this equation:
\[ \text{Violence} = 2.321 - 0.55 \times \text{Male Honor} - 0.475 \times \text {Moral Absolutism} + 0.080 \times \text{Male Honor} \times \text{Moral Absolutism}. \]
I honestly do not know SPSS well enough to know if there is an easy way to get the continuout interaction plots. It seems to me like the most straightforward way would be to make a data window and use transform to get the same thing as I get below.

In R, this “problem” is next to trivial I start by making a function that matches the equation above.

violence <- function(mh, ma) {
    return(2.321 - 0.55 * mh - 0.475 * ma + 0.08 * mh * ma)
}

It is also good to know \( \overline{X} \) and \( S \) for each of the two IVs so that reasonable ranges are plotted. Min and max could be used, too.

xbar.mh <- 3.83
s.mh <- 1.37
xbar.ma <- 2.56
s.ma <- 0.88

You have two chioces. You can vary Male Honor and pick constant values for Moral Absolutism (here, I use \( \overline{X} \) and \( \overline{X}\pm S \)), or you can vary Moral Absolutism and pick constant values for Male Honor. Which way is best depends on the theory and the data. Here Male Honor is varied.

curve(violence(x, xbar.ma), xlim = xbar.mh + c(-2, 2) * s.mh, ylim = c(-2, 2), 
    xlab = "Male Honor", ylab = "Violence")
curve(violence(x, xbar.ma + s.ma), add = TRUE)
curve(violence(x, xbar.ma - s.ma), add = TRUE)

plot of chunk unnamed-chunk-3

For the following figure Moral Absolutism is varied.

curve(violence(xbar.mh, x), xlim = xbar.ma + c(-2, 2) * s.ma, ylim = c(-2, 2), 
    xlab = "Moral Absolutism", ylab = "Violence")
curve(violence(xbar.mh + s.mh, x), add = TRUE)
curve(violence(xbar.mh - s.mh, x), add = TRUE)

plot of chunk unnamed-chunk-4