lavExport.RdExport a fitted lavaan object to an external program.
lavExport(object, target = "lavaan", prefix = "sem", dir.name = "lavExport",
export = TRUE)An object of class lavaan.
The target program. Current options are "lavaan" and
"Mplus".
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’.
The directory name (including a full path) where the input files will be written.
If TRUE, the files are written to the output directory
(dir.name). If FALSE, only the syntax is generated as a
character string.
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.
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.
HS.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 '
fit <- cfa(HS.model, data=HolzingerSwineford1939)
#> Warning: lavaan->lav_model_vcov():
#> The variance-covariance matrix of the estimated parameters (vcov) does not
#> appear to be positive definite! The smallest eigenvalue (= -1.747972e-02)
#> is smaller than zero. This may be a symptom that the model is not
#> identified.
out <- lavExport(fit, target = "Mplus", export=FALSE)
cat(out)
#> TITLE:
#> [This syntax is autogenerated by lavExport]
#> DATA:
#> file is sem.mplus.raw;
#> type is individual;
#> listwise = on;
#> VARIABLE:
#> names are
#> x1 x2 x3 x4 x5 x6
#> x7 x8 x9;
#> missing are all (-999999);
#> ANALYSIS:
#> type = general;
#> estimator = ML;
#> information = expected;
#> model = nomeanstructure;
#> MODEL:
#> ! this model syntax is autogenerated by lavExport
#> visual BY x1@1 (p1);
#> visual BY x2* (p2);
#> visual BY x3* (p3);
#> textual BY x4@1 (p4);
#> textual BY x5* (p5);
#> textual BY x6* (p6);
#> speed BY x7@1 (p7);
#> speed BY x8* (p8);
#> speed BY x9* (p9);
#> x1* (p10);
#> x2* (p11);
#> x3* (p12);
#> x4* (p13);
#> x5* (p14);
#> x6* (p15);
#> x7* (p16);
#> x8* (p17);
#> x9* (p18);
#> visual* (p19);
#> textual* (p20);
#> speed* (p21);
#> visual WITH textual* (p22);
#> visual WITH speed* (p23);
#> textual WITH speed* (p24);
#> OUTPUT:
#> sampstat standardized tech1;