Skip to content
AI.info

Research

DoFlow: Flow-based Generative Models for Interventional and Counterfactual Forecasting on Time Series

DoFlow: Flow-based Generative Models for Interventional and Counterfactual Forecasting on Time Series Overview Research area: Causal time-series forecasting, generative modeling (continuous normalizin

arXiv
2511.02137
Published
2025-11-04
Authors
Dongze Wu, Feng Qiu, Yao Xie

AI summary

DoFlow: Flow-based Generative Models for Interventional and Counterfactual Forecasting on Time Series

Overview

  • Research area: Causal time-series forecasting, generative modeling (continuous normalizing flows), causal inference on time-indexed DAGs.
  • Technical level: Advanced. The paper assumes familiarity with structural causal models, do-calculus, continuous normalizing flows / Neural ODEs, and conditional flow matching.
  • Scope: One-sentence scope — the paper introduces DoFlow, a flow-based generative model defined over a causal DAG that unifies observational, interventional, and counterfactual forecasting of multivariate time series, adds a supporting counterfactual recovery result and likelihood-based anomaly detection, and evaluates on synthetic DAGs plus hydropower and cancer-treatment data.

What This Paper Is About

Standard time-series forecasters are purely observational: they learn correlations from past behavior and extrapolate them, so they cannot answer "what if" questions about planned control changes or alternative treatment plans. DoFlow targets two causal queries — interventional forecasting ("how will the forecast change under a planned modification of certain variables?") and counterfactual forecasting ("what would this same trajectory have looked like had we intervened differently?") — in multivariate systems governed by a causal directed acyclic graph (DAG). The goal is a single generative model that produces coherent system-wide trajectories under all three regimes and, as a byproduct, assigns explicit likelihoods to future trajectories for anomaly detection.

Key Contributions

  1. A unified causal generative forecaster. DoFlow is built on continuous normalizing flows (CNFs) and explicitly embeds a causal DAG with nodes in topologically sorted order, providing observational, interventional, and counterfactual forecasting within one framework. The authors state that to their knowledge no general framework for counterfactual time-series forecasting existed previously.
  2. A counterfactual recovery theory. The paper provides a supporting result (Proposition 4.3 and Corollary 4.5) showing that under Assumption 4.1 the decoder recovers the true counterfactual at each time step almost surely, with a model-specific pointwise recovery argument under Assumptions (A1)–(A3) that the authors contrast with the distribution-matching requirement of Bijective Generation Mechanisms.
  3. Explicit likelihoods enabling anomaly detection. Proposition 3.1 gives the log-density of the generated trajectory as a sum over time steps of the base log-density plus the integral of the divergence of the learned velocity field, and the authors exploit low density assigned to generated forecast trajectories under anomalous contexts.
  4. Empirical evaluation across synthetic and real data. Experiments cover synthetic datasets with various causal DAG structures (additive noise models and non-linear, non-additive cases), plus real-world hydropower data from Argonne National Laboratory and a cancer-treatment dataset from Bica et al. (2020a). Code is released at https://github.com/StatFusion/DoFlow_Causal_Time_Series.

Main Findings

  • Observational forecasting works system-wide: The authors report that DoFlow achieves accurate system-wide observational forecasting on synthetic datasets with various causal DAG structures and on the real-world datasets.
  • Interventional and counterfactual queries are supported: DoFlow "enables causal forecasting over interventional and counterfactual queries," as stated in the abstract and introduction; the authors emphasize that no prior work had modeled the counterfactual trajectory despite its importance for decision making.
  • Anomaly detection is effective: The paper reports that DoFlow "effectively detects anomalies," leveraging the explicit trajectory likelihoods from Proposition 3.1.
  • Counterfactual recovery is provable under stated assumptions: Under Assumption 4.1 — (A1) exogenous noise independent of past values, (A2) the structural equation is strictly monotone and continuous in the noise, (A3) the encoded latent's conditional distribution equals the base distribution — the encoded latent is a function of the exogenous noise alone, and the decoder recovers the true counterfactual almost surely.
  • Real-world counterfactuals are not directly verifiable: The authors note that ground-truth counterfactuals are never observable in the real world, and ground-truth interventional outcomes are only observable if interventions are actively conducted under a correct causal DAG; they therefore rely on synthetic experiments for quantitative performance metrics.
  • Metric coverage: Root Mean Squared Error (RMSE) is reported for all settings. Maximum Mean Discrepancy (MMD) and Continuous Ranked Probability Score (CRPS) are computed only for observational and interventional forecasting, because counterfactuals in DoFlow yield a single deterministic trajectory.
  • Numerical results: The provided content is truncated at the start of Section 5.1's baseline discussion and does not report the specific RMSE, MMD, or CRPS values, nor the naming of the synthetic DAG configurations or the size of the hydropower and cancer-treatment datasets. Those figures are not reported in the content available here.

Methodology in Plain English

The system is assumed to be a multivariate time series whose variables sit on a causal DAG, with no within-time-step causal effects — every causal influence occurs with at least one time-step lag. Each sequence is split into a context window (used for conditioning, never intervened on) and a forecasting window (the part predicted, where interventions may be applied).

For each node in the DAG, DoFlow trains its own continuous normalizing flow that is shared across time steps. The flow is a Neural ODE that transforms between the node's value at a given time step and a standard Gaussian base distribution using a learned velocity field. What makes the flow "time-conditioned" is an RNN (LSTM or GRU) that summarizes each node's own past history and its parents' past histories into hidden states; these hidden states are concatenated and fed into the velocity network. Training uses a Conditional Flow Matching loss, which regresses the learned velocity field onto the straight-line interpolation between data samples and Gaussian base samples.

Generation proceeds one time step at a time in topological order — parents before children. For observational or interventional forecasting, non-intervened nodes are decoded by integrating the ODE backward from a sampled Gaussian latent; intervened nodes are simply set to the specified value, and this value propagates to downstream nodes through the hidden-state updates.

Counterfactual forecasting follows the standard abduction–action–prediction recipe. First, each observed factual value is encoded (forward process) into a latent representation conditioned on factual hidden states built from the observed trajectory. Then the intervention is applied. Finally, the abducted latents are decoded under counterfactual hidden states, which are updated autoregressively from the model's own counterfactual predictions, yielding a hypothetical trajectory for the same individual.

Because CNFs are invertible and give exact density evaluation, the model also yields an explicit log-density for a whole forecast trajectory, which is used as an anomaly score.

Why This Matters

  • Research impact: The paper argues that existing causal-effect-on-time-series methods focus mainly on discrete, fixed-time actions and estimate short-term expected outcome differences, that most causal generative models target non-temporal settings, and that the closest related work (Liu et al., 2023) handles constrained physical systems with interventions only on the initial constrained state. DoFlow extends causal generative modeling to general time-indexed DAGs with interventions on individual continuous variables at arbitrary times.
  • Real-world applications (from the paper's own examples):
    • Hydropower operations: specifying a hypothetical turbine-control plan and inspecting how all downstream signals, such as power output, evolve.
    • Healthcare: asking whether a particular patient's outcome trajectory would have been better or worse under a different dosing schedule, conditioning on the factual trajectory to infer unobserved patient-specific factors.
    • Anomaly detection: flagging anomalous contexts by the low likelihood assigned to the resulting generated forecast trajectories.
    • Decision support in complex dynamical systems more generally, where planned control changes must be evaluated before adoption.
  • Industry relevance: The framework targets trustworthy inference and decision support, which is relevant to energy systems, clinical decision-making, and any setting where operators need to evaluate counterfactual control policies rather than only point forecasts. The released code and use of standard forecasting baselines (GRU, TFT, TiDE, TSMixer, DeepVAR, MQF2, via the Darts and GluonTS packages) make the work directly comparable to deployed forecasting tooling.

Future Directions

  • Causal discovery integration: The paper situates DoFlow alongside causal discovery, noting that recovering a causal DAG from observational data is an active research line; DoFlow assumes the DAG structure is given, so coupling it to discovery methods is a natural extension.
  • Relaxing the theoretical assumptions: The counterfactual recovery result relies on Assumption 4.1, including strict monotonicity of the structural equation in the noise and the latent-matching condition (A3). The synthetic study already tests non-linear, non-additive cases "beyond the scope of our counterfactual recovery result," inviting theory that covers them.
  • Uncertainty quantification for counterfactuals: Because DoFlow counterfactuals yield a single deterministic trajectory, MMD and CRPS could not be computed for them; developing a distributional counterfactual formulation is an open problem raised by the paper's own evaluation design.
  • Real-world counterfactual validation: Since ground-truth counterfactuals are never observable and ground-truth interventional outcomes require actively conducted interventions under a correct DAG, validating these predictions outside simulation remains an open challenge.

Target Audience

Researchers and graduate students in machine learning and statistics working on time-series forecasting, causal inference, or generative modeling with flows and Neural ODEs; applied scientists in energy and healthcare who need interventional or counterfactual trajectory predictions; and practitioners building anomaly detection or decision-support systems who can already supply a plausible causal graph. A background in structural causal models and continuous normalizing flows is needed to follow the derivations, though the conceptual framing of observational versus interventional versus counterfactual queries is accessible to a broader audience.

Authors’ abstract

Time-series forecasting increasingly demands not only accurate observational predictions but also causal forecasting under interventional and counterfactual queries in multivariate systems. We present DoFlow, a flow-based generative model defined over a causal Directed Acyclic Graph (DAG) that delivers coherent observational and interventional predictions, as well as counterfactuals through the natural encoding-decoding mechanism of continuous normalizing flows (CNFs). We also provide a supporting counterfactual recovery theory under certain assumptions. Beyond forecasting, DoFlow provides explicit likelihoods of future trajectories, enabling principled anomaly detection. Experiments on synthetic datasets with various causal DAG structures and real-world hydropower and cancer-treatment time series show that DoFlow achieves accurate system-wide observational forecasting, enables causal forecasting over interventional and counterfactual queries, and effectively detects anomalies. This work contributes to the broader goal of unifying causal reasoning and generative modeling for complex dynamical systems.

Read the original paper