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 (not exported; qualify as CausalDynamics.…): Hypergraph for higher-order edges; symbolic do-calculus stubs; constructor-only normalise_* validators. Prefer DAGMakie for figures. EstimationPlan remains the hand-off object for CausalTargeted (package move deferred).
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]) # false: direct X → Y path remains open
backdoor_adjustment_set(g, 1, 2) # Set([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). Identification and estimation names follow Pearl-style conventions (d_separated, backdoor_adjustment_set, do_intervention, DiscreteTimeCDM, …). Temporal identity may use the closed lexicon on Terminology. 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]) # false: X → Y remains open
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
Adjusting for Z blocks the backdoor path X ← Z → Y, while leaving the direct causal path X → Y open. A valid backdoor adjustment set does not imply d-separation of X and Y in the original DAG.
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 · Terminology · Comparison · Getting Started · Missingness · API
- Design: DESIGN.md · BOUNDARIES.md · ecosystem principles
- 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.