Maximally oriented PDAG (MPDAG)

an MPDAG
class pyagrum.MPDAG(*args)

MPDAG represents a maximally oriented PDAG: a CPDAG refined by background knowledge.

A PDAG represents the DAGs with its skeleton, its v-structures and containing its arcs (its consistent extensions). Its maximal orientation (MPDAG) orients every edge that has the same orientation in all these DAGs: it is the closure of the PDAG under the Meek rules (Meek 1995). A CPDAG with some imposed arcs gives an MPDAG (Perković, Kalisch and Maathuis 2017). An MPDAG is not always a chain graph.

An MPDAG cannot be modified: it is built by MPDAG.meekClosure(), MPDAG.fromCPDAG() or checked by MPDAG.fromPDAG(). The represented DAGs are Markov equivalent: dSeparation() is the d-separation of any of them.

Example

import pyagrum as gum

cpdag = gum.CPDAG.fromDAG(gum.fastDAG("A->B->C"))
sorted(cpdag.edges())
# [(0, 1), (1, 2)]
mpdag = gum.MPDAG.fromCPDAG(cpdag, [(0, 1)])  # A->B imposed, then B->C by the Meek rules
sorted(mpdag.arcs()), sorted(mpdag.edges())
# ([(0, 1), (1, 2)], [])

Scientific notes

An MPDAG (maximally oriented PDAG) is a PDAG closed under the four Meek rules (stated in pyagrum.MeekRules). An extendable PDAG \(G\) represents the set \([G]\) of its consistent extensions (see pyagrum.PDAG); its closure under the rules orients exactly the edges that have the same orientation in all the DAGs of \([G]\) [1] (Theorem 4). The typical MPDAG is a CPDAG (pyagrum.CPDAG) refined by arcs imposed by background knowledge [2]: fromCPDAG imposes the arcs, raises an error if no DAG of the class contains them all (a directed cycle, for instance), and closes the result under the rules.

An MPDAG is not always a chain graph: imposing \(a \to b\) in the undirected triangle \(a - b - c - a\) orients nothing else, which leaves the partially directed cycle \(a \to b - c - a\). meekClosure computes the closure of an extendable PDAG with Algorithm 2 of [3]: from a consistent extension \(D\), it starts from the CPDAG of \(D\), gives its undirected edges the orientation of the PDAG, then visits the nodes once in a topological order of \(D\), orienting the edges into the current node by R1, R4, then R2 (R3 never applies there). fromPDAG accepts a PDAG iff it is extendable and closed under the rules; an MPDAG is immutable.

The DAGs of \([G]\) are Markov equivalent (same skeleton and v-structures [4]): cpdag returns the CPDAG of their class, and dSeparation is the d-separation of any of them, computed on a consistent extension kept from the construction.

Methods

adjacencyMatrix()

adjacency matrix from a graph/graphical models

arcs()

children()

connectedComponents()

The connected components of the graph (of its skeleton).

connectedComponentsCount()

number of connected components

connectedComponentsList()

connected components as a dict of sets

consistentExtension()

contains()

cpdag()

dSeparation()

Check if the sets of nodes X and Y are d-separated (by the set of nodes Z if given) in every DAG represented by the MPDAG.

edges()

empty()

existsArc()

existsEdge()

existsNode()

fromCPDAG()

The MPDAG of a CPDAG with some arcs imposed by background knowledge.

fromPDAG()

Checked conversion of a PDAG into an MPDAG: the PDAG must be extendable and closed under the Meek rules.

graph()

hasName()

idFromName()

Return the id of the node with the given name, or None if no such name exists.

idsFromNames()

The ids of nodes given by their names, in a container of the same type.

meekClosure()

The maximal orientation of an extendable PDAG (its closure under the Meek rules).

nameFromId()

Return the name of a node, or its id as a string if no name was set.

namesFromIds()

The names of nodes given by their ids, in a container of the same type.

neighbours()

nodes()

parents()

saveGUM()

Save the graph as a .jgum (text) or .bgum (binary) file (its class, its nodes with their names, its arcs, edges and marks).

saveGUMstring()

Save the graph as a jgum string (see pyagrum.graphFromGUMString to read it back).

size()

sizeArcs()

sizeEdges()

skeleton()

toDot()

The compelled arcs are drawn with the color of the key dot.compelledArcColor of pyagrum.config.

toString()