Learn R Programming

caugi (version 1.0.0)

latent_project: Project latent variables from a DAG to an ADMG

Description

Projects out latent (unobserved) variables from a DAG to produce an Acyclic Directed Mixed Graph (ADMG) over the observed variables.

Usage

latent_project(cg, latents)

Value

A caugi object of class "ADMG" containing only the observed variables.

Arguments

cg

A caugi object of class "DAG".

latents

Character vector of latent variable names to project out.

See Also

Other operations: condition_marginalize(), exogenize(), moralize(), mutate_caugi(), skeleton()

Examples

Run this code
# 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