Let's say I have data:
x1 <- rnorm(100,2,10) x2 <- rnorm(100,2,10) y <- x1+x2+x1*x2+rnorm(100,1,2) dat <- data.frame(y=y,x1=x1,x2=x2) res <- lm(y~x1*x2,data=dat) summary(res)
I want to plot the continuous by continuous interaction such that x1 is on the X axis and x2 is represented by 3 lines, one which represents x2 at a Z-score of 0, one at Z-score of +1, and another at a Z-score of -1, with each line a separate color and labelled. How can I do this using ggplot2?
For example, it might look something like this (though of course with different colored lines rather than different line types):