← Back to the toolbox

Three examples with low-dimensional X

Each CSV has directly observed baseline covariates X. The mediator columns distinguish the observed-variable and noisy-measurement paths. These are fixed synthetic draws for demonstrating the workflow.

Low-dimensional

n=100, X=2, M=2. Answer Observed covariates and mediators. The automatic method is Multiply robust, using the Díaz adapter with Z=NULL.

Download CSV · Seed: 2026091920.

X ~ N(0, I_2) P(A=1 | X) = expit(.3 X1) M1(a) = .3 X1 + .5 a + e1 M2(a) = -.2 X2 + .3 a + e2 Y(a,m) = .5 a + .3 X1 - .2 X2 + .6 m1 + .25 m2 + eY

All errors are independent standard normal. X and M are directly observed; there is no latent measurement layer. The sample-size preset uses 2 cross-fitting folds, which can be adjusted in Settings.

NIE = .6*.5 + .25*.3 = .375 NDE = .5 TE = .875

Sparsity · low-dimensional X

n=300, X=20, M=500. Answer Observed covariates and mediators. The automatic method is Sparsity. X remains unpenalized; L1 regularization applies to M only.

Download CSV · Seed: 20260917.

Z_j ~ Uniform(-sqrt(3), sqrt(3)); Z3 = 2 C - 1, C ~ Bernoulli(.5) X1 = 50 + 10 Z1; X3 = C; other X_j = Z_j P(A=1 | X) = expit(-.1 + .35 Z1 + .25 Z2 + .2 Z3) M1(a) = .3 Z1 + .6 a + e1 M2(a) = -.25 Z2 + .4 a + e2 M3(a) = .2 Z3 - .3 a + e3 M_j(a) = .2 Z_j + e_j, j=4,...,8 M_j(a) = e_j, j=9,...,500 Y(a,m) = 1 + .4 a + .35 Z1 - .25 Z2 + .2 Z3 + .5 m1 + .4 m2 - .2 m3 + eY

All errors are independent standard normal. The CSV retains readable covariate names; Z is just a known recoding of observed X, not a latent factor or an intermediate confounder. Only three mediator pathways contribute to the outcome. This is a simpler sparse DGP without interactions, separate from the original paper-inspired high-X example.

NIE = .5*.6 + .4*.4 + (-.2)*(-.3) = .52 NDE = .4 TE = .92

Preset K₁=K₂=2.75. Enabling sensitivity automatically checks the data and fills a feasible K grid. The range remains editable.

Factor · low-dimensional X

n=240, X=3, M=300. Answer Noisy measurements, then choose Linear factor or MediEncoder. Both keep X directly observed and apply a factor representation to M only.

Download CSV · Seed: 2026091910.

X ~ N(0, I_3) P(A=1 | X) = expit(.3 X1) b(X) = (.4 X1 + .2 X2, -.3 X2 + .15 X3) F_M(a) = b(X) + (.7, .35) a + eM M = F_M(A) L_M' + .35 E_M Y(a,f) = 1 + .5 a + .4 X1 - .2 X2 + (.6 + .2 a) f1 + .25 f2 + eY

The latent mediator has dimension 2. Factor errors, loadings, measurement errors and outcome errors are independent standard-normal draws. X is observed directly, with no measurement error or factor extraction applied to it.

NIE = .8*.7 + .25*.35 = .6475 Population NDE = .5; conditional NDE = .5 + .2 mean(b1(X)) Population TE = 1.1475

Choose Cumulative explained variance (50% by default; 10% to 95% in 5% steps, plus 99%) or Eigenvalue ratio to calculate the M dimension from the CSV. The true simulation dimension is not supplied as a preset. The sensitivity grid compares M dimensions 1 and 2 and can be edited. There is no X dimension grid because X remains observed.

Known effects for the saved draws

NIE is the total natural indirect effect E[Y(1,M(1))−Y(1,M(0))]; NDE is the pure natural direct effect E[Y(1,M(0))−Y(0,M(0))]. For the factor example, M in this definition denotes the latent mediator F_M.

ExampleTargetNIENDETE
Loading known effects…

Bootstrap and reproducibility

Each example initializes a target of 20 successful bootstrap refits. Increase it for final uncertainty analysis. Parameter sensitivity is available for Sparsity and the two factor methods; the low-dimensional multiply robust route has no corresponding K or factor-dimension grid.

Save the three Python files below together, then run python generate_routing_examples.py alongside the existing manifest.json. NumPy is required. The generator preserves the original public Sparsity and Factor records and adds these three cases.

Routing example generatorSparse generator helperManifest helperMetadata and checksums

These examples check computation and automatic routing. A single dataset and a small bootstrap run do not establish bias or interval coverage.