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

lavExport

lavaan Export


Description

Export a fitted lavaan object to an external program.

Usage

lavExport(object, target = "lavaan", prefix = "sem", dir.name = "lavExport", 
          export = TRUE)

Arguments

object

An object of class lavaan.

target

The target program. Current options are "lavaan" and "Mplus".

prefix

The prefix used to create the input files; the name of the input file has the pattern ‘prefix dot target dot in’; the name of the data file has the pattern ‘prefix dot target dot raw’.

dir.name

The directory name (including a full path) where the input files will be written.

export

If TRUE, the files are written to the output directory (dir.name). If FALSE, only the syntax is generated as a character string.

Details

This function was mainly created to quickly generate an Mplus syntax file to compare the results between Mplus and lavaan. The target "lavaan" can be useful to create a full model syntax as needed for the lavaan() function. More targets (perhaps for LISREL or EQS) will be added in future releases.

Value

If export = TRUE, a directory (called lavExport by default) will be created, typically containing a data file, and an input file so that the same analysis can be run using an external program. If export = FALSE, a character string containing the model syntax only for the target program.

See Also

Examples

HS.model <- ' visual  =~ x1 + x2 + x3
              textual =~ x4 + x5 + x6
              speed   =~ x7 + x8 + x9 '

fit <- cfa(HS.model, data=HolzingerSwineford1939)
out <- lavExport(fit, target = "Mplus", export=FALSE)
cat(out)

lavaan

Latent Variable Analysis

v0.6-10
GPL (>= 2)
Authors
Yves Rosseel [aut, cre] (<https://orcid.org/0000-0002-4129-4477>), Terrence D. Jorgensen [aut] (<https://orcid.org/0000-0001-5111-6773>), Nicholas Rockwood [aut] (<https://orcid.org/0000-0001-5931-183X>), Daniel Oberski [ctb], Jarrett Byrnes [ctb], Leonard Vanbrabant [ctb], Victoria Savalei [ctb], Ed Merkle [ctb], Michael Hallquist [ctb], Mijke Rhemtulla [ctb], Myrsini Katsikatsou [ctb], Mariska Barendse [ctb], Florian Scharf [ctb], Han Du [ctb]
Initial release

We don't support your browser anymore

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