Online Causal Diagram (and DAG) drawing / editing tools

Causal Wizard app
7 min readJul 2, 2023

--

Contents

  • What’s a DAG and why would you want to draw one?
  • Related concepts: DAGs, Causal Loop Diagrams, SEMs, SCMs, Graphical Models, Bayesian Networks etc.
  • DAG / Causal Diagram editing and drawing tools
  • Python Causality libraries
  • Javascript network and graph visualization libraries
Causal Diagrams enable you to describe and model causality, while managing the effects of confounding variables to avoid introducing excessive bias.

What’s a DAG and why would you want to draw one?

A DAG or Directed Acyclic Graph is a great way to describe the interactions between elements of a complex system; nodes represent the elements and the arrows depict the interactions.

The Acyclic property (literally — “no loops”) is important from a computational perspective, as it permits use of a bunch of efficient methods to analyse the graph and associated data, and to produce models which are compatible with the graph.

The Directed property is of particular interest because it captures the direction of each relationship, which is vital when we start to think about causality. A DAG in which arrows represent direct, causal effects is known as a Causal Diagram:

Example causal diagram. Each node represents a variable; edges represent direct causal effects between variables. Edges have a direction; the arrows indicate the direction of causation.

Most people naturally think about complex systems as the interaction of various elements, and will naturally start drawing something like Causal Diagrams when trying to explain how things work. For example, check this drawing of the metabolic processes in a cell, which is almost a causal diagram:

Metabolic processes in a cell, from “Emergent Properties of Tumor Microenvironment in a Real-Life Model of Multicell Tumor Spheroids” by Edoardo Milotti and Roberto Chignola. Although they probably didn’t intend to draw a Causal Diagram, they almost did.

So the reason you will want to draw DAGs, Causal Diagrams and other types of graph is because:

a) Graphs are an excellent way to communicate the properties of complex systems, especially the interactions of components.

b) Directed graphs are important when trying to capture and describe causality.

c) There are many powerful analysis tools that can be applied to graphs, particularly when exploring and quantifying causality.

Related concepts

Given the varied terminology used in the available software, it’s important to have a basic grasp of some key distinctions.

Let’s begin by separating DAGs and Causal Diagrams from a distantly-related concept, the Causal Loop Diagram (CLD). CLD does allow loops and is better suited to analysis of realtime systems and their interactions (as Systems Dynamics models). However, CLDs/System Dynamics are very sensitive to both topology (structural) changes and changes to the parameters or functions which describe edge and node behaviour, which means it can be difficult to generate systems that behave as expected.

You might also encounter some other types of graph, including Graphical Models, Bayesian Networks (a type of Graphical Model which must be a DAG), and Structural Equation Models (SEMs) or Structural Causal Models (SCMs)! What are the differences between all these?

First, note that these are not just diagrams which describe the existence of relationships between variables — these are models which also quantify these relationships. This is equivalent to a Causal Diagram plus some additional model, usually trained or fitted using data. A Causal Diagram by itself is just the first step to modelling a system.

Using a Causal Diagram or some other graph to describe a system is a good way to capture your existing domain knowledge. If you don’t know what the graph might be, your problem isn’t causal inference — it’s causal discovery. Causal Discovery aims to recover the structure or topology of the graph from data.

Second, many of these representations (such as Graphical Models, Bayesian Networks and SEMs) are designed to model associative relationships between variables rather than causal ones. This means that these are unlikely to answer causal questions correctly (such as “why”, “what if…” or counterfactuals). Causal variants of both Graphical and Bayesian networks do exist. The main difference between an ordinary Bayesian Network and a Structural Causal Model is the so-called “response function” of each variable, which does capture causality.

In short, we have two types of models based on graphs:

  • Associative models including SEMs, Graphical Models, Bayesian Networks (no guarantees the associations you model are causal), and:
  • Causal models (e.g. SCMs, Causal Bayesian Networks)

Most of the causal modelling techniques you will encounter have the acyclic criterion, but there some less commonly used techniques which are applicable to graphs with cycles.

DAG and Causal Diagram editing and drawing tools

