Extract Model Syntax

Skip to first unread message

Joseph Bonito

Oct 12, 2018, 2:32:32 PM10/12/18
to lavaan
Hi All,

I've searched lavaan's output structure so that I can retrieve the model syntax.  I see bits and pieces in the structure but not the actual syntax object.  For example:

model <- '
# latent variable definitions
ind60 =~ x1 + x2 + x3
dem60 =~ y1 + y2 + y3 + y4
dem65 =~ y5 + y6 + y7 + y8
# regressions
dem60 ~ ind60 dem65 ~ ind60 + dem60
# residual covariances
y1 ~~ y5 y2 ~~ y4 + y6 y3 ~~ y7 y4 ~~ y8 y6 ~~ y8 '

<- sem(model, data=PoliticalDemocracy)

Is there a way to retrieve the syntax, including the latent variable definitions, regressions, and residuals, as an intact object that I can reuse it in subsequent models?  Thanks in advance.  


Christopher D Desjardins

Oct 12, 2018, 2:47:11 PM10/12/18
to lav...@googlegroups.com

Have you looked at


For model syntax, can't you just use the model object you previously defined?

You likely just need to write your own function to extract the specific pieces you're interested in and combine them in the format you want. Shouldn't be too hard.


You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.

Joseph Bonito

Oct 12, 2018, 2:50:42 PM10/12/18
to lavaan
Thanks, Chris.  Yes, reusing the object occurred to me after I posted.  And as you surmised, I'm writing a function to reuse the pieces.  I just made it harder than it needed to be.

Reply all
Reply to author
0 new messages