Skip to contents

Compute confusion matrix for two PDAG caugi::caugi graphs.

Usage

confusion(truth, est, type = c("adj", "dir"))

Arguments

truth

A caugi::caugi object representing the truth graph.

est

A caugi::caugi object representing the estimated graph.

type

Character string specifying the comparison type:

  • "adj": adjacency comparison.

  • "dir": orientation comparison conditional on shared adjacencies.

Value

A list with entries tp (true positives), tn (true negatives), fp (false positives), and fn (false negatives).

Details

Adjacency comparison: The confusion matrix is a cross-tabulation of adjacencies. Hence, a true positive means that the two inputs agree on the presence of an adjacency. A true negative means that the two inputs agree on no adjacency. A false positive means that the estimated graph places an adjacency where there should be none. A false negative means that the estimated graph does not place an adjacency where there should have been one.

Orientation comparison: The orientation confusion matrix is conditional on agreement on adjacency. This means that only adjacencies that are shared in both input matrices are considered, and agreement wrt. orientation is then computed only among these edges that occur in both matrices. A true positive is a correctly placed arrowhead (1), a false positive marks placement of arrowhead (1) where there should have been a tail (0), a false negative marks placement of tail (0) where there should have been an arrowhead (1), and a truth negative marks correct placement of a tail (0).

Only supports caugi::caugi objects whose edges are restricted to -->, <->, ---, or absence of an edge.

Examples

cg1 <- caugi::caugi(A %-->% B + C)
cg2 <- caugi::caugi(B %-->% A + C)
confusion(cg1, cg2)
#> $tp
#> [1] 1
#> 
#> $tn
#> [1] 0
#> 
#> $fp
#> [1] 1
#> 
#> $fn
#> [1] 1
#> 
confusion(cg1, cg2, type = "dir")
#> $tp
#> [1] 0
#> 
#> $tn
#> [1] 0
#> 
#> $fp
#> [1] 1
#> 
#> $fn
#> [1] 1
#>