CausalDynamics.jl
CausalDynamics.CausalDynamics — Module
CausalDynamicsProvide causal graph operations and identification for structural and discrete-time dynamical models (CDMs), including a lightweight SCM layer.
Core exports cover d-separation and paths; backdoor, frontdoor, and instrumental-variable criteria; GraphSCM simulation with do(·); and DiscreteTimeCDM trajectories with shared-U counterfactuals. Identification façades wrap CausalInference.jl. Optional extensions load DAGMakie.jl plotting and RxInfer / GraphPPL backdoor inference.
Experimental (exported but outside the identify pipeline): Hypergraph for higher-order edges; SymbolicSCM as a ModelingToolkit placeholder.
Examples
using CausalDynamics
using Graphs
g = DiGraph(4)
add_edge!(g, 1, 2) # X → Y
add_edge!(g, 3, 1) # Z → X
add_edge!(g, 3, 2) # Z → Y
d_separated(g, 1, 2, [3]) # true (Z blocks the path)
backdoor_adjustment_set(g, 1, 2) # [3]References
- Pearl, J. (2009). Causality: Models, Reasoning, and Inference
- Shpitser, I., & Pearl, J. (2006). Identification of joint interventional distributions
CausalDynamics provides causal graph operations and identification for structural and discrete-time dynamical models (CDMs). Names follow Pearl-style conventions (d_separated, backdoor_adjustment_set, do_intervention, DiscreteTimeCDM, …). See Scope for what is in core versus deferred.
The package covers d-separation and path finding; backdoor, frontdoor, and instrumental-variable criteria; static GraphSCM simulation with do(·) and shared-U counterfactuals; discrete-time CDMs (DoSequence, trajectory simulation); soft interventions and g-computation; and time-indexed identification via unrolled lag DAGs. Optional extensions load DAGMakie plotting, RxInfer / GraphPPL backdoor inference, and Associations.jl discovery bridges.
Compared with R and Python
| Need | CausalDynamics | Familiar elsewhere |
|---|---|---|
| d-separation / backdoor / frontdoor / IV | Yes | dagitty, DoWhy, causal-learn |
Typed identify → certificate | Unique | Partial |
Discrete-time CDM + shared-U CF | Unique | Rare |
| Temporal unroll / SciML continuous CDM | Unique | Partial / custom |
Choose CausalDynamics when certificates and trajectories should feed Julia estimation and plotting. Prefer dagitty / DoWhy for GUI-first or existing Python four-step workflows. Details: Comparison · ECOSYSTEM_COMPARISON.md.
Quick start
using CausalDynamics, Graphs, DAGMakie, CairoMakie
g = DiGraph(3)
add_edge!(g, 1, 2) # Z → X
add_edge!(g, 1, 3) # Z → Y
add_edge!(g, 2, 3) # X → Y
d_separated(g, 2, 3, [1]) # true
backdoor_adjustment_set(g, 2, 3) # Set([1])
# Optional DAGMakie highlighting of backdoor paths and the adjustment set
fig = plot_backdoor_paths(g, 2, 3; node_labels = ["Z", "X", "Y"])
fig
DAG figures use DAGMakie.jl; CausalDynamics supplies the identification sets that the plot helpers consume.
Installation
using Pkg
Pkg.add("CausalDynamics")Optional plots: Pkg.add("DAGMakie") then using DAGMakie, CairoMakie.
See REGISTRATION.md for newer versions still awaiting registry publication.
Documentation
- Scope · Comparison · Getting Started · API
- References — Pearl, g-methods, discovery, temporal ID (DOIs / BibTeX keys)
- Estimation layer: CausalTargeted.jl references
- Narrative companion: CDCS Book
Compared with R/Python graph tools and the rest of this Julia stack: see Comparison (summary above) and ECOSYSTEM_COMPARISON.md.