Learn R Programming

pwSEM (version 1.0.0)

MAG.to.DAG.in.pwSEM: Title MAG.to.DAG.in.pwSEM

Description

This function converts a MAG, usually created with the makeMG() function of th ggm library, with 0/1 for the directed paths, 100 for marginalized latents and 10 for conditioned latents.

Usage

MAG.to.DAG.in.pwSEM(MAG, marginalized.latents, conditioned.latents)

Value

A binary matrix of 0/1 values representing the DAG produced by adding the latent variables (named as L1, L2 etc)

Arguments

MAG

a MAG input as a matrix

marginalized.latents

a list containing pairs of variables that share a common latent marginalized cause; eg list(X2~~X3, X4~~X5)

conditioned.latents

a list containing pairs of variables that cause a common latent conditioned cause; eg list(X2~~X3, X4~~X5)

Examples

Run this code
library(ggm)
my.mag<-makeMG(dg=DAG(X2~X1,X3~X2,X4~X3),bg=UG(~X2*X4))
DAG.with.latent<-MAG.to.DAG.in.pwSEM(my.mag,
marginalized.latents=list(X2~~X4),conditioned.latents=NULL)

Run the code above in your browser using DataLab