Extract Model Syntax

103 views
Skip to first unread message

Joseph Bonito

unread,
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 '


fit
<- sem(model, data=PoliticalDemocracy)
summary
(fit)


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.  

Joe

Christopher D Desjardins

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

Have you looked at

str(fit)
parameterestimates(fit)
residuals(fit)
?inspect

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.

Chris

--
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

unread,
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.

Joe
Reply all
Reply to author
Forward
0 new messages