Skip to contents

from_lavaan() reads a lavaan-style model-syntax string and returns a drmSEM graph skeleton: the ~ regression lines become per-response node formulas (assembled into a drm_dag()), and the ~~ covariance lines become covary() declarations. This is pure string parsing — nothing is evaluated or fitted.

Usage

from_lavaan(syntax)

Arguments

syntax

A single lavaan model-syntax string.

Value

A list of class drm_skeleton with elements dag (a drm_dag() of the regression structure, or NULL if there were no ~ lines) and covary (a list of covary() declarations from the ~~ lines, possibly empty).

Details

Reflective latent measurement (=~) lines are ignored with a warning: reflective measurement models need a joint likelihood and are out of the 0.x scope (docs/design/09-latent-variables.md). Variance / intercept-only lines (x ~~ x, x ~ 1) are skipped.

References

Rosseel Y (2012). “lavaan: An R Package for Structural Equation Modeling.” Journal of Statistical Software, 48(2), 1–36. doi:10.18637/jss.v048.i02 .

Examples

skel <- from_lavaan("abundance ~ size + temp\nsize ~ temp\nsize ~~ abundance")
skel$dag
#> <drm_dag> 2 nodes: "abundance" and "size"
#> abundance: abundance ~ size + temp
#> size: size ~ temp
skel$covary
#> [[1]]
#> <covariance edge> rho12(size, abundance) [residual]
#>