Building the Mechanism

Bivalent, Exhaustive Mediators for Front-Door Identification with Bayesian SEMs

Nathaniel Forde

Data Science @ PandaDoc

and Open Source Contributor @ PyMC

2026-11-12

Preliminaries

Who am I?

Link to my website

Code or it didn’t Happen

The companion notebook, with every model and sensitivity analysis in this talk, is here. The worked example is drawn from the SEM chapter of Bayesian Causal Inference (Vincent & Forde, in preparation).

The Pitch

The front-door criterion identifies a causal effect through unmeasured confounding, with no instrument required.

So why does almost nobody use it?

  • It asks the mediator to carry everything: every directed path from \(X\) to \(Y\).
  • Any effect that leaks around the mediator breaks identification.
  • Read as a demand on a single observed node, almost no real mediator qualifies.

The argument: the mediator should be built, not found. Identification is a piece of information architecture.

Agenda

Act I: The Demand of the Front Door. Why a single mediator node almost never qualifies, and why identification is an architecture rather than a discovery

Act II: Building the Mechanism. A bivalent mediator set for job satisfaction, encoded in two matrices of a Bayesian SEM

Act III: Auditing the Architecture. Relaxing the zeros, recovering the parameters, and springing a leak

Act I: The Demand of the Front Door

The Front-Door Criterion

Pearl (1995): \(M\) identifies the effect of \(X\) on \(Y\) when

  1. \(M\) intercepts every directed path from \(X\) to \(Y\)
  2. There is no unblocked back-door path from \(X\) to \(M\)
  3. Every back-door path from \(M\) to \(Y\) is blocked by \(X\)

Then, despite the unmeasured \(U\):

