Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

pcalg2dagitty

Transform the adjacency matrix from pcalg into a dagitty object


Description

Transform the adjacency matrix of type amat.cpdag or amat.pag (for details on coding see amatType).

Usage

pcalg2dagitty(amat, labels, type = "cpdag")

Arguments

amat

adjacency matrix of type amat.cpdag or amat.pag

labels

character vector of variable (or “node”) names.

type

string specifying the type of graph of the adjacency matrix amat. It can be a DAG (type="dag"), a CPDAG (type="cpdag") or a maximally oriented PDAG (type="pdag") from Meek (1995); then the type of adjacency matrix is assumed to be amat.cpdag. It can also be a MAG (type = "mag") or a PAG (type="pag"); then the type of the adjacency matrix is assumed to be amat.pag.

Details

For a given adjacency matrix amat the form amat.cpdag or amat.pag and a specified graph type, this function returns a dagitty object corresponding to the graph structure specified by amat, labels and type. The resulting object is compatible with the dagitty package.

Value

A dagitty graph (see the dagitty package).

Author(s)

Emilija Perkovic and Markus Kalisch

Examples

data(gmG)
n <- nrow    (gmG8$x)
V <- colnames(gmG8$x) # labels aka node names

amat <- wgtMatrix(gmG8$g)
amat[amat != 0] <- 1
if(requireNamespace("dagitty", quietly = TRUE)) {
dagitty_dag1 <- pcalg2dagitty(amat,V,type="dag")
}

pcalg

Methods for Graphical Models and Causal Inference

v2.7-2
GPL (>= 2)
Authors
Markus Kalisch [aut, cre], Alain Hauser [aut], Martin Maechler [aut], Diego Colombo [ctb], Doris Entner [ctb], Patrik Hoyer [ctb], Antti Hyttinen [ctb], Jonas Peters [ctb], Nicoletta Andri [ctb], Emilija Perkovic [ctb], Preetam Nandy [ctb], Philipp Ruetimann [ctb], Daniel Stekhoven [ctb], Manuel Schuerch [ctb], Marco Eigenmann [ctb], Leonard Henckel [ctb], Joris Mooij [ctb]
Initial release
2021-4-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.