Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

legal.path

Check if a 3-node-path is Legal


Description

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.

Usage

legal.path(a, b, c, amat)

Arguments

a,b,c

(integer) positions in adjacency matrix of nodes a, b, and c, respectively.

amat

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)

Value

TRUE if path is legal, otherwise FALSE.

Note

Prerequisite: a-b-c must be in a path (and this is not checked by legal.path()).

Author(s)

Markus Kalisch (kalisch@stat.math.ethz.ch)

Examples

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)

pcalg

Methods for Graphical Models and Causal Inference

v2.7-2
GPL (>= 2)
Authors
Markus Kalisch [aut, cre], Alain Hauser [aut], Martin Maechler [aut], Diego Colombo [ctb], Doris Entner [ctb], Patrik Hoyer [ctb], Antti Hyttinen [ctb], Jonas Peters [ctb], Nicoletta Andri [ctb], Emilija Perkovic [ctb], Preetam Nandy [ctb], Philipp Ruetimann [ctb], Daniel Stekhoven [ctb], Manuel Schuerch [ctb], Marco Eigenmann [ctb], Leonard Henckel [ctb], Joris Mooij [ctb]
Initial release
2021-4-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.