Causal mediation and moderation analysis
Decomposing causal mechanisms to understand not only whether a factor influences an outcome, but how and under what conditions it does so
What it is
Statistical analysis that decomposes the relationship between an exposure and an outcome to identify intermediate mechanisms (mediation) and the conditions that modify that relationship (moderation).
It quantifies direct and indirect effects, estimates the proportion of the total effect that operates through a mediator, and assesses whether the effect varies across subgroups or clinical contexts.
Objectives
- Quantify what proportion of the effect of an exposure on an outcome operates through a specific intermediate mechanism.
- Assess whether the size of the effect depends on a third factor (moderator), identifying subpopulations where the relationship is stronger or weaker.
- Generate evidence on causal mechanisms to inform clinical decisions, health policy decisions or intervention design.
Causal mediation analysis
- Estimation of the ACME (average causal mediation effect) and ADE (average direct effect) with bootstrap confidence intervals.
- Models for continuous and binary outcomes (GLM, logistic regression) within the Imai, Keele and Tingley framework.
- Assessment of the proportion mediated and sensitivity analysis for violation of the sequential ignorability assumption.
Moderation and interaction analysis
- Models with interaction terms to assess whether the effect of an exposure depends on the level of a third variable.
- Visualisation of conditional effects with interaction plots (simple slopes, Johnson-Neyman).
- Distinguishing statistical moderation from biological interaction, with interpretation in context.
Combined models and extensions
- Moderated mediation and mediated moderation analysis when the design justifies it.
- Mediation with multiple simultaneous or sequential mediators.
- Extensions for longitudinal data and sensitivity analysis for unmeasured confounding.
Design and validation of causal hypotheses
- Building DAGs (directed acyclic graphs) to formalise the causal hypothesis before the analysis.
- Checking identification assumptions and discussing the limitations inherent in observational designs.
- Writing the methods section in line with reporting guidelines (STROBE, RECORD).
What it is for
- Determine whether the effect of a clinical exposure operates through a specific biological mechanism, quantifying the proportion of the effect that is indirect.
- Identify subpopulations in which an intervention has a differential effect, informing personalisation and prioritisation strategies.
- Answer reviewers and committees who demand evidence on mechanisms, not just on associations.
Knowing that A affects B is not enough. You need to know by what pathway, and in which patients
In clinical and epidemiological research, demonstrating an association between exposure and outcome is only the first step. Reviewers, evaluation committees and health policy makers want to know through what mechanism that association operates, and whether the effect is the same for everyone or depends on the context. A poorly framed mediation and moderation analysis, or worse, a missing one, leaves your manuscript exposed and your intervention without grounds to scale up.
Rigorous quantification of direct and indirect effects
We estimate the ACME and ADE with bootstrap and with models suited to your type of outcome (continuous or binary), not with the Baron and Kenny method, which the literature moved beyond two decades ago. Simulation-based confidence intervals, not normal approximations.
The causal hypothesis formalised before the analysis
We build the DAG with you before estimating anything. If the causal structure does not justify a mediation analysis (because there is mediator–outcome confounding, or the mediator is post-treatment in an unsuitable design), we tell you before running a model that cannot answer your question.
Sensitivity analyses that anticipate objections
The sequential ignorability assumption cannot be verified empirically. We provide formal sensitivity analyses that quantify how much unmeasured confounding would be needed to invalidate your conclusions, giving you solid arguments for sceptical reviewers.
Clinical interpretation, not just statistical
A significant ACME is of no use if it does not translate into an implication for clinical practice or intervention design. We place each result in the context of your research question and help you write the discussion with rigour.
What working with us looks like
We apply our D²I (Data to Insights) methodology to every service. A structured, iterative and transparent process that turns complex data into actionable knowledge.
01
Kick-off and problem definition
We meet with you to understand the clinical problem, the data available and the objectives of the project. We agree on deliverables, timelines and communication channels, and we sign whatever confidentiality agreements you need to protect your data.
02
Data review and preparation
We assess the quality of your data, identify inconsistencies and limitations, and structure the data for analysis. If critical information is missing, we tell you before going any further. We document every cleaning decision so that the process is traceable and reproducible. In mediation and moderation analysis, this includes checking the temporal order of exposure, mediator and outcome, assessing whether the coding of the variables allows the proposed causal model to be specified, and detecting any mediator–outcome confounding that would invalidate the analysis before it is run.
03
Analysis and modelling
We apply the statistical methodology that fits your questions. We work iteratively: we share preliminary results with you, discuss the findings and adjust the approach where needed. We do not work in the dark until the final delivery. For this service, we build the causal DAG, specify the mediator and outcome models separately, run the analysis with bootstrap for robust inference and provide sensitivity analyses for violations of the assumptions. If the design justifies it, we also assess moderation and interaction, with visualisation of conditional effects.
04
Communicating results
We turn the findings into the format you need: a technical report, tables and figures for publication, an interactive dashboard or an executive presentation. We always include the clinical interpretation, not just the figures.
05
Impact review session
30 days after delivery we meet with you again for a 60-minute strategy session. By then you have had time to present the results internally, the real implementation questions have come up and you can assess the impact of the work with some perspective. We answer your questions, adjust interpretations where necessary and agree together on the way forward.
This is our general process. If you want to understand how we apply it technically to each type of analysis, see our full D²I methodology.
Have a data project on your hands?
Tell us about your case and we will work out together how to approach it.
Book a sessionFrequently asked questions
I have already shown that my exposure is associated with the outcome. What does a mediation or moderation analysis add?
It adds the answer to two questions the association leaves open: through what mechanism the effect might operate, if the causal hypothesis is justified (mediation), and under what conditions or in which subgroups it changes (moderation). It applies when showing an association between exposure and outcome is only the first step, and reviewers, committees or policy makers want to know the how and the for whom. Mediation decomposes the total effect into a direct part and an indirect part that passes through an intermediate mechanism, and quantifies what proportion of the effect operates through that mediator. Moderation assesses whether the size of the effect depends on a third factor, identifying subpopulations in which the relationship is stronger or weaker. Knowing that A is related to B is not enough to ground a clinical decision or the design of an intervention; understanding the mechanism and the conditions is. That is what separates a documented association from an actionable understanding of the effect.
What exactly is causal mediation, and what do I receive: direct effect, indirect effect, proportion mediated?
Causal mediation decomposes the effect of an exposure on an outcome into a direct effect and an indirect effect that operates through a mediator and, where it is interpretable, estimates what proportion of the total effect is indirect. It applies when an exposure is suspected of influencing the outcome through a specific intermediate pathway that you want to quantify. You receive the ACME (average causal mediation effect, the indirect part) and the ADE (average direct effect), with confidence intervals obtained by bootstrap rather than normal approximations, and models suited to the type of outcome, continuous or binary. The proportion mediated is also reported when it offers an interpretable reading, always with caution, because it is a quantity that is sensitive to the scale and the model. What you receive is not just a number for the indirect effect, but its quantification with uncertainty and its interpretation within the framework of the question. The decomposition of the effect is the result; the bootstrap and the right models are what make it defensible.
I've heard that the Baron and Kenny method is outdated. What do you use instead?
We use the counterfactual framework for causal mediation, specifically the Imai, Keele and Tingley approach, which estimates direct and indirect effects on an explicit causal basis, instead of the Baron and Kenny method, which has been displaced by more current causal approaches. It applies if you know the classic regression-steps procedure and want to know why it is no longer the standard. The classic approach does not handle non-continuous outcomes well, does not formalise the causal assumptions the decomposition needs, and offers no clean route to inference or to sensitivity analysis. The counterfactual framework does: it defines the effects as causal quantities, accommodates continuous and binary outcomes, and produces bootstrap confidence intervals. The difference is not one of fashion but of validity: the current framework makes explicit the assumptions under which the proportion mediated means what it is claimed to mean. Relying only on the classic procedure can be a weak point with methodologically demanding reviewers.
How do I know my mediation analysis is valid, and not a model that fails to answer my question?
Validity is decided before estimating, by formalising the causal hypothesis in a DAG and checking that the structure of the problem allows a mediation analysis. It applies to every mediation study, where a technically sound model may still fail to answer the question if the assumptions do not hold. Before estimating, we check the temporal order of exposure, mediator and outcome, and look for mediator–outcome confounding or a measurement of the mediator that does not respect that required temporal order: situations that invalidate the decomposition. If the causal structure does not justify the analysis, we say so before running the model, not after. The central assumption, sequential ignorability, cannot be verified empirically, so it comes with a sensitivity analysis that assesses how far the conclusion would depend on possible unmeasured confounding. An ACME estimated without examining these assumptions is a number that is hard to interpret causally; what makes it defensible is the explicit examination of the conditions under which it can be interpreted.
What is moderation, and how does it differ from mediation?
Moderation assesses whether the effect of an exposure on an outcome changes with the level of a third factor, whereas mediation decomposes that effect into the pathway through which it occurs. It applies when the question is not "why" the effect occurs, but "for whom" or "under what conditions" it is stronger or weaker. These are different questions that are frequently confused. A mediator lies on the causal path between exposure and outcome; a moderator modifies the size or direction of that relationship and is not interpreted as part of the main causal pathway. Moderation is analysed with interaction terms and interpreted with visualisations of conditional effects, such as simple slopes or Johnson-Neyman, distinguishing statistical interaction from biological interaction, which are not the same thing. When the design justifies it, the two are combined in moderated mediation or mediated moderation. Confusing them leads to answering a different question from the one you had, which is why we establish from the outset which one the study is asking.
Do I need a full causal design to decompose an effect into its pathways?
Causal mediation and moderation analysis is a specialised part of causal inference, focused on decomposing an effect into its pathways (direct and indirect) and on assessing how it varies across subgroups. Causal inference and observational study design is the broader framework: estimating the total or marginal effect of an intervention, exposure or policy when there is no randomisation, with DAGs, propensity scores, difference-in-differences, g-computation and sensitivity analysis. They do not answer quite the same question. General causal inference estimates whether X affects Y and by how much; mediation and moderation, assuming or estimating that effect, decompose it into its mechanism and its conditions under additional causal assumptions. If you are looking specifically for "mediation analysis", this is your service; if your causal question is broader, the starting point is causal inference. The two are handled in coordination: this service is the special case, and that one is the umbrella.
What do I need to provide for a mediation analysis, and what do you decide?
You need the dataset with the exposure, the mediator or moderator, the outcome and the relevant covariates, plus the domain knowledge that underpins the causal hypothesis. The client provides the data, the temporal order of the variables and the clinical or contextual knowledge that gives the proposed mechanism its meaning; the service formalises the hypothesis in a DAG, specifies the models, estimates the effects, assesses the assumptions and interprets the results. The DAG is built jointly, because the causal structure depends on the research team's domain knowledge, not on a statistical decision. A key check before the analysis is temporal order: the exposure must precede the mediator, and the mediator the outcome, because a temporal order incompatible with the model invalidates the decomposition. What you receive is the estimate and its methodological defence; the causal question and its authorship remain the client's.
What do you deliver from an effect decomposition, and how does it stand up to peer review?
You receive the effect decomposition, interpreted and documented: the direct and indirect effects with their bootstrap confidence intervals, the proportion mediated with its caveats, the moderation analysis where applicable with its conditional effects visualised, the DAG that formalises the hypothesis and the sensitivity analysis for unmeasured confounding. It applies if you need to respond to reviewers and committees who demand evidence on mechanisms, not just on associations. The material includes the methods section written in line with the reporting guidelines that apply to the design, such as STROBE or RECORD where relevant, and a discussion of the limitations inherent in the observational design, which is usually what a methodologically demanding reviewer scrutinises. A significant ACME does not stand on its own: it is placed in the context of what it implies for clinical practice or intervention design. The research team signs and leads the manuscript; the service provides the estimate, its interpretation and the arguments against foreseeable methodological objections.
Shall we talk?
Tell us what you are working on and we will give you a straight answer on how we can help.