edge_matrix.Rd
A DAG can be represented as a triangular matrix of regression coefficients.
dag2edge_matrix(object, out = 1)
edge_matrix2dag(edge_matrix)
g <- dag(~x2|x1 + x3|x1:x2 + x4|x3)
dag2edge_matrix(g, out=1)
#> x1 x2 x3 x4
#> x1 "1" "0" "0" "0"
#> x2 "x2x1" "1" "0" "0"
#> x3 "x3x1" "x3x2" "1" "0"
#> x4 "0" "0" "x4x3" "1"
dag2edge_matrix(g, out=2)
#> x1 x2 x3 x4
#> x1 "1" "0" "0" "0"
#> x2 "-b_x2x1" "1" "0" "0"
#> x3 "-b_x3x1" "-b_x3x2" "1" "0"
#> x4 "0" "0" "-b_x4x3" "1"
dag2edge_matrix(g, out=3)
#> x1 x2 x3 x4
#> x1 "1" "0" "0" "0"
#> x2 "-b21" "1" "0" "0"
#> x3 "-b31" "-b32" "1" "0"
#> x4 "0" "0" "-b43" "1"
dag2edge_matrix(g, out=4)
#> x1 x2 x3 x4
#> x1 "1" "0" "0" "0"
#> x2 "-b_21" "1" "0" "0"
#> x3 "-b_31" "-b_32" "1" "0"
#> x4 "0" "0" "-b_43" "1"
d2 <- dag(~c|a:b+d:c)
dag2edge_matrix(d2)
#> a b c d
#> a "1" "0" "0" "0"
#> b "0" "1" "0" "0"
#> c "ca" "cb" "1" "0"
#> d "0" "0" "dc" "1"