Learn R Programming

gadjid (version 0.1.0)

sid: Structural Identification Distance between two DAG adjacency matrices

Description

Computes the structural intervention distance (SID), between the true g_true DAG and an estimated g_guess DAG.

Usage

sid(g_true, g_guess, edge_direction)

Value

2-element vector of type double
c(normalized error in [0,1], total number of errors)

Arguments

g_true

Adjacency matrix of the true directed acyclic graph

g_guess

Adjacency matrix of the guess directed acyclic graph

edge_direction

either "from row to column" or "from column to row"

Details

Since the Parent-AID reduces to the SID in the special case of DAG inputs and is efficiently implemented using reachability algorithms, it offers a faster way to calculate the SID; see also Henckel, Würtzen, Weichwald (2024) tools:::Rd_expr_doi("doi:10.48550/arXiv.2402.08616"). The example below can be compared to

library("SID")
system.time(structIntervDist(random_dag(20), random_dag(20)))

For details see Henckel, Würtzen, Weichwald (2024) tools:::Rd_expr_doi("doi:10.48550/arXiv.2402.08616")
The source code is available at github.com/CausalDisco/gadjid

Graph inputs are accepted as adjacency matrices of type double. An adjacency matrix for a DAG may only contain 0s and 1s. DAG inputs are validated for acyclicity.

If edge_direction="from row to column", then a 1 in row r and column c codes a directed edge ‘r → c’; if edge_direction="from column to row", then a 1 in row r and column c codes a directed edge ‘c → r’.

References

L Henckel, T Würtzen, S Weichwald. "Adjustment Identification Distance: A gadjid for Causal Structure Learning." Proceedings of the 40th Conference on Uncertainty in Artificial Intelligence (UAI), 2024. tools:::Rd_expr_doi("doi:10.48550/arXiv.2402.08616")

J Peters,P Bühlmann. "Structural intervention distance for evaluating causal graphs." Neural Compututation 27(3), 771–799, 2015. tools:::Rd_expr_doi("doi:10.1162/NECO_a_00708")

Examples

Run this code
random_dag <- function(n, p=0.1) {
    P <- sample(n)
    m <- matrix(0, n, n)
    m[upper.tri(m)] <- rbinom(n*(n-1)/2, 1, p)
    m[P, P]
}

system.time(sid(random_dag(400), random_dag(400), "from row to column"))

Run the code above in your browser using DataLab