TransWikia.com

Creating a directed acyclic graph for an instrumental variables design

TeX - LaTeX Asked by Tarjei W. Havneraas on March 15, 2021

I am trying to create two DAGs that looks like this (Morgan & Winship (2010) Counterfactuals and Causal Inference, p. 188):
Morgan & Winship (2010) Counterfactuals and Causal Inference, p. 188

I am not sufficiently advanced in LaTeX coding to draw these using tikz (or other relevant packages). However, there are two good online options (DAGitty and shinyDAG). I have tried to replicate 7.2. (b) using shinyDAG:

enter image description here

However, I would like (1) e to $epsilon$ and the other letters to have same format as the DAGs above too, and (2) a bidirectional line from D and PP to e. ShinyDAG provide LaTeX code:

tikzset{
  every node/.style={ }
}


begin{tikzpicture}[>=latex]
matrix(m)[matrix of nodes, row sep=2.6em, column sep=2.8em,text height=1.5ex, text depth=0.25ex]
{
  PP & ~ & ~ & e & ~  
  ~ & D & ~ & ~ & Y  
};
path[->,font=scriptsize,>=angle 90](m-2-2) edge [>=stealth, bend left = 0, color = Black,thin,solid] node[auto] {$~$} (m-2-5)(m-1-4) edge [>=stealth, bend left = 0, color = Black,thin,solid] node[auto] {$~$} (m-2-5)(m-2-2) edge [>=stealth, bend left = 30, color = Black,thin,dashed] node[auto] {$~$} (m-1-4)(m-1-1) edge [>=stealth, bend left = 30, color = Crimson,thin,dashed] node[auto] {$~$} (m-1-4)(m-1-1) edge [>=stealth, bend left = 0, color = Black,thin,solid] node[auto] {$~$} (m-2-2);
end{tikzpicture}

When I include this in Overleaf I only obtain:
enter image description here

I wonder if anyone can see where the fault lies in the code and how I might implement point 1 and 2 above?

I include the full code from Overleaf for replication:

documentclass{article}
usepackage[utf8]{inputenc}
usepackage{tikz}
title{DAG IV}
author{tarjeihavneraas}
date{October 2020}

begin{document}

maketitle

section{Introduction}

tikzset{
  every node/.style={ },
  395e727a5247a98c55028c61e103d0b1/.style={fill=White, text=DarkGray}
}
begin{tikzpicture}[>=latex]
matrix(m)[matrix of nodes, row sep=2.6em, column sep=2.8em,text height=1.5ex, text depth=0.25ex]
{
  |[395e727a5247a98c55028c61e103d0b1]| PP* & PP & ~ & ~ & e & ~  
  ~ & ~ & D & ~ & ~ & Y  
};
path[->,font=scriptsize,>=angle 90](m-2-3) edge [>=stealth, bend left = 0, color = Black,thin,solid] node[auto] {$~$} (m-2-6)(m-1-5) edge [>=stealth, bend left = 0, color = Black,thin,solid] node[auto] {$~$} (m-2-6)(m-2-3) edge [>=stealth, bend left = 30, color = Black,thin,dashed] node[auto] {$~$} (m-1-5)(m-1-2) edge [>=stealth, bend left = 30, color = Crimson,thin,dashed] node[auto] {$~$} (m-1-5)(m-1-2) edge [>=stealth, bend left = 0, color = Black,thin,solid] node[auto] {$~$} (m-2-3)(m-1-1) edge [>=stealth, bend left = 0, color = DarkGray,thin,solid] node[auto] {$~$} (m-1-2);
end{tikzpicture}


end{document}

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP