causaldag.classes.dag.DAG.marginal_mag

DAG.marginal_mag(latent_nodes, relabel=None, new=True)[source]

Return the maximal ancestral graph (MAG) that results from marginalizing out latent_nodes.

Parameters:
  • latent_nodes – nodes to marginalize over.
  • relabel – if relabel=’default’, relabel the nodes to have labels 1,2,…,(#nodes).
  • new – TODO - pick whether to use new or old implementation.
Returns:

cd.AncestralGraph, the MAG resulting from marginalizing out latent_nodes.

Return type:

m

Examples

>>> import causaldag as cd
>>> d = cd.DAG(arcs={(1, 3), (1, 2)})
>>> mag = d.marginal_mag(latent_nodes={1})
>>> mag
Directed edges: set(), Bidirected edges: {frozenset({2, 3})}, Undirected edges: set()
>>> mag = d.marginal_mag(latent_nodes={1}, relabel="default")
Directed edges: set(), Bidirected edges: {frozenset({0, 1})}, Undirected edges: set()