Skip to main content

Make nodes exogenous

Source: R/transform.R

Description

Returns a copy of cg with each node in nodes made exogenous: its incoming edges are removed, and its parents are connected directly to its children to preserve reachability.

Usage

exogenize(cg, nodes)

Arguments

cg A DAG created with cgraph().
nodes Character vector of node names to exogenize.

Value

A cgraph of class DAG.

Examples

dag <- cgraph(A %-->% M, M %-->% Y)
exogenize(dag, "M")
#> DAG with 3 nodes and 2 edges:
#>   nodes: A, M, Y
#>   edges:
#>     A --> Y, M --> Y