I try to understand interactions in multiple linear regression and especially how to plot them and there is one uncertainty that emerged I hope somebody can rule out for me. So if you have done the MLR and the interaction term is significant and you now want to do the post hoc test. We have to do this in a homework.
Most resources that cover this topic explain it in a model with only 4 coefficients:
$\hat{Y} = A + B_1X_1 + B_2X_2 + B_3X_1X_2$
Or written in another way:
$\hat{Y} = (B_1 + B_3X_2)X_1 + (A + B_2X_2)$
Then I can calculate the simple slopes for different values of $X_2$, for example if $X_2$ is the variable gender (male = 0 and female =1), then I get 2 the 2 lines:
$Z_{males} = B_1 + X_1 + A$
$Z_{females} = (B_1 + B_3)X_1 + (A + B_2)$
If I understood the material, then I could plugin 2 values for $X_1$, e.g. the min and max values and then plot the lines.
$ $
But what if I have 5 coefficients so that we have a regression equation like this: $\hat{Y} = A + B_1X_1 + B_2X_2 + B_3X_1X_2 + B_4X_3 $
Or written in another way:
$\hat{Y} = (B_1 + B_3X_2)X_1 + (A + B_2X_2 + B_4X_3)$
When I then want to make the 2 lines for males and females, I thought that I then just have to ignore the term $B_4X_3$. Is that correct? And if I do not ignore this term, which values will I have to plugin for $X_3$ to plot the 2 lines to make the interaction plot?
By the way, if there is an easy way to plot this with ggplot2, please let me know. My plan was to make use geom_abline()
to make each line manually.