← Back to the toolbox

FACTOR · NOISY MEASUREMENTS

Factor

300 observations with 400 X measurements and 500 M measurements. Three latent covariates and two latent mediators generate the observations. This single linear DGP can be used with either Linear factor or MediEncoder.

Download dataset (CSV)Generator (Python)Generator helper (Python)Metadata and true effects (JSON)

Data-generating model

F_X ~ N(0, I_3) P(A=1 | F_X) = expit(.35 tanh(F_X1) + .25 tanh(F_X2)) b(F_X) = (.45 F_X1 + .2 F_X2, -.3 F_X2 + .15 F_X3) F_M(a) = b(F_X) + (.7, .35) a + e_M Y(a,f) = 1 + .5 a + .4 F_X1 - .2 F_X2 + (.6 + .2 a) f1 + .25 f2 + e_Y X = F_X L_X' + .35 E_X M = F_M(A) L_M' + .35 E_M

The factor errors e_M, outcome error e_Y, loadings L_X and L_M, and measurement errors E_X and E_M use independent standard-normal draws. Each observation has independent measurement errors. X and M in the CSV are the noisy measurements; the latent variables are not supplied to the estimator.

Known effects

NIE = E[Y(1,F_M(1)) - Y(1,F_M(0))] = .8*.7 + .25*.35 = .6475 NDE = E[Y(1,F_M(0)) - Y(0,F_M(0))] = .5 TE = NIE + NDE = 1.1475 Conditional NDE = .5 + .2 mean(b_1(F_X))
TargetNIENDETE
Loading true effects…

The conditional target averages over the generated latent covariates and integrates the mediator/outcome errors. The population target also averages over the covariate distribution. A single fitted estimate need not equal either truth.

Run the example

  1. Load Factor and confirm the variable roles.
  2. Answer Noisy measurements, then choose Linear factor or MediEncoder.
  3. Dimensions default to Cumulative explained variance (50% by default; 10% to 95% in 5% steps, plus 99%), with Eigenvalue ratio also available. Counts are computed from the CSV, not copied from the known simulation truth. Since X is high-dimensional, both blocks get a factor representation. With low-dimensional X, only M is represented by factors.
  4. Enable Bootstrap Uncertainty to refit resampled observations. Enable Sensitivity to latent dimensions to compare dimension choices. The primary result retains bootstrap intervals; the sensitivity grid compares point estimates.

Reproduce

Save both Python files together and run with NumPy installed:

python generate_latent_examples.py

Seed: 2026091801. The fixed CSV and manifest record the original draw and its checksum. This is a simulation for exercising the analysis workflow; a single run does not establish estimator accuracy or coverage.