Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

lavaanToGraph

Convert Lavaan Model to DAGitty Graph


Description

The lavaan package is a popular package for structural equation modeling. To provide interoperability with lavaan, this function converts models specified in lavaan syntax to dagitty graphs.

Usage

lavaanToGraph(x, digits = 3, ...)

Arguments

x

data frame, lavaan parameter table such as returned by lavaanify. Can also be a lavaan object or a lavaan model string.

digits

number of significant digits to use when representing path coefficients, if any

...

Not used.

Examples

if( require(lavaan) ){
mdl <- lavaanify("
X ~ C1 + C3
M ~ X + C3
Y ~ X + M + C3 + C5
C1 ~ C2
C3 ~ C2 + C4
C5 ~ C4
C1 ~~ C2 \n C1 ~~ C3 \n C1 ~~ C4 \n C1 ~~ C5
C2 ~~ C3 \n C2 ~~ C4 \n C2 ~~ C5
C3 ~~ C4 \n C3 ~~ C5",fixed.x=FALSE)
plot( lavaanToGraph( mdl ) )
}

dagitty

Graphical Analysis of Structural Causal Models

v0.3-1
GPL-2
Authors
Johannes Textor, Benito van der Zander, Ankur Ankan
Initial release
2021-01-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.