Skip to contents

This function extends the as.dagitty function from the dagitty package to allow the input of a DAG object. The result is a dagitty object that includes only the structure of the DAG, without any specifications. May be useful to perform identifiability checks etc. on the DAG.

Usage

# S3 method for class 'DAG'
as.dagitty(x, include_root_nodes=TRUE,
           include_td_nodes=TRUE, include_networks=FALSE,
           layout=FALSE, ...)

Arguments

x

A DAG object created using the empty_dag function with nodes added to it using the + syntax. See ?empty_dag or ?node for more details. Supports DAGs with time-dependent nodes added using the node_td function. However, including such DAGs may result in cyclic causal structures, because time is not represented in the output matrix.

include_root_nodes

Whether to include root nodes in the output matrix. Should usually be kept at TRUE (default).

include_td_nodes

Whether to include time-dependent nodes added to the dag using the node_td function or not. When including these types of nodes, it is possible for the adjacency matrix to contain cycles, e.g. that it is not a classic DAG anymore, due to the matrix not representing the passage of time.

include_networks

Whether to include time-fixed networks added to the dag using the network function or not. Usually it does not make sense to include those, because they are not classical nodes.

layout

Corresponds to the argument of the same name in the dagitty function.

...

Currently not used.

Author

Robin Denz

Value

Returns a dagitty object.

Examples

library(simDAG)

# some example DAG
dag <- empty_dag() +
  node("death", type="binomial", parents=c("age", "sex"), betas=c(1, 2),
       intercept=-10) +
  node("age", type="rnorm", mean=10, sd=2) +
  node("sex", parents="", type="rbernoulli", p=0.5) +
  node("smoking", parents=c("sex", "age"), type="binomial",
       betas=c(0.6, 0.2), intercept=-2)

if (requireNamespace("dagitty")) {
  g <- dagitty::as.dagitty(dag)
}