Skip to main content

Condition and marginalize a graph

Source: R/transform.R

Description

Removes given and index from cg, returning the AG over the remaining nodes that represents the graphical effect of conditioning on given and marginalizing out index. At least one of the two must be non-empty, and they must be disjoint.

Usage

condition_marginalize(cg, given = character(), index = character())

Arguments

cg A DAG, ADMG, or AG-family (AG, MAG) graph created with cgraph().
given Character vector of node names to condition on.
index Character vector of node names to marginalize out.

Value

A cgraph of class AG.

Examples

dag <- cgraph(A %-->% M, M %-->% Y, U %-->% A, U %-->% Y)
condition_marginalize(dag, index = "U")
#> AG with 3 nodes and 3 edges:
#>   nodes: A, M, Y
#>   edges:
#>     A --> M, A --> Y, M --> Y