I am struggling to understand how/if the interaction is connected to mediation. I understand that the interaction in a regression indicates that a variable Z influences the effect of a variable X on the outcome (Y). I am also aware that the variable X can influence Y through another variable, a mediator, in this case, we call it M. This mediation can be either complete or partial, meaning that X can influence Y directly and through M.
However, what I do not quite understand is how these two aspects are related. I guess I am wrong in assuming that if X interacts with Z, I can decompose the influence of Z on the effect of X on Y using mediation analysis.
What I would like to do is to identify all the variables (Y and Z) that have a combined effect on Y. I then want to decompose the effect of X and Z on Y in:
- interaction (X*Z->Y)
- direct effect (X->Y)
- mediated effect (X->Z(M)->Y)
Are these simply different problems that require independent regression and mediation analyses, or there is a way to explore the above simultaneously? Is there an R package that does that? Thank you very much!