# lepidoptera: A Domain-Agnostic Engine for Causal Simulation with Mixed Variable Types, Vine Copula Dependence, and Individual-Level Counterfactual Propagation

arXiv: https://arxiv.org/abs/2610.24147 · HTML: https://mlsanity.com/paper/2610.24147/

## Key facts

- No citing papers in the map yet (data through 26 Nov 2026).
- Builds on 9 of its 55 references that are in the map.
- Submitted 16 Oct 2026.

## Builds on (most cited first, 9 of 9)

- [Direct and Indirect Effects](https://mlsanity.com/paper/1301.2300/) (2013)
- [ranger: A Fast Implementation of Random Forests for High Dimensional Data in C++ and R](https://mlsanity.com/paper/1508.04409/) (2015)
- [Foundations of Structural Causal Models with Cycles and Latent Variables](https://mlsanity.com/paper/1611.06221/) (2016)
- [DoWhy: An End-to-End Library for Causal Inference](https://mlsanity.com/paper/2011.04216/) (2020)
- [Causal Networks: Semantics and Expressiveness](https://mlsanity.com/paper/1304.2379/) (2013)
- [Using simulation studies to evaluate statistical methods](https://mlsanity.com/paper/1712.03198/) (2017)
- [Evading the curse of dimensionality in nonparametric density estimation with simplified vine copulas](https://mlsanity.com/paper/1503.03305/) (2015)
- [Causal Effect Identification from Multiple Incomplete Data Sources: A General Search-based Approach](https://mlsanity.com/paper/1902.01073/) (2019)
- [Simulating counterfactuals](https://mlsanity.com/paper/2306.15328/) (2023)

## Abstract (arXiv)

lepidoptera is an open-source R and Python package for simulation from structural causal models with heterogeneous variable types. The package is built around a typed mechanism architecture, which separates the causal graph from the generating rule at each node and exposes each rule as an inspectable, serialisable object. A pre-built mechanism library covers all nine combinations of continuous, categorical, and ordinal parent and child types, removing the need for users to implement type-specific sampling from scratch. A vine copula mechanism estimates the full joint dependence structure from observed data using pair-copula constructions and the Rosenblatt conditional-simulation algorithm, supporting over twenty copula families. Individual-level counterfactual queries are supported through partial propagation, which freezes the random draws of unaffected nodes and replays only the downstream consequences of an intervention, thereby separating the individual treatment effect (ITE) estimand from the population-level average treatment effect (ATE) without additional model assumptions. An extension layer allows any pre-fitted predictive model to serve as a generative mechanism via a unified callable interface. Three worked illustrations spanning clinical trial planning, emergency-ward capacity analysis, and epidemiological mediation analysis demonstrate the package's scope.
