Mediation analysis tests a hypothetical causal chain where one variable X affects a second variable M and, in turn, that variable affects a third variable Y. Mediators describe the how or why of a relationship between two other variables. Mediators describe the process through which an effect occurs. This is also sometimes called an indirect effect. We therefore have the following properties:
Total effect of X on Y: c = c’ + ab
Indirect effect of X on Y: ab
Direct effect of X on Y after controlling for M: c’ = c - ab
Perfect mediation occurs when the effect of X on Y decreases to 0 with M in the model.
Partial mediation occurs when the effect of X on Y decreases by a nontrivial amount (the actual amount is up for debate) with M in the model.
8.2 Investigation of the direct and indirect effects
Mediation was previously considered statistically significant if a and b were significant and c’ was less than c. One calculated c-c’ (difference method) and regarded a mediation as statistically significant if c was significant and c’ was not. The mediation was thus validated by a logical conclusion without considering a*b (the indirect effect) specifically.
However, this approach might not be suitable for the following cases:
c just significant, c’ just no longer significant: Would be explained as statistically significant mediation using the difference method, but mediation explains too little.
c significant, c’ still significant: Would be explained as insignificant mediation using the difference method, but mediation explains enough, but not all mediation processes were found (therefore c’ still becomes significant).
c is not significant: Would be explained as insignificant mediation using the difference method, but mediation effect is possible if indirect and direct effects are in opposite directions.
8.3 Significance
In order to be able to speak of mediation, the following must be statistically reliable: ab not equal 0 (i.e. a not equal to 0 and b not equal to 0!).
To determine the significance of the indirect effect, the indirect effect is backed up statistically using the so-called Sobel test. Due to unrealistic requirements, however, it is no longer recommended.
Instead, a bootstrap method (also “resampling method”) is preferred. Empirical sample is considered as a pseudo-population, and a large number of random samples (each with replacement) are drawn from this pseudo-population (1000 or more). The indirect effect is calculated in each case. The result is a distribution of the indirect effects (which are normally distributed!)
8.4 Two approaches
We will cover two ways to conduct mediation analysis:
estimate the relationship between X on Y (c must be significantly different from 0)
estimate the relationship between X on M (a must be significantly different from 0)
estimate the relationship between M on Y controlling for X (b must be significantly different from 0)
estimate the relationship between Y on X controlling for M (should be non-significant and nearly 0)
8.4.2 Method with the R mediation package
This package uses the more recent bootstrapping method of Preacher & Hayes (2004) to address the power limitations of the Sobel test. This method computes the point estimate of the indirect effect (ab) over a large number of random sample (typically 1000) so it does not assume that the data are normally distributed and is especially more suitable for small sample sizes than the Barron & Kenny method.
This method includes 2-steps:
estimate the relationship between X on M
estimate the relationship between X on Y controlling for M
The mediate function gives us our Average Causal Mediation Effects (ACME), our Average Direct Effects (ADE), our combined indirect and direct effects (Total Effect), and the ratio of these estimates (Prop. Mediated). The ACME here is the indirect effect of M (total effect - direct effect) and thus this value tells us if our mediation effect is significant.
8.5 Inconsistent mediation
In general, complete mediation implies that these step 1-2-3-4 (in the 4-steps from Baron & Kenny) be met. However, in practice, some researchers also consider that the essential steps in establishing mediation are steps 2 (X on M) and 3 (Z on Y, controlling for X).
Furthermore, if c′ (direct effect of X on Y after controlling for M) had the opposite sign to that of ab (indirect effect of X on Y), then there would still be mediation (even if step 1 could not be met). In this case the mediator acts like a suppressor variable (see MacKinnon, Fairchild & Fritz, 2007).
For instance, we could have the following model: participation in strikes (or social demonstrations) and satisfaction with government mediated by media consumption. Presumably, we have the following relations:
the direct effect is negative, with more participation in (anti-government) demonstration(s) suggesting less satisfaction with government
however, likely the effect of participation in demonstration(s) on consuming media is positive
furthermore, the effect of media consumption on satisfaction with government is likely to be positive
Thus, we obtain a positive indirect effect, and the total effect of participation in demonstration(s) on satisfaction with government is likely to be very small because the direct and indirect effects will tend to cancel each other out.
8.6 Sobel test
Given the above example, it is recommended to perform a single test of ab (rather than two separated tests of a and b). The test was first proposed by Sobel (1982). The Sobel test uses the following standard error estimate of ab:
\[ \sqrt{b^2*s^2_{a} + a^2*s^2_{b}} \]
The test of the indirect effect is given by dividing ab by the above standard error estimate and treating the ratio as a Z test:
\[ z = \frac{ab}{\sqrt{b^2*s^2_{a} + a^2*s^2_{b}}} \].
If a z-score is larger than 1.96 in absolute value, the mediation effect is significant at the .05 level.
8.7 Bootstraping
The Sobel test is easy to conduct but presumes that a and b are independent (which may not always be true). Furthermore, it assumes that ab is normally distributed (which might not work well for small sample sizes).
One solution is to use the bootstrap method (see Bollen & Stine, 1990). This method has no distribution assumption on the indirect effect ab, but rather approximates the distribution of ab using its bootstrap distribution.
Using the original data set (Sample size = n) as the population, the model draws a bootstrap sample of n individuals with paired (Y, X, M) scores randomly from the data set with replacement. From the bootstrap sample, estimate ab based on a set of regression models. The steps are repeated for a total of N times (N=number of bootstraps).
8.8 Total mediation versus partial mediation
One speaks of total mediation when the direct effect disappears as a result of mediation: c != 0, and thus ab = c.
One speaks of partial mediation when the direct effect does not disappear as a result of the mediation, but a residue remains: c!= 0 (i.e. if ab != c).
In the social science context, mediations are mostly partial, because one process rarely explains the full influence of X on Y.
8.9 Why consider ab instead of c-c’?
The difference method (c-c’) originally assumed that c must be significant (that is, that the X must have a total effect on the Y, which is to be explained by mediation).
However, mediation can also exist if c = 0. This is possible because there may be several significant mediator effects that cancel each other out (but not all may have been measured).
The targeted examination of ab thus provides a more precise picture of individual significant mediation processes, even if there is no total effect.
8.10 More recent methodology: lavaan
The R package that handles measurement and analysis models most easily is lavaan. For the calculation, the model formula and the data are passed to the sem() function.
The result is a complex object with many methods of its own. The most important are: summary(), fitMeasures(), parameterEstimates(), and inspect().
8.11 In a nutshell
A mediation analysis is a regression analysis in which the influence of an independent variable (X) on a dependent variable Y is fully or partially explained by a mediator (M).
The indirect effect via the mediator is formed by multiplying two effects: effect of X on M and effect of M on Y. The significance of the indirect effect is determined by bootstrapping.
Significant mediation occurs when the confidence interval for the indirect effect is not 0.
The size of the effect can be described by the unstandardized or standardized coefficients.
A mediation can exist even if there is no significant total effect.
8.12 How it works in R?
See the lecture slides on mediation analysis:
You can also download the PDF of the slides here:
8.13 Quiz
True
False
Statement
Perfect mediation occurs when the relationship between the predictor (X) and the outcome (Y) is completely wiped out when the mediator (M) is included in the model.
To measure the effect size of mediation, we rely on the ratio of the indirect to total effect.
The Sobel test works well for small sample sizes.
To test for a mediation effect, we assess the size of the indirect effect and ensure that the confidence interval does not contains 0.
My results will appear here
8.14 Example from the literature
The following article relies explains mediation (and moderation) analysis with an illustrative example:
Igartua, J. J., & Hayes, A. F. (2021). Mediation, moderation, and conditional process analysis: Concepts, computations, and some common confusions. The Spanish Journal of Psychology, 24, e49. Available here.
Please reflect on the following questions:
What is the difference between “total”, “direct” and “indirect” effects?
What happens if ab and c’ are the same size but different in sign?
What is the advantage of using the bootstrapping method instead of Baron and Kenny’s method?
8.15 Optional example from the literature
The following article relies on moderated mediation as a method of analysis:
Matthes, J. (2013). Do hostile opinion environments harm political participation? The moderating role of generalized social trust. International Journal of Public Opinion Research, 25(1), 23-42. Available here.
Please reflect on the following questions:
What is the research question of the study?
What are the research hypotheses?
Is moderated mediation an appropriate method of analysis to answer the research question?
What are the main findings of the moderated mediation analysis?
In this exercise, we will use the data “protest.sav” (Hayes, 2022) which can be downloaded or here under “data files and code”. Especially, we will focus on the following variables:
Protest (independent variable): A lawyer protests against gender discrimination (experimental group, dichotomous 0 = no and 1 = yes)
Respappr (mediator): Perceived adequacy of response (scale 1-7)
Like (dependent variable): assessment of the lawyer (scale 1-7)
Hypothesis: If the lawyer protests, her reaction will be perceived as more appropriate, and therefore the lawyer will be evaluated more favorably.
Start by drawing the regression equations.
Solution: equation
The regression equations go as:
\[ Y_i = \beta_0 + \beta_1*Protest_i + \beta_2*Respappr_i + \epsilon_i = c' + b \]\[ M_i = \beta_0 + \beta_1*Protest_i + \epsilon_i = a \]\[ Y_i = \beta_0 + \beta_1*Protest_i + \epsilon_i = c = c' + ab \]
Now, we want to calculate the mediation model and to answer the following questions:
Is the a-path significant? If so, how much variance does it explain?
Are the b-path and the c’-path significant? If so, how much variance do they explain together?
Is there a total effect of X on Y?
Is there a significant mediation effect? If so, is there partial or total mediation?
Start by loading and selecting the data:
Show the code
# load the datalibrary(foreign)db <-read.spss(file=paste0(getwd(),"/data/protest.sav"),use.value.labels = F, to.data.frame = T)# get the datasel <- db |> dplyr::select(protest, respappr, liking) |> stats::na.omit()
Now, define the model in laavan and give the results for the c path:
Show the code
# define the modelmodell.c ="liking ~ protest"# get the complete outputfit.c = lavaan::sem(modell.c, data=sel)lavaan::parameterestimates(fit.c, standardized=T)[1:8]## lhs op rhs est se z pvalue ci.lower## 1 liking ~ protest 0.479 0.193 2.478 0.013 0.100## 2 liking ~~ liking 1.044 0.130 8.031 0.000 0.789## 3 protest ~~ protest 0.217 0.000 NA NA 0.217lavaan::inspect(fit.c,"r2")## liking ## 0.045
Solution: Interpretation
The C path is significant and explains 4.5% of the variance of liking. Linear regression makes sense for this data.
Now get the model for the c’ path. The output is a little better understandable if you take the indirect and the overall effect on Y with the names of the paths:
Show the code
# define the modelmodell.mediation ="## direct effectliking ~ cp*protest## mediation pathrespappr ~ a*protestliking ~ b*respappr## indirect effect (a*b)ab := a*b## total effect (c+a*b)total := cp+a*b"# get the complete outputfit.med = lavaan::sem(modell.mediation, data=sel)lavaan::parameterestimates(fit.med, standardized=T)[1:8]## lhs op rhs label est se z pvalue## 1 liking ~ protest cp -0.101 0.198 -0.508 0.611## 2 respappr ~ protest a 1.440 0.220 6.544 0.000## 3 liking ~ respappr b 0.402 0.069 5.857 0.000## 4 liking ~~ liking 0.824 0.103 8.031 0.000## 5 respappr ~~ respappr 1.354 0.169 8.031 0.000## 6 protest ~~ protest 0.217 0.000 NA NA## 7 ab := a*b ab 0.579 0.133 4.364 0.000## 8 total := cp+a*b total 0.479 0.193 2.478 0.013lavaan::inspect(fit.med,"r2")## liking respappr ## 0.246 0.249lavaan::fitMeasures(fit.med)[c("chisq","df","aic","cfi","rmsea")]## chisq df aic cfi rmsea ## 0.000 0.000 756.355 1.000 0.000
Solution: Interpretation
The c’ path is not significant, but both a and b are significant and the variance explained by liking is significantly higher (24.6%) than in the last model.
Give the full interpretation of the model:
Solution: Interpretation
The indirect effect (ab) of X via the mediator on Y is significant and positively directed.
If the lawyer protests, her reaction will be perceived as more appropriate than if she does not protest. An appropriate perception of the reaction then leads to a better assessment of the lawyer.
The direct effect (cp), however, is not significant. Since the indirect effect is significant at the same time, there is complete mediation.
The connection between the lawyer’s protesting and the lawyer’s evaluation is fully mediated by the lawyer’s reaction being perceived as more appropriate when she protests.
In this exercise, we will use the data “protest.sav” (Hayes, 2022) which can be downloaded here under “data files and code”. Especially, we will focus on the following variables:
Protest (independent variable): A lawyer protests against gender discrimination (experimental group, dichotomous 0 = no and 1 = yes)
Respappr (mediator): Perceived adequacy of response (scale 1-7)
Like (dependent variable): assessment of the lawyer (scale 1-7)
Sexism (moderator): perception of sexism as a ubiquitous problem in society (scale 1-7)
We want to test the assumption that if the lawyer protests, her response will be judged more appropriate by women who perceive sexism as a problem (moderator: dichotomous variable “sexism”), and therefore the lawyer will be judged better.
We want to test the following hypothesis: If the lawyer protests against gender discrimination, her response is perceived as more appropriate and therefore the lawyer is judged better.
Start by drawing the regression equations.
Solution: equation
The regression equations go as:
\[ Y_i = \beta_0 + \beta_1*Protest_i + \beta_2*Respappr_i + \epsilon_i = c' + b \]\[ M_i = \beta_0 + \beta_1*Protest_i + \beta_2*Sexism_i + \beta_3*(Protest_i*Sexism_i) + \epsilon_i = a \]\[ Y_i = \beta_0 + \beta_1*Protest_i + \epsilon_i = c = c' + ab \]
Now, we want to calculate the mediation model and to answer to following questions:
Is the a-path moderated? How much mediator variance does regression explain for the overall a-path and how much of that is explained by moderation? Illustrate the moderation of the a-path. What do the results mean in terms of content?
Are the b-path and the c’-path significant? If so, how much variance do they explain together?
Start by loading and selecting the data, and also construct the interaction variable:
Show the code
# load the datalibrary(foreign)db <-read.spss(file=paste0(getwd(),"/data/protest.sav"),use.value.labels = F, to.data.frame = T)# get the datasel <- db |> dplyr::select(protest, respappr, liking, sexism) |> stats::na.omit()# construct the interaction variablesel$protest.sexism = sel$protest*sel$sexism
The overall model for the mediator (respappr) significantly explains 29.6% of the mediator’s variance.
There is a significant conditional effect of the independent variable on the mediator when the moderator has a value of 0 (= with a moderate level of sexism, the lawyer’s protest leads to her reaction being perceived as more appropriate).
The a-path from the independent variable to the mediator is significantly moderated by the sexism attitude. This moderation alone explains 4.8% (0.296-0.246=0.05) of the variance of the mediator.
The extent to which protesting influences the perceived appropriateness of the reaction thus varies depending on the subjects’ sexism attitude.
However, the strong correlations between the independent variables are a problem for the model! The standardized coefficients are outside the natural limits of -1 to +1. The model represents the data poorly. Moderation is better studied independently of mediation.
Finally, we want to know whether there is a significant moderated mediation effect? If so, how can this be described and interpreted in terms of content?
Solution: Interpretation
Interaction is significant: The moderator has an influence on the a-path.
Path ab is not significant: There is not an indirect effect for all values of the moderator.
The data are not suitable for this evaluation and the estimators cannot be fully trusted.