Papers
Topics
Authors
Recent
2000 character limit reached

DoFlow: Causal Flows for Time-Series

Updated 9 November 2025
  • 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 XX?”) and counterfactual (“what would have happened if we did XX' 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 {Xt}t=1T\{X_t\}_{t=1}^T, where XtRKX_t \in \mathbb{R}^K, and leverages a DAG G\mathcal{G} over nodes 1,,K1,\ldots,K to encode instantaneous causal dependencies: if jpa(i)j\in\mathrm{pa}(i), then Xj,tXi,tX_{j,t} \rightarrow X_{i,t} (with pa(i)\mathrm{pa}(i) denoting the parent set). Each node ii evolves according to a (possibly nonlinear) structural equation: Xi,t=fi(Xi,t,Xpa(i),t,Ui,t),X_{i,t} = f_i(X_{i,t-}, X_{\mathrm{pa}(i),t-}, U_{i,t}), where Xi,tX_{i,t-} and Xpa(i),tX_{\mathrm{pa}(i), t-} denote the past values, and Ui,tU_{i,t} are independent exogenous (noise) variables.

Forecasting tasks in this setting are divided as:

  • Observational forecasting: Estimate p(Xτ+1:TX1:τ)p(X_{\tau+1:T} | X_{1:\tau}).
  • Interventional forecasting: For an intervention schedule I{(i,t)}\mathcal{I} \subset \{(i, t)\}, with values γi,t\gamma_{i,t}, estimate p(Xτ+1:TX1:τ,do(XI:=γI))p(X_{\tau+1:T} \mid X_{1:\tau}, do(X_\mathcal{I} := \gamma_\mathcal{I})).
  • Counterfactual forecasting: Given realized X1:TFX_{1:T}^F (the factual trajectory) and counterfactual interventions, infer Xτ+1:TCFX_{\tau+1:T}^{CF} with the same UU 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 ii and forecast step tt, a neural ODE parameterizes the bijection between Gaussian noise zi,tN(0,1)z_{i,t} \sim \mathcal{N}(0,1) and Xi,tX_{i,t}, conditioned on recurrent states Hi,t1H_{i,t-1} summarizing its and its parents' past.
  • For each i,ti,t, consider the path xi,t(s)x_{i,t}(s), s[0,1]s \in [0,1], governed by

dxi,t(s)ds=vi(xi,t(s),s;Hi,t1),\frac{dx_{i,t}(s)}{ds} = v_i(x_{i,t}(s), s; H_{i,t-1}),

with xi,t(0)=zi,tx_{i,t}(0) = z_{i,t} and xi,t(1)=Xi,tx_{i,t}(1) = X_{i,t}.

  • 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: logpθ(Xτ+1:THτ)=t=τ+1T[logq(zt)01Tr(vx)ds],\log p_\theta(X_{\tau+1:T} | H_\tau) = \sum_{t=\tau+1}^{T} \left[ \log q(z_t) - \int_0^1 \mathrm{Tr}\left( \frac{\partial v}{\partial x} \right) \, ds \right], where q(zt)=N(zt;0,1)q(z_t) = \mathcal{N}(z_t; 0,1).

3. Learning via Conditional Flow Matching

The flow vector fields viv_i are trained using a conditional flow matching (CFM) criterion:

  • For each training triple (xi,t,s,z)(x_{i,t}, s, z), linearly interpolate ϕ(s)=(1s)xi,t+sz\phi(s) = (1-s)x_{i,t} + s z,
  • The loss is

Edata,sU[0,1],zN(0,1)vi(ϕ(s),s;Hi,t1)(zxi,t)2.\mathbb{E}_{\text{data},\, s \sim U[0,1],\, z \sim \mathcal{N}(0,1)} \left\| v_i(\phi(s), s; H_{i,t-1}) - (z - x_{i,t}) \right\|^2.

This loss aligns the learned velocity field viv_i 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 ii at time tt:
    • If (i,t)I(i,t) \in \mathcal{I}: set y^i,t=γi,t\hat{y}_{i,t} = \gamma_{i,t} (explicit intervention).
    • Else: sample zi,tN(0,1)z_{i,t} \sim \mathcal{N}(0,1) and decode y^i,t=Φθ1(zi,t;H^i,t1)\hat{y}_{i,t} = \Phi_\theta^{-1}(z_{i,t}; \hat{H}_{i,t-1}).
  • Recurrent hidden states for ii 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:

  1. Abduction: Encode the factual trajectory Xτ+1:TFX^F_{\tau+1:T} one step at a time to obtain latent codes Zi,tFZ^F_{i,t}.
  2. Action: For intervention points, set Xi,tCF=γi,tX^{CF}_{i,t} = \gamma_{i,t}; for others, reuse Zi,tFZ^F_{i,t}.
  3. Prediction: Decode each latent using the counterfactual history H^i,t1CF\hat{H}^{CF}_{i,t-1}:

Y^i,tCF=Φθ1(Zi,tF;H^i,t1CF)\hat{Y}_{i,t}^{CF} = \Phi_\theta^{-1}(Z^F_{i,t}; \hat{H}^{CF}_{i,t-1})

producing a deterministic trajectory that is consistent with the original UU.

Counterfactual Recovery Theorem

Under assumptions:

  • (A1) UtU_t is independent of all previous variables.
  • (A2) fi(,U)f_i(\cdot, U) is strictly monotone in UU.
  • (A3) In the infinite-data limit, ZtZ_t is standard normal and independent of Ht1H_{t-1}.

It follows:

  • The flow encoder maps XtX_t to a ZtZ_t that depends only on UtU_t (not Ht1H_{t-1}).
  • Decoding ZtZ_t under counterfactual parent trajectories recovers XtCFX^{CF}_t 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 YtY_t 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 logpθ(Y^τ+1:TH^τ)-\log p_\theta(\hat{Y}_{\tau+1:T}|\hat{H}_\tau).
  • 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.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)
Slide Deck Streamline Icon: https://streamlinehq.com

Whiteboard

Forward Email Streamline Icon: https://streamlinehq.com

Follow Topic

Get notified by email when new papers are published related to DoFlow.