# DAG with latent confounder U
dag <- caugi(
U %-->% X,
U %-->% Y,
X %-->% Y,
class = "DAG"
)
# Project out the latent variable
admg <- latent_project(dag, latents = "U")
# Result: X -> Y, X <-> Y (children of U become bidirected-connected)
edges(admg)
# DAG with directed path through latent
dag2 <- caugi(
X %-->% L,
L %-->% Y,
class = "DAG"
)
# Project out the latent variable
admg2 <- latent_project(dag2, latents = "L")
# Result: X -> Y (directed path X -> L -> Y becomes X -> Y)
edges(admg2)
Run the code above in your browser using DataLab