Description Usage Arguments Details Value Author(s) References See Also Examples
Create or test for objects of type "causality.graph"
1 2 3 4 5 6 7 |
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 |
graph |
A graph to coerced or tested |
object |
A causality.graph |
... |
additional (unused) arguments to pass to |
A causality-graph consists of three things
nodes: a character vector of the nodes of the in the causal graph
adjacencies: a list of character vectors that contain the adjacencies of each node. This is calculated when a cgraph is created.
edges: either a m x 3 character matrix or 3 x m character vector which represents the edges in a causal graph in the form (from, to, edge). For example, if we are dealing with a causal graph regarding drug use and cancer, The edge "Smoking –> Cancer" would be stored as ("Smoking", "Cancer", "–>") in the edge matrix.
The valid edges types for non latent variable model graphs (DAGs, PDAGs, Patterns) are:
-->
---
And for latent variable models (PAGs, MAGs):
o-o
o->
++>
(in Tetrad this is a green arrow)
~~>
(in Tetrad this is a black arrow)
<->
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.
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
.
Alexander Rix
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.
Other causality classes: dag
, pattern
coercing non causality graphs to causality.graphs : as.cgraph
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.