While most make models in Word or Powerpoint, there are other alternatives, that can also be used with R. One such, is DAGitty, (and related packages). You can make the diagrams in a browser window, and export the R code. The diagrams can be exported in most high quality graphics packages. Definitely worth looking into if you want a model in your paper.

DAGitty – drawing and analyzing causal diagrams (DAGs)

DAGitty is a browser-based environment for creating, editing, and analyzing causal diagrams (also known as directed acyclic graphs or causal Bayesian networks). The focus is on the use of causal diagrams for minimizing bias in empirical studies in epidemiology and other disciplines. For background information, see the ” learn” page.

DAGitty code for the diagram: 

dag {
bb=”-8.253,-6.478,6.838,7.608″
“SM*E1″ [adjusted,pos=”-1.035,-2.890″]
“SM*E2″ [adjusted,pos=”0.862,-2.947″]
D [outcome,pos=”2.390,0.870″]
E [outcome,pos=”2.390,2.703″]
E1 [exposure,pos=”-4.929,0.241″]
E2 [exposure,pos=”-4.919,1.550″]
E3 [exposure,pos=”-4.929,3.027″]
“SM*E1” -> D
“SM*E2” -> D
E1 -> D
E2 -> D
E2 -> E
E3 -> D
E3 -> E
}

R-code

testImplications <- function( covariance.matrix, sample.size ){
library(ggm)
tst <- function(i){ pcor.test( pcor(i,covariance.matrix), length(i)-2, sample.size )$pvalue }
tos <- function(i){ paste(i,collapse=” “) }
implications <- list(c(“E1″,”E2”),
c(“E1″,”E3”),
c(“E1″,”E”),
c(“E1″,”SM*E1”),
c(“E1″,”SM*E2”),
c(“D”,”E”,”E2″,”E3″),
c(“E2″,”E3”),
c(“E2″,”SM*E1”),
c(“E2″,”SM*E2”),
c(“E3″,”SM*E1”),
c(“E3″,”SM*E2”),
c(“E”,”SM*E1″),
c(“E”,”SM*E2″),
c(“SM*E1″,”SM*E2”))
data.frame( implication=unlist(lapply(implications,tos)),
pvalue=unlist( lapply( implications, tst ) ) )

}

 

Share This