This list focuses on end-user software tools which allow drawing and editing of Causal Diagrams and DAGs. You do not need any programming skills for these tools:

  • DAGitty. DAGitty is established as a powerful and highly featured graph drawing and analysis tool. It allows you to draw DAGs in your browser. DAGitty can also identify causal effects via adjustment sets (frontdoor, backdoor) and instrumental variables. DAGitty is free to use. Instructions here. We found DAGitty a bit overwhelming at first.
  • CausalWizard. CausalWizard is a browser-based web-app which provides Causal Diagram editing (although you can interpret your diagram as an ordinary DAG) and can also perform causal effect estimation with your data, by first identifying causal effects with adjustment sets or instrumental variables and then fitting various machine learning models. CausalWizard aims to make causal inference available to experts in other domains such as engineering, and therefore has a simpler user interface than DAGitty. CausalWizard is free to use.
  • BARD — Bayesian Argumentation via Delphi. This browser-based tool uses Bayesian Network drawing and constraint analysis to arrive at group consensus regarding system interactions and function (a process known as elicitation). You must apply for an account to use the software.
  • TETRAD is a free, Java-based tool for creating and analyzing causal diagrams, DAGs, and undirected graphs. You must run this tool on your computer, using Java. Source code and downloads are here.
  • GraphViz is a Python library which can also be used by non-programmers as a command-line tool on your computer. It’s commonly used by Python developers to render images of graphs; it has several useful layout functions.
  • ShinyDAG is a browser-based web app for drawing and (beautifully) rendering DAGs, primarily as preparation for publications.
  • Gephi — a leading platform for network and graph editing, visualisation and analysis. Gephi is highly featured and is free to use. You can draw various types of graph and network with Gephi. This software must be installed on your computer.
  • Agena AI — Bayesian Network based causal discovery with user-defined constraints on graph topology. You must buy a licence to use this software. It must be installed on your computer, but modelling work can be performed in the cloud. Agena has APIs in Python, R, and Java.
  • BI-CaMML. BI-CaMML performs causal discovery and causal inference, but it allows you to draw hard (must have) and soft (may have) constraints on the graph. This software must be installed and run using Java. BI-CaMML is free to use.
  • BayesFusion GeNIe Modeller — This software must be installed on a Windows computer. It provides a graphical, collaborative user interface for Bayesian Network editing and analysis. You must buy a licence to use this software.

Python Causal Diagram libraries

If you’re a Python programmer, you have many options to choose from, many of which are able to import or convert other graph formats. These libraries are all free to use.

  • NetworkX is the most popular and widely supported Python graph modelling package. It has many functions to create, edit and analyse graphs of all types. The other items in this list build on top of NetworkX.
  • CausalNex is “a toolkit for reasoning with Bayesian Networks”. It has a number of features for calculating adjustment sets and performing effect estimation (with your data).
  • DoWhy uses NetworkX but adds Identification (using your graph) and Estimation of causal effects (using your graph, and some data). DoWhy is used by CausalWizard (above).

Javascript Network Visualization libraries

If you’re a programmer of some sort, you’ve probably considered using Javascript to visualise (and maybe edit) graphs. It would be difficult to write these features from scratch, but fortunately there are a number of good tools for this. As with the Python libraries, they’re all free.

  • d3.js — a library for complex data visualization. D3 supports a huge range of data vis tools, including many network based layout and rendering options.
  • cytoscape.js — Cytoscape is a data vis library which focuses on network or graph models. Some of the visuals depend on D3. Like D3, it’s highly customizable but due to the focus on graph and network models, it’s more closely aligned to graph editing out of the box. CausalWizard uses Cytoscape.
  • Cola.js is a Javascript module which is compatible with D3. It aims to provide a better editing and layout experience for graph and network diagrams.

Summary

Most of the tools available for Causal Inference and Causal Diagram editing are aimed at data scientists, statisticians, economists and other experts. For this reason, very few tools are suitable for non-specialists to use. This is a shame, because we believe causality should be part of any deep system analysis or modelling.

If you’re a Python programmer you’ve got a range of good choices for Causal Diagram and DAG editing and visualization. But for everyone else, there aren’t many good options. Many of the software tools are older, require licences or install on your computer. All these things are bad.

DAGitty and CausalWizard both stand out as browser-based, free platforms that will allow you to freely draw causal diagrams and DAGs. Of the two, we think CausalWizard is easier to use, but we’re biased :) . DAGitty does have a lot of additional functionality which CausalWizard lacks, once you get used to the somewhat clunky interface.

--

--

Causal Wizard app

https://causalwizard.app Blogging about Causal Inference case studies, and attacking the ARC challenge in 2023. Two things somewhat related by Machine Learning