# Mediator or Moderator?

Hello I have a question to decide whether a variable, M, is mediator or moderator. This is the link for the diagram for X, Y and M: Introduction to Mediation Analysis | UVA Library

This is my mediation analysis:

# Mediation Analysis

``````# Download data online. This is a simulated dataset for this post.
``````

## Step 1

``````model.0 <- lm(Y ~ X, myData)
summary(model.0)
``````
``````Call:
lm(formula = Y ~ X, data = myData)

Residuals:
Min      1Q  Median      3Q     Max
-5.0262 -1.2340 -0.3282  1.5583  5.1622

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)   2.8572     0.6932   4.122 7.88e-05 ***
X             0.3961     0.1112   3.564 0.000567 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.929 on 98 degrees of freedom
Multiple R-squared:  0.1147,	Adjusted R-squared:  0.1057
F-statistic:  12.7 on 1 and 98 DF,  p-value: 0.0005671
``````

## Step 2

``````model.M <- lm(M ~ X, myData)
summary(model.M)
``````
``````Call:
lm(formula = M ~ X, data = myData)

Residuals:
Min      1Q  Median      3Q     Max
-4.3046 -0.8656  0.1344  1.1344  4.6954

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)  1.49952    0.58920   2.545   0.0125 *
X            0.56102    0.09448   5.938 4.39e-08 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.639 on 98 degrees of freedom
Multiple R-squared:  0.2646,	Adjusted R-squared:  0.2571
F-statistic: 35.26 on 1 and 98 DF,  p-value: 4.391e-08

``````

## Step 3

``````model.Y <- lm(Y ~ X + M, myData)
summary(model.Y)
``````
``````Call:
lm(formula = Y ~ X + M, data = myData)

Residuals:
Min      1Q  Median      3Q     Max
-3.7631 -1.2393  0.0308  1.0832  4.0055

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)   1.9043     0.6055   3.145   0.0022 **
X             0.0396     0.1096   0.361   0.7187
M             0.6355     0.1005   6.321 7.92e-09 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.631 on 97 degrees of freedom
Multiple R-squared:  0.373,	Adjusted R-squared:  0.3601
F-statistic: 28.85 on 2 and 97 DF,  p-value: 1.471e-10
``````
``````library(mediation)
results <- mediate(model.M, model.Y, treat='X', mediator='M',
boot=TRUE, sims=500)
summary(results)
``````
``````Causal Mediation Analysis

Nonparametric Bootstrap Confidence Intervals with the Percentile Method

Estimate 95% CI Lower 95% CI Upper p-value
ACME             0.3565       0.2235         0.52  <2e-16 ***
Total Effect     0.3961       0.1122         0.63   0.004 **
Prop. Mediated   0.9000       0.5081         2.36   0.004 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Sample Size Used: 100

Simulations: 500
``````

This is my moderation analysis:

``````model_interaction <- lm(Y ~ X + M +X*M, data = myData)
summary(model_interaction)
``````
``````Call:
lm(formula = Y ~ X + M + X * M, data = myData)

Residuals:
Min      1Q  Median      3Q     Max
-3.8887 -1.1147  0.0062  1.1226  3.9758

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)  0.84237    1.56674   0.538  0.59206
X            0.22189    0.27122   0.818  0.41531
M            0.86381    0.32651   2.646  0.00953 **
X:M         -0.03700    0.05033  -0.735  0.46403
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.635 on 96 degrees of freedom
Multiple R-squared:  0.3765,	Adjusted R-squared:  0.357
F-statistic: 19.32 on 3 and 96 DF,  p-value: 6.972e-10
``````

So if the interaction term is insignificant and the mediation effect is statistically significant, we can say that M is a mediator? Or do you have other suggestions for it? I want to know the only way to test whether a variable is a moderator is to use an interaction term or not?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.