Skip to contents

as_lavaan() renders the mean structure of a drmSEM graph as a lavaan-style model-syntax string: one y ~ x1 + x2 regression line per endogenous node (from the variable-level directed edges) and one y1 ~~ y2 line per declared covariance edge (covariances()).

Usage

as_lavaan(object, ...)

# S3 method for class 'drm_sem'
as_lavaan(object, ...)

# S3 method for class 'drm_dag'
as_lavaan(object, ...)

Arguments

object

A drm_sem (from drm_sem() / drm_psem()) or a drm_dag (from drm_dag()).

...

Unused.

Value

A length-1 character string of class drm_lavaan (its print method cat()s the syntax). The dropped attribute lists any non-mu component paths that lavaan syntax could not represent.

Details

This is graph interchange, not a fitting bridge — drmSEM never fits its own likelihoods and does not call lavaan. Honesty: lavaan model syntax cannot express a distributional-component path (an arrow into sigma, zi, nu, hu, sd(group), or rho12). Such paths are therefore collapsed away, never silently emitted as a mean (~) regression. Every dropped non-mu path is attached as a dropped attribute and reported once via a cli message, so the loss is explicit.

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

# From an unfitted candidate DAG (no engine needed):
dag <- drm_dag(size ~ temp, abundance ~ size + temp)
as_lavaan(dag)
#> size ~ temp
#> abundance ~ size + temp