\[P(y \mid do(x)) = \sum_m P(m \mid x) \sum_{x'} P(y \mid m, x') P(x')\]

Two well-identified pieces, \(X \to M\) and \(M \to Y \mid X\), are chained together.

Why It Is Rarely Used

  • A bare DAG node is a single indicator: loading fixed at 1, no measurement error.
  • Asked to exhaust a pathway in social, marketing or organisational data, it fails.
  • The pieces exist: Pearl admits a mediator set; Kuroki (2000) and Kuroki & Cai (2004) treat front-door in linear SEMs; multi-indicator latents are standard practice.

What is missing is the construction step.

Identification as Information Architecture

Every credible design decides where variation is allowed to flow. None of these plans is found in the data.

Design Unwanted variation is… The argument you owe
Propensity score weighting rebalanced: reweighting builds a pseudo-population where treatment is independent of the observed covariates every confounder is observed, and overlap holds
Double ML residualised away: flexible nuisance models partial it out of \(T\) and \(Y\) every confounder is observed
Mundlak device absorbed by group means: cluster means of the covariates soak up the correlation between group effects and treatment the unobserved confounding lives at the group level
Control-function IV modelled explicitly: the first-stage residual \(\hat v\) enters the outcome equation relevance and exclusion of the instrument
Front-door SEM quarantined: confounding may live in \(\text{Cov}(\zeta_X, \zeta_Y)\), and nowhere else the mechanism is exhaustive and unconfounded

A structural equation model is a blueprint of permitted covariances. The front-door design is one floor plan: the effect must walk through the mechanism, the confounding must stay in its room.

Act II: Building the Mechanism

The Job Satisfaction Constructs

Houghton & Jinkerson (2007): 12 indicators, 4 constructs; 263 observations simulated from their published correlations.

  • CTS, constructive thought strategies (treatment): EBA, ST, MI
  • DTS, dysfunctional thought: DA1–DA3
  • WB, well-being: UF1, UF2, FOR
  • Satisfaction (outcome): JW1–JW3

The mechanism is bivalent: CTS suppresses a negative construct and raises a positive one.

The front-door claim: these two routes exhaust CTS’s influence: a premise to argue, not a finding.

One Covariance Form, Two Matrices

Both models share the marginal covariance

\[\Sigma_y = \Lambda(I - \color{blue}{B})^{-1}\color{blue}{\Psi_\zeta}(I - \color{blue}{B})^{-\top}\Lambda^\top + \Psi\]

and the mechanism is encoded entirely in \(\color{blue}{B}\) and \(\color{blue}{\Psi_\zeta}\).

\[\color{blue}{B} = \begin{bmatrix} \overbrace{0}^{Sat} & \overbrace{\beta_{sw}}^{WB} & \overbrace{\beta_{sd}}^{DTS} & \overbrace{\color{red}{0}}^{CTS} \\ 0 & 0 & \color{red}{0} & \beta_{wc} \\ 0 & 0 & 0 & \beta_{dc} \\ 0 & 0 & 0 & 0 \end{bmatrix}\]

Direct edge CTS → Sat and the path DTS → WB are removed.

\[\color{blue}{\Psi_\zeta} = \begin{bmatrix} \psi_{s} & 0 & 0 & \color{blue}{\psi_{sc}} \\ 0 & \psi_{w} & \color{blue}{\psi_{wd}} & 0 \\ 0 & \color{blue}{\psi_{wd}} & \psi_{d} & 0 \\ \color{blue}{\psi_{sc}} & 0 & 0 & \psi_{c} \end{bmatrix}\]

Exactly two covariances stay free: treatment–outcome confounding \(\psi_{sc}\), and structure inside the mediator set \(\psi_{wd}\).

Every other zero is the formal content of “the mechanism explains everything.”

The Mechanism in Code

FRONTDOOR_PATHS = [
    ("dysfunctional", "constructive"),  # CTS -> DTS
    ("well being", "constructive"),     # CTS -> WB
    ("satisfaction", "well being"),     # WB  -> Sat
    ("satisfaction", "dysfunctional"),  # DTS -> Sat
]
FRONTDOOR_COVS = [
    ("satisfaction", "constructive"),   # confounding we survive
    ("well being", "dysfunctional"),    # inside the mechanism
]
with pm.Model(coords=coords) as frontdoor_model:
    Lambda, Psi = measurement_model(sample_df)
    Psi_zeta = make_Psi_zeta(FRONTDOOR_COVS)
    betas = pmd.Normal("mu_betas", 0, 1, dims="frontdoor_paths")
    B = set_edges(pt.zeros((4, 4)), FRONTDOOR_PATHS, betas.values)

    inv = pt.linalg.solve(pt.eye(4) - B, pt.eye(4))
    Sigma_y = Lambda @ inv @ Psi_zeta @ inv.T @ Lambda.T + Psi
    pm.MvNormal("likelihood", mu=0, cov=Sigma_y, observed=observed_data)
  • The edge list is the mechanism.
  • The permitted covariances are the walls.
  • Everything else is a zero we have to defend.
  • The total effect is read off \((I - B)^{-1}\).

The Payoff

Total effect CTS → Sat 94% HDI Posterior SD SRMR
Saturated +0.19 [−1.25, +1.62] 0.77 0.054
Front-door +0.14 [+0.01, +0.27] 0.07 0.053

The saturated model is not identified: its interval is mostly prior. The front-door model is identified, and its interval just excludes zero. Global fit is unchanged: the restrictions trade one-for-one for identification, so fit cannot test them.

What the Second Mediator Buys

  • CTS raises a positive force (well-being: +0.14 × +0.69 = +0.09) and suppresses a negative one (dysfunctional thinking: −0.16 × −0.31 = +0.05).
  • Find only well-being: the suppression route becomes a leak, and the front door misses about a third (35%) of the effect.

Two different gains from building:

  • Several indicators per construct handle measurement error.
  • Several constructs, of opposite valence, handle exhaustiveness: that is what closes the pathway.

Act III: Auditing the Architecture

Relaxing the Zeros

Muthén & Asparouhov (2012): replace each exact zero with \(\text{Normal}(0, \sigma)\) and watch the conclusion.

  • The mean barely moves (≈ 0.14–0.18): the data are nearly silent about the direct edge.
  • The interval does all the moving: at \(\sigma = 0.05\) the HDI already reaches zero; at \(\sigma = 0.5\) it is almost as wide as the saturated model’s.
  • Re-admitting DTS → WB changes nothing. One zero, CTS → Sat, carries the precision.

Simulating from the Mechanism

Can the model recover itself?

# Fix every parameter at the fitted values,
# plus a direct leak the front-door model forbids
with pm.do(generator, {**truth, "leak": [delta]}):
    y = pm.sample_prior_predictive(draws=1)[
        "prior"]["likelihood"]  # one synthetic survey, n = 263
# Condition a fresh front-door model on it
with pm.observe(build_frontdoor(observed=None),
                {"likelihood": y}):
    idata = pm.sample()

With \(\delta = 0\) the model recovers what generated the data: the total-effect HDI covers the truth in 8 / 8 replicates. But the estimates are noisy at \(n = 263\), because the CTS → mediator paths are small.

Springing a Leak

  • In a linear SEM a front door recovers only what flows through its mediators, so a leak of size \(\delta\) biases it by exactly \(-\delta\) (dotted line). The simulations track this, noisily: five replicates per \(\delta\); coverage of the true effect falls to zero by \(\delta = 0.3\).
  • The leak is absorbed as confounding: \(\rho(\zeta_{CTS}, \zeta_{Sat})\) rises from 0.10 to 0.27, and SRMR never moves.

A Design Pattern for People Analytics

Same DAG, easier premises to defend

The recipe, applied

  1. Build: after a thought-strategy course, measure the change in CTS, well-being, dysfunctional thinking and perceived support.
  2. Argue: the course reaches satisfaction only through them. Who gets sent is the confounding the design survives.
  3. Encode: the argument as zeros in \(B\) and \(\Psi_\zeta\).
  4. Audit: relax the zeros, simulate leaks, recover parameters.
  • If enrolment can be randomised, just compare the groups. The front door is for selected enrolment, the usual HR case.
  • Given the DAG, the cross-sectional SEM is already a causal argument: conditioning stands in for intervention. A dated course makes the DAG’s premises easier to defend: time order, and a named confounder.

Conclusion

Identification is Built

“SEM is an inference engine that takes in two inputs, qualitative causal assumptions and empirical data, and derives two logical consequences of these inputs: quantitative causal conclusions and statistical measures of fit for the testable implications of the assumptions… Fitting the data does not ”prove” the causal assumptions, but it makes them tentatively more plausible.”

– Bollen & Pearl, Eight Myths about Causality and Structural Equation Models

  • The front-door restrictions are not even tentatively tested by fit: they are paid for in identification, one-for-one.
  • So the warrant for the estimate lives in the construction: the choice of constructs, their measurement, and the argument that they exhaust the pathway.
  • Bayesian SEMs make that warrant auditable: soften the zeros, simulate the leaks, and report how much of the answer the architecture supplies.

“The mediator is not found.

It is built.”

Resources

Resources

  • Companion notebook: github.com/NathanielF/…/frontdoor_sem_sensitivity.ipynb
  • PyMC: pymc.io
  • Pearl (1995), “Causal Diagrams for Empirical Research,” Biometrika
  • Kuroki (2000), “Selection of Post-Treatment Variables for Estimating Total Effect,” J. Japan Stat. Soc.
  • Kuroki & Cai (2004), “Selection of Identifiability Criteria for Total Effects,” UAI
  • Muthén & Asparouhov (2012), “Bayesian SEM: A More Flexible Representation of Substantive Theory,” Psych. Methods
  • Houghton & Jinkerson (2007), “Constructive Thought Strategies and Job Satisfaction,” J. Business & Psychology
  • Bollen & Pearl (2013), “Eight Myths about Causality and SEMs”

Bayesian Causal Inference (Vincent & Forde), coming soon