How to use write_lavaan()

Rémi Thériault

October 6, 2023

This vignette covers the arguments of the write_lavaan() function and links to examples in other vignettes showing their usage.

regression

The regression argument is a shorthand for the ~ operator. For example usage, see the Regression vignette.

covariance

The covariance argument is a shorthand for the ~~ operator. For example usage, see Example 1.

intercept

The latent argument is a shorthand for the ~ 1 operator. For example usage, see Example 1.

latent

The latent argument is a shorthand for the =~⁠⁠ operator. For example usage see Example 2.

constraints

Constraints can be specified with the constraint.equal, constraint.smaller, and constraint.larger argument, as showcased in Example 4.6.

mediation

The mediation argument is also a shorthand for the ~ operator. However, the difference with the regression argument is that it can automatically specify path names when the argument label is set to TRUE. It is also possible to name the paths with letters instead of the variable names by setting use.letters = TRUE. For example usage, see Example 5.

indirect

The indirect argument is a shorthand for the :=⁠ operator. For example usage, see Example 5.

user-defined parameters

For user-defined parameters (e.g,. total effects), see Example 5.

custom

Sometimes, some elements cannot be specified with the other arguments, and so the custom argument becomes handy to make tailored specifications, such as with Multilevel SEM in Example 6.

The custom argument can also be useful when having to specify thresholds with the “|” operator. For example usage, see Example 10.