# Moderation and Mediation

Moderation and mediation are terms for measuring conditional effects. They are frequently discussed in the context of SEMs. However, both can be estimated in standard regression settings.

(For mediation, while you can estimate via regression, I do not recommend it. See note below.)

## Moderation

Let$$X$$ be a predictor, $$Y$$ be a response and we are studying whether $$M$$ moderates the relationship between$$X$$ and $$Y$$. In other words, we want to know whether $$M$$ modifies the strength (or direction) of the relationship between $$X$$ and $$Y$$ . For example, we could study the relationship between socio-economic status ($$X$$ and frequency of breast exams ($$Y$$ ). Among younger women, breast exams are rare because current recommendations are for women age 40 and over to get exams. However, in older women, there is a relationship because those with higher SES tend to be more concerned with health. Age ($$M$$) moderates the relationship between SES and frequency of breast exams.

### In Regression

Moderation is represented in a regression model with nothing more than an interaction term. There is a causal aspect to it, in that there needs to be the assumption that the predictor ($$X$$) has a causal relationship on the response ($$Y$$). If $$X$$ is randomized, this assumption is satisfied. If the $$X$$ is not randomized, this assumption must be based on theory and domain specific knowledge.

Fit the interaction model,

$Y = \beta_0 + \beta_1X + \beta_2Z + \beta_3XZ + \epsilon.$

Therefore, $$\beta_3$$ measures the moderation effect.

## Mediation

Again, let $$X$$ be a predictor and $$Y$$ be a response. We are studying whether $$M$$ mediates the relationship between$$X$$ and $$Y$$. Mediating variables are more complicated that moderators. A variable ($$M$$) is said to be a mediator if it partially or fully explains the relationship between the predictor ($$X$$) and the response ($$Y$$). The easiest way to explain this is visually.

The unmediated and mediated model follow.

In the first model, the unmediated model, the total relationship between $$X$$ and $$Y$$ is captured by $$a$$. This model allows no mediation.

In the second model, the total effect is split into a direct effect and an indirect effect. $$d$$ is the direct effect and $$bc$$ (the product of $$b$$ and $$c$$) is the indirect effect from $$X$$ to $$Y$$ mediated through $$M$$.

Depending on the significance (both statistical and practical) of $$d$$ and $$bc$$, we would have:

• If $$d$$ is non-zero but $$bc$$ is zero, then we have no evidence of mediation.
• If both $$d$$ and $$bc$$ are non-zero then we have evidence of partial mediation. (There is evidence of both a direct effect and an indirect effect.)
• If $$d$$ is zero, but $$bc$$ is non-zero, then we have evidence of total mediation. (The only evidence of a relationship between $$X$$ and $$Y$$ is through the mediation of $$M$$.)
• Finally, if both $$d$$ and $$bc$$ are zero, there's no evidence of a relationship.

We call $$d + bc$$ the total effect between $$X$$ and $$Y$$. In least squares regression (linear regression), we have that $$a = d + bc$$. In all other models, that relationship may not hold.

### In Regression

While we can fit mediation via regression (called the Baron-Kenny approach), it is not recommended. Thinking of mediation as a series of linear regressions is great for conceptualizing mediation, but not for estimation. Use either the lavaan or mediation packages in R or use causal mediation in Stata.

We can conceptalize the above model as three regression models, testing all paths above.

1. Test $$a$$ to establish a relationship between predictor ($$X$$) and response ($$Y$$):
$Y = \beta_0^{(1)} + cX + \epsilon_1$
1. Test $$b$$ to establish correlation between predictor ($$X$$) and moderator ($$M$$):
$Z = \beta_0^{(2)} + aX + \epsilon_2$
1. Test $$c$$ to establish that the mediator ($$M$$) affects the response ($$Y$$). Include both mediator ($$M$$) and predictor ($$X$$) to establish that the relationship exists when controlling for $$X$$.
$Y = \beta_0^{(3)} + dX + bM + \epsilon_3$