Skip to main content

Separation/connection metrics between two graphs

Source: R/metrics.R, R/jlbind-wrappers.R

Description

Compare two graphs by every separation statement (x, y, s) they imply, for every pair of nodes x, y and every set s of the other nodes with at most max_order nodes. The share of statements on which the graphs disagree is computed for each size of s, and the shares are averaged over the sizes, so that the many large sets do not dominate.

Usage

sc_metric(cg1, cg2, max_order = NULL)

markov_metric(cg_truth, cg_test, max_order = NULL)

faithfulness_metric(cg_truth, cg_test, max_order = NULL)

Arguments

cg1, cg2, cg_truth, cg_test Graphs created with cgraph(), with the same nodes and the same notion of separation: both d-separation (DAG, PDAG, CPDAG, MPDAG) or both m-separation (ADMG, AG, MAG, PAG).
max_order Maximum size of the separating sets. NULL (default) uses every size, up to n - 2.

Details

sc_metric() counts every disagreement, so it is symmetric in its arguments. markov_metric() (the c-metric) counts only the statements connected in cg_truth but separated in cg_test, the false-negative rate for connections; it is 0 when cg_test is at least as connected as cg_truth. faithfulness_metric() (the s-metric) counts only the statements separated in cg_truth but connected in cg_test, the false-positive rate. A size with no statements of the counted kind contributes 0.

A graph and its equivalence class (e.g. dag_to_cpdag(), mag_to_pag()) imply the same separations, so, unlike shd() and aid(), these metrics need no conversion of the true graph when comparing causal discovery algorithms.

The number of statements grows exponentially with the number of nodes, so limit max_order for larger graphs.

Value

A number in [0, 1].

References

Wahl J, Runge J (2025). “Separation-Based Distance Measures for Causal Graphs.” In Li Y, Mandt S, Agrawal S, Khan E (eds.), Proceedings of The 28th International Conference on Artificial Intelligence and Statistics, volume 258 of Proceedings of Machine Learning Research, 3412–3420. https://proceedings.mlr.press/v258/wahl25b.html.

Examples

truth <- cgraph(A %-->% B %-->% C %-->% D)
test <- cgraph(A %-->% B, C %-->% B, C %-->% D)
sc_metric(truth, test)
#> [1] 0.25
sc_metric(truth, test, max_order = 0)
#> [1] 0.3333333
markov_metric(truth, test)
#> [1] 0.1527778
faithfulness_metric(truth, test)
#> [1] 0.2777778