Ananke: A Python Package For Causal Inference Using Graphical Models

Jaron J. R. Lee, Rohit Bhattacharya, Razieh Nabi, Ilya ShpitserarXiv 2023 · DOI

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.

The inheritance structure of the Graph class in Ananke, showing the relationship between various graphical models.

Key Components:

  • Inheritance Structure: At the top is a general Graph class. Subclasses represent specific models: DAGs for standard causal paths, Bidirected Graphs for marginal correlations, ADMGs for unmeasured confounding, and Chain Graphs for 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.

Ananke API example showing how to define an ADMG and visualize it using the Framingham Heart Study variables.

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:

  1. Identification Success: Ananke successfully verified that the effect of smoking on diabetes was identifiable despite potential confounding.
  2. 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.
  3. 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

BibTeX
@misc{lee2023ananke,
  author = {Jaron J. R. Lee and Rohit Bhattacharya and Razieh Nabi and Ilya Shpitser},
  title = {{Ananke: A Python Package For Causal Inference Using Graphical Models}},
  year = {2023},
  eprint = {2301.11477},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2301.11477},
}
Figure