DAG.to.MAG: Function to convert a Directed Acyclic Graph (DAG) into a...

DAG.to.MAGR Documentation

Function to convert a Directed Acyclic Graph (DAG) into a Mixed Acyclic Graph (MAG), obtained via marginalizing or conditioning on latent variables in the DAG.

Description

This function converts a Directed Acyclic Graph (DAG) into a Mixed Acyclic Graph (MAG), obtained via marginalizing or conditioning on latent variables in the DAG, as described in Shipley, B. & Douma, J. Testing piecewise structural equations models in the presence of latent variables, including correlated errors. It is typically used along with the function basiSet.mag, which outputs the union basis set of the MAG.

Usage

DAG.to.MAG(full.DAG, latents = NA,conditioning.latents=NULL)

Arguments

full.DAG

a named binary matrix encoding the DAG. This is typically obtained via the DAG function of the ggm library.

latents

a vector containing the names of the latent variables in the DAG. The names of these latent variables must match those used in full.DAG.

conditioning.latents

a vector containing the names of the latent variables in the DAG that are to be conditioned. The names of these latent variables must match those used in full.DAG and be a subset of the vector "latents".

Details

This function inputs a Directed Acyclic Graph (DAG) and outputs the Mixed Acyclic Graph (MAG) that results from marginalizing on those variables (nodes) contained in the vector "latents" and conditioning on the subset of these latents contained in the vector "conditioning.latents"

Value

The DAG and the resulting MAG are printed to the screen and the MAG is output from this function as a matrix.

Author(s)

Bill Shipley

References

Shipley, B. & Douma, J. Testing piecewise structural equations models in the presence of latent variables, including correlated errors.

See Also

dsep.test, basiSet.mag, DAG

Examples

library(ggm)
dag1.ms<-DAG(X~A+L,Y~L,B~Y,order=T)
#This is a call to the main function: DAG.to.MAG
out1 <- DAG.to.MAG(full.DAG=dag1.ms,latents=c("L"),conditioning.latents = NULL)
#This is a call to the function to output the union
#basis set of a MAG
basiSet.mag(out1)

BillShipley/CauseAndCorrelation documentation built on Jan. 31, 2023, 4:20 a.m.