cgraph: Casuality Graphs

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/cgraph.R

Description

Create or test for objects of type "causality.graph"

Usage

1
2
3
4
5
6
7
cgraph(nodes, edges, validate = TRUE)

is_valid_cgraph(graph)

is.cgraph(graph)

\method{summary}{causality.graph}(object, ...)

Arguments

nodes

A character array of node names

edges

A m x 3 character matrix. Each row is an edge in the form of (node1, node2, edgetype), with node1 and node2 being in nodes. Valid edge types are listed below

validate

logical value to determine whether or not to check to see if the cgraph is valid before returning it. Default is TRUE

graph

A graph to coerced or tested

object

A causality.graph

...

additional (unused) arguments to pass to summary

Details

A causality-graph consists of three things

The valid edges types for non latent variable model graphs (DAGs, PDAGs, Patterns) are:

And for latent variable models (PAGs, MAGs):

is_valid_cgraph checks to see if the input is a valid "causality.graph." Specifically, it checks that there are no duplicate nodes, self-loops, or multiple edges between pairs of nodes.

is.cgraph tests whether or not an object has the class causality.graph

summary provides basic summary statistics about graph, like average degree, max degree, number of directed/undirected eges etc.

Value

cgraph returns object of class "causality.graph", or an error if the graph is invalid.

is_valid_cgraph returns TRUE or FALSE depending on whether or not the input is valid.

is.cgraph returns TRUE or FALSE.

Author(s)

Alexander Rix

References

Spirtes et al. “Causation, Prediction, and Search.”, Mit Press, 2001, p. 109.

Spirtes P. Introduction to causal inference. Journal of Machine Learning Research. 2010;11(May):1643-62.

Pearl, Judea. Causality. Cambridge university press, 2009.

See Also

Other causality classes: dag, pattern coercing non causality graphs to causality.graphs : as.cgraph

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
nodes <- c("X1", "X2", "X3", "X4")
edges <- matrix(c("X1", "X2", "-->",
                  "X3", "X2", "-->",
                  "X4", "X1", "---",
                  "X4", "X3", "-->",
                  "X4", "X2", "-->"), ncol = 3, byrow = T)
graph <- cgraph(nodes, edges)

# cgraph defaults to validate = TRUE, but you can check validity by calling
is_valid_cgraph(graph)

# you can coerce graphs from package \code{bnlearn} to causality.graphs
## Not run: 
  library(bnlearn)
  sachs <- as.cgraph(mmhc(sachs.df))

## End(Not run)

tzimiskes/causality documentation built on Sept. 15, 2019, 8:41 p.m.