Abstract
Ananke is an object-oriented Python package designed to streamline the causal inference pipeline. By providing a unified interface for sophisticated graphical models—including Acyclic Directed Mixed Graphs (ADMGs) and chain graphs—Ananke enables researchers to identify causal effects in the presence of unmeasured confounding and perform robust semiparametric estimation. This paper outlines the package's architecture, its theoretical foundations, and its application to real-world longitudinal data.
Introduction
Causal inference is rarely a single-step process; it is a complex pipeline involving model specification, identifiability analysis, and statistical estimation. While tools for simple Directed Acyclic Graphs (DAGs) are common, real-world data often presents challenges like unmeasured confounding, selection bias, and data dependence (e.g., social networks). Ananke was developed to bridge the gap between high-level causal theory and practical data analysis, offering a "one-stop shop" for researchers dealing with complex causal structures.
The Ananke Framework
The core of Ananke is its hierarchical, object-oriented graph structure. This design allows for a clear representation of different causal assumptions and provides a foundation for extensible algorithms.
Key Components:
- Inheritance Structure: At the top is a general
Graphclass. Subclasses represent specific models:DAGsfor standard causal paths,Bidirected Graphsfor marginal correlations,ADMGsfor unmeasured confounding, andChain Graphsfor interference and feedback. - Identification: The package implements sound and complete algorithms, such as
OneLineID, to determine if a causal query can be answered given the observed data and graph structure. - Estimation: Once identified, Ananke supports multiple estimation strategies, including Linear Gaussian Structural Equation Models (SEMs), Möbius parameterization for discrete data, and advanced semiparametric techniques like the efficient augmented primal Inverse Probability Weighting (IPW) estimator.
Practical Application: The Framingham Heart Study
To demonstrate the package's utility, the authors analyzed a teaching dataset derived from the Framingham Heart Study. The goal was to model the relationship between smoking and diabetes, accounting for blood pressure (bp) and age. This scenario specifically tests the "front-door" identification strategy, where unmeasured confounding between the treatment (smoking) and the outcome (diabetes) is present.
As shown in the code snippet above, Ananke allows users to define vertices and edges (both directed and bidirected) with minimal code. The bidirected edge (red) between smoking and diabetes explicitly represents potential unmeasured confounding, making the modeler's assumptions transparent.
Key Results and Insights
The analysis of the Framingham data yielded several important findings:
- Identification Success: Ananke successfully verified that the effect of smoking on diabetes was identifiable despite potential confounding.
- Estimation Sensitivity: Different modeling assumptions led to varying results for the Average Causal Effect (ACE). The Linear SEM yielded an ACE of -0.004, the Möbius discrete model yielded 0.004, and the Semiparametric (Efficient IPW) approach yielded -0.002. This highlights the importance of choosing the correct estimator based on data types and distribution assumptions.
- API Efficiency: Complex tasks, such as checking m-separation or calculating a functional, are reduced to one or two lines of code, significantly lowering the barrier to entry for advanced causal analysis.
Conclusion and Future Work
Ananke provides a powerful engine for graphical causal inference. By focusing on ADMGs and semiparametric efficiency, it moves beyond the limitations of standard DAG-based tools. Future development aims to integrate Ananke with broader causal frameworks like doWhy and to incorporate automated causal discovery algorithms. While computational scalability for extremely dense graphs remains a challenge, Ananke stands as a robust tool for bridging theoretical causal models with empirical data analysis.
Summary updated