DoFlow: Causal Flows for Time-Series
- DoFlow is a framework for causal time-series prediction that integrates continuous normalizing flows, structural causal models, and neural ODEs to address observational, interventional, and counterfactual queries.
- It employs per-node neural ODE-based flows conditioned on DAG-structured dependencies, enabling explicit likelihood computations and principled anomaly detection.
- Empirical studies on synthetic, hydropower, and cancer treatment data demonstrate significant improvements in RMSE and predictive reliability over conventional deep learning models.
DoFlow refers to "DoFlow: Causal Generative Flows for Interventional and Counterfactual Time-Series Prediction" (Wu et al., 4 Nov 2025), a framework uniting continuous normalizing flows (CNFs), structural causal modeling (SCM), and neural ODEs for time-series forecasting under both observational and causal queries on systems structured by a known directed acyclic graph (DAG). DoFlow is designed to answer not just observational (“what will happen?”) forecasts, but also interventional (“what if we do ?”) and counterfactual (“what would have happened if we did instead?”) queries, with explicit likelihoods for proper statistical inference and anomaly detection.
1. Problem Formulation and Causal Setting
The DoFlow framework considers a multivariate time series , where , and leverages a DAG over nodes to encode instantaneous causal dependencies: if , then (with denoting the parent set). Each node evolves according to a (possibly nonlinear) structural equation: where and denote the past values, and are independent exogenous (noise) variables.
Forecasting tasks in this setting are divided as:
- Observational forecasting: Estimate .
- Interventional forecasting: For an intervention schedule , with values , estimate .
- Counterfactual forecasting: Given realized (the factual trajectory) and counterfactual interventions, infer with the same that generated the factual path.
2. Architecture: Continuous Normalizing Flows on a Causal DAG
DoFlow employs a per-node, per-timestep continuous normalizing flow:
- For each node and forecast step , a neural ODE parameterizes the bijection between Gaussian noise and , conditioned on recurrent states summarizing its and its parents' past.
- For each , consider the path , , governed by
with and .
- The forward (“encoding”) direction maps base noise to data; the reverse allows likelihood computation and inference.
The joint density over the forecast window is autoregressive: where .
3. Learning via Conditional Flow Matching
The flow vector fields are trained using a conditional flow matching (CFM) criterion:
- For each training triple , linearly interpolate ,
- The loss is
This loss aligns the learned velocity field along interpolants between data and base noise, facilitating stable and expressive conditional flows adapted to the marginal dynamics of each node conditional on its Markov blanket.
4. Causal Interventions, Counterfactuals, and Theoretical Guarantees
Interventional Forecasting
At inference, the system proceeds stepwise in DAG topological order:
- For each node at time :
- If : set (explicit intervention).
- Else: sample and decode .
- Recurrent hidden states for and its children are then updated and the process continues for subsequent times and nodes.
Counterfactual Forecasting
DoFlow implements the abduction-action-prediction paradigm for counterfactuals:
- Abduction: Encode the factual trajectory one step at a time to obtain latent codes .
- Action: For intervention points, set ; for others, reuse .
- Prediction: Decode each latent using the counterfactual history :
producing a deterministic trajectory that is consistent with the original .
Counterfactual Recovery Theorem
Under assumptions:
- (A1) is independent of all previous variables.
- (A2) is strictly monotone in .
- (A3) In the infinite-data limit, is standard normal and independent of .
It follows:
- The flow encoder maps to a that depends only on (not ).
- Decoding under counterfactual parent trajectories recovers as under the true SCM.
- This theoretical guarantee ensures that the encode–do–decode mechanism implemented in DoFlow is sound in the limit for univariate, monotonic SCMs, and suggests wider applicability in practice given similar regularities in the learned flows.
5. Applications: Likelihood-based Anomaly Detection and Empirical Results
DoFlow is evaluated on both synthetic and real-world time-series data in settings requiring causal forecasting:
Synthetic DAG-structured Systems
- Supports various causal graph structures: Chain, Tree, Diamond, Fully-Connected-Layer, with both additive and non-additive (nonlinear) SCMs.
- Metrics:
- RMSE for point predictions under observational, interventional, and counterfactual regimes.
- Maximum Mean Discrepancy (MMD) for matching forecast distributions.
- Empirical findings:
- DoFlow outperforms GRU, TFT, TiDE, TSMixer, DeepVAR, and MQF2 on observational and interventional RMSE/MMD.
- It is the only method with nontrivial counterfactual RMSE, i.e., capable of explicit, data-consistent what-if predictions.
Hydropower System (Real Data)
- 8-node DAG: turbine vibrations, generator signals, transformer outputs, and control units.
- Experiments:
- Interventional forecasting is validated by simulating turbine failures (power-outages).
- Early anomaly detection is demonstrated: log-likelihood dips identify emerging faults 10–20 minutes before actual outages.
- Interventional RMSE is substantially lower than adapted black-box baselines.
Cancer Treatment Time-Series
- Nodes: four treatments (chemo/radiotherapy, with dose schedules) as parents of tumor volume in single-step DAG.
- Experimental protocol:
- First 55 days observed per patient; days 56–62 rolled out for 10 hypothetical treatment regimens.
- RMSE measured against ground-truth generated by adversarially-balanced SCMs.
- DoFlow reduces normalized RMSE by approximately 50% compared to CRN, RMSN, and MSM baselines for treatment effect estimation.
Likelihood-based Anomaly Detection
- Every generated trajectory has an explicit log-likelihood.
- Anomalous events are detected by thresholding .
- In hydropower and synthetic domains, this enables principled, model-aware diagnosis of rare system behaviors.
6. Framework Significance, Trade-offs, and Broader Implications
DoFlow synthesizes causal SCMs, normalizing flows, temporal recurrence, and neural ODE machinery to operationalize the full spectrum of time-series causal inference:
| Capability | DoFlow Implementation |
|---|---|
| Observational forecasting | CNF roll-out, recurrent, explicit density |
| Interventional (do-operator) | Intervention per node/time, DAG topological pass |
| Counterfactual ("encode-do-decode") | Abduct latent, intervene, conditionally decode |
| Anomaly detection | Likelihood thresholding along roll-outs |
Resource requirements are mainly determined by neural ODE integration per node per time step, with recurrence for history; scalability tracks that of modern CNF ODE solutions and RNNs.
Salient trade-offs:
- Expressivity vs. computational cost: Per-node flows avoid the curse of dimensionality but require parallel ODE solves.
- Theoretical identifiability: Guarantees hinge on monotonicity and independence assumptions; complex SCMs with unobserved confounding may violate these, but practical benefit has been observed in heterogeneous domains.
- Interpretability: The DAG-structured flows maintain explicit causal semantics, facilitating interventional science and policy queries, unlike black-box sequence models.
DoFlow thus advances unification of generative modeling and causal inference in dynamical systems, opening principled paths for "what-if" reasoning and risk assessment in domains such as industrial process control, medicine, and physical system modeling.