Skip to content
StatsOtter A workspace for causal thinking
Method library WORKFLOW / 031
Research workflow/4 steps

Causal mediation: natural direct & indirect effects (CMAverse)

Source CMAverse — Shi, Valeri et al.
01
The method workspace

Follow the analysis.

Select a node to explore the method

Method mapInput → 4 steps → output
START WITHInput data
ARRIVE ATResults
Read step 01
Inside the methodReasoning, equations & implementation
Step 1 of 4
01
Data prep

Treatment, mediator, outcome, confounders

Data preparation — shapes the raw inputs into what the estimator expects.

What happens here

Lay out the mediation DAG and the confounders of the A→M, A→Y and M→Y links.

Formula
\mathrm{TE}=\underbrace{\mathrm{NDE}}_{\text{not through }M}+\underbrace{\mathrm{NIE}}_{\text{through }M}
Reads fromNot specified Feeds intoNot specified
Key code
library(CMAverse)
# a (treatment), m (mediator), y (outcome), C (confounders)

Reference / docs ↗

Discussion on this step (0)
StatsOtterDiscussion starter · Editorial note

Before using this step, make its assumptions and its output explicit. A useful peer note explains what you would check, what could go wrong, or what would change your interpretation.

Questions to explore
  1. Which assumption matters most here, and what evidence could challenge it?
  2. What would you check before passing this output to the next step?

Peer discussion

  • Bring your experience, a question, or a different perspective.
02
Data contract

Inputs & data

A treatment, a mediator on the causal path, an outcome, and the confounders of each link.

Show data format & exampleHide example

Format — one row per unit: treatment a, mediator m, outcome y, confounders C.

  a    m     y    c1   c2
  1   0.6   3.2  0.4  -1.1
  0   0.2   1.8 -0.1   0.6
03
Read the evidence

Results & interpretation

2 figures Workflow discussion 0
01FigureThe causal diagram: treatment → mediator → outcome, with confounders of each link.
02FigureDecomposition of the total effect into direct and mediated (indirect) components.

Figures reproduced from CMAverse — Shi, Valeri et al. — unofficial community showcase; all credit to the original authors.

Context & interpretation

⚠️ Unofficial community showcase of cmaverse. Not affiliated with the authors; all credit to them.

Split a total effect into what flows through a mediator (indirect) and what doesn't (direct) — with a sensitivity analysis for mediator–outcome confounding.

Peer notes

Discuss the workflow (0)

  • No comments yet — start the conversation.
IN THE MARGINS

Peer discussion