drawdag | R Documentation |
A fancier version of dagitty's plot function, as well as a way to show open paths given a conditioning set.
drawdag( x , col_arrow="black" , col_segment="black" , col_labels="black" , cex=1 ,
lwd=1.5 , goodarrow=TRUE , xlim , ylim , shapes , col_shapes , radius=3 ,
add=FALSE , ... )
drawopenpaths( x , Z=list() , col_arrow="red" , ... )
x |
A dagitty graph |
col_arrow |
Color or vector of colors for the graph arrows |
col_segment |
Color or vector of colors for the graph segments |
col_labels |
Color or vector of colors for the graph text labels |
cex |
Size of text labels |
lwd |
Width of arrow lines |
goodarrow |
Use |
xlim |
Optional plot limits |
ylim |
Optional plot limits |
shapes |
A named list of variables with one of "c" for an open circle or "fc" for a filled circle |
col_shapes |
A named list of colors to correspond to the shapes list |
radius |
Radius of shapes circles |
add |
If TRUE, draw over existing DAG in active plot |
Z |
List of variables to condition on when computing open paths |
... |
Optional arguments to pass to other functions |
drawdag
is a modified version of plot.dagitty
but with additional stylistic options. By default, it draws arrows in black and with thicker line width. It also uses the nicer arrows drawn by Arrows
in the shape
package. If the DAG doesn't already have coordinates
, then graphLayout
is called to provide them.
drawopenpaths
uses dagitty::paths
to compute and then overdraw open paths, given an exposure and outcome variable. It uses drawdag
to perform the drawing. Requires that the DAG already be displayed. Only open paths are drawn in the overlay color.
Richard McElreath
## Not run:
ex1 <- dagitty("dag {
X [exposure]
Y [outcome]
U [unobserved]
Z -> X -> Y
X <- U -> Y
}")
coordinates(ex1) <- list( x=c(Z=0,X=1,Y=1,U=0) , y=c(Z=0,U=0.5,X=0,Y=1) )
drawdag( ex1 )
# example of drawing open paths
drawdag( ex1 )
drawopenpaths( ex1 ) # open backdoor
drawdag( ex1 , col_arrow="gray" )
drawopenpaths( ex1 , Z=list("U") ) # closed backdoor
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.