powered by
Check if the path \(a--b--c\) is legal.
A 3-node path \(a--b--c\) is “legal” iff either \(b\) is a collider or \(a--b--c\) is a triangle.
legal.path(a, b, c, amat)
(integer) positions in adjacency matrix of nodes \(a\), \(b\), and \(c\), respectively.
Adjacency matrix (coding 0,1,2,3 for no edge, circle, arrowhead, tail; e.g., amat[a,b] = 2 and amat[b,a] = 3 implies a -> b)
amat[a,b] = 2
amat[b,a] = 3
TRUE if path is legal, otherwise FALSE.
TRUE
FALSE
# NOT RUN { amat <- matrix( c(0,1,1,0,0, 2,0,1,0,0, 2,2,0,2,1, 0,0,1,0,0, 0,0,2,0,0), 5,5) legal.path(1,3,5, amat) legal.path(1,2,3, amat) legal.path(2,3,4, amat) # }
Run the code above in your browser using DataLab