Skip to main content

Function reference

Construction

Build causal graphs.

cgraph()
Create a causal graph
`%–>%` `%<–%` `%—%` `%<->%` `%o->%` `%<-o%` `%o–%` `%–o%` `%o-o%` `%!–>%` `%!<–%`
Edge specification operators
`==`(<cgraph>) `!=`(<cgraph>)
Compare two graphs

Graph queries

Whole-graph queries: nodes, edges, and adjacency.

nodes() topological_sort() exogenous_nodes()
Graph-level node queries
has_edge()
Test whether two nodes are adjacent
edges()
Get all edges in a graph

Node-set queries

Relatives of a single node.

ancestors() descendants() parents() children() spouses()
Node-set queries
markov_blanket()
Markov blanket of a node
neighbors()
Neighbors of a node
possible_ancestors() possible_descendants()
Possible-ancestor/descendant node-set queries
anteriors() posteriors()
Anterior/posterior node-set queries
possible_d_sep()
Find the D-SEP set of two nodes
districts()
Districts of a mixed graph

Graph class predicates

Test structural properties of a graph.

is_dag() is_pdag() is_cpdag() is_mpdag() is_ug() is_admg() is_ag() is_mag() is_pag() is_simple() is_acyclic()
Graph class predicates

Transformations

Derive a new graph from an existing one.

skeleton()
Drop edge marks to an undirected graph
moralize()
Moralize a graph
dag_to_cpdag()
Convert a DAG to its CPDAG
dag_from_pdag()
Extend a PDAG to a consistent DAG
meek_closure()
Apply Meek's orientation rules
apply_background_knowledge()
Apply background knowledge to a PDAG
dag_to_mpdag()
Convert a DAG to its MPDAG
ag_to_mag()
Convert an AG to a Markov equivalent MAG
mag_to_pag()
Map a MAG to its PAG equivalence class
mag_from_pag()
Resolve a PAG to a representative MAG
subgraph()
Induced subgraph
latent_project()
Project out latent variables
exogenize()
Make nodes exogenous
normalize_latent_structure()
Normalize latent structure
condition_marginalize()
Condition and marginalize a graph

Mutation and reclassification

Add or remove edges/nodes, or change a graph’s tagged class.

add_edges() remove_edges()
Add or remove edges
add_nodes() remove_nodes()
Add or remove isolated nodes
reclass()
Reclassify a graph

Separation and identification

d-/m-separation and adjustment/frontdoor/IV identification.

d_separated()
Test d-separation
m_separated()
Test m-separation
minimal_separator()
Find a minimal separator
adjustment_set()
Find an adjustment set
frontdoor_set()
Find a frontdoor adjustment set
is_valid_backdoor()
Validate a backdoor adjustment set
all_backdoor_sets()
Enumerate backdoor adjustment sets
all_frontdoor_sets()
Enumerate frontdoor adjustment sets
is_valid_adjustment()
Validate an adjustment set
all_adjustment_sets()
Enumerate all valid adjustment sets
is_valid_frontdoor()
Validate a frontdoor criterion set
is_valid_iv()
Validate instrumental variables
all_iv_sets()
Enumerate all valid instrumental variable sets
iv_set()
Find an instrument and its conditioning set
backdoor_set()
Find a generalized backdoor set
id() idc()
Identify an interventional distribution
idp() cidp()
Identify an interventional distribution from a PAG

Local IDA

Local structure-learning identification (IDA and its variants).

possible_parent_sets()
Enumerate possible parent sets (local IDA)
possible_joint_parent_sets()
Enumerate possible joint parent sets (joint-IDA)
possible_optimal_adjustment_sets()
Enumerate possible optimal adjustment sets (O-set-based IDA)
possible_local_structures()
Enumerate valid local structures at a node of a PAG
maximal_local_mag()
Build the maximal local MAG for a local structure
pagcauses()
Find every possible causal effect in a PAG (PAGcauses)

Equivalence classes

Count and enumerate Markov equivalent graphs.

count_dags() enumerate_dags()
Count and enumerate DAGs in a Markov equivalence class
markov_equivalent()
Test whether two graphs are Markov equivalent
enumerate_mags()
Enumerate MAGs in a PAG equivalence class

Metrics

Compare two graphs, e.g. a learned graph with the true one.

hd() shd()
Hamming distances between two graphs
aid()
Adjustment Identification Distance
separation_distance()
Separation distance between two graphs
sc_metric() markov_metric() faithfulness_metric()
Separation/connection metrics between two graphs

Generation and simulation

simulate_data()
Simulate data from a DAG
generate_graph()
Generate a random graph
uniform_dag() uniform_dag_counts()
Generate a uniformly random DAG

Plotting

cgraph_plot() plot(<cgraph>)
Plot a causal graph
style_nodes() style_labels() style_title() label_nodes() style_edges()
Style the nodes, edges and labels of a plot
cgraph_plot_grid() Ops(<cgraph_plot>) Ops(<cgraph_plots>)
Arrange several plots in one figure
cgraph_grob()
Grid grob of a causal graph plot
cgraph_layout()
Compute a graph layout
plot_options()
Get or set global default plot styles
plot_default_options()
Default plot styling options

Setup

Check that the compiled CausalStructures.jl library is available, and package options.

julia_ready()
Is the compiled CausalStructures.jl library available?
CausalStructures_options
Package options