Error in lavaan - missing observed values

384 views
Skip to first unread message

Kyung Mi Lee

unread,
Sep 3, 2022, 7:09:41 PM9/3/22
to lavaan
 Hello, I am new to using the lavaan package and got an error message,
"Error in lavaan::lavaan(model = sr.model, data = data1, model.type = "sem",  : 
  lavaan ERROR: missing observed variables in dataset: social".

I can't understand it because I succeeded in the CFA and that means there are observed variables in the dataset.
Could you take a look at my model and do me a favor?

#step1-cfa analysis

cfa.model <-
'cog =~ FAC1+FAC2
facil =~ FAC3+FAC4
trust =~ T1+T2
rule =~ Q2_8_1+Q2_8_2+Q2_8_3
social =~ sol1+sol2'
cfa.out <- cfa(cfa.model, data1)
summary(cfa.out, fit.measures=T, standardized=T)

library(semPlot)
semPaths(cfa.out)
semPaths(cfa.out, style="lisrel")

#step2-SR

sr.model <-
'cog =~ FAC1+FAC2
facil =~ FAC3+FAC4
trust =~ T1+T2
rule =~ Q2_8_1+Q2_8_2+Q2_8_3
socail =~ sol1+sol2
trust ~ cog+facil
rule ~ cog+facil
social ~ cog+facil+rule+trust

cog ~~ facil'

sr.out <- sem(sr.model, data1)
summary(sr.out, fit.measures=T, standardized=T)
summary(sr.out, fit.measures=T, standardized=T, rsquare=T)

Chesnut, Ryan

unread,
Sep 3, 2022, 7:22:02 PM9/3/22
to lav...@googlegroups.com
Not sure if this is the issue or not, but in step 2, you spelled social as socail.

Sent from my iPhone

On Sep 3, 2022, at 7:09 PM, Kyung Mi Lee <wnh...@gmail.com> wrote:

 Hello, I am new to using the lavaan package and got an error message,
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/d10f7c02-a8a9-47ca-b457-307bf44804c9n%40googlegroups.com.

Kyung Mi Lee

unread,
Sep 3, 2022, 9:26:02 PM9/3/22
to lavaan
Wow! I appreciate your kind response.
Thanks to you I solved the problem.

2022년 9월 4일 일요일 오전 8시 22분 2초 UTC+9에 rpc...@psu.edu님이 작성:

Edward Rigdon

unread,
Sep 4, 2022, 2:57:28 PM9/4/22
to lav...@googlegroups.com
In the second model syntax, the first appearance of "social" is miss-typed as "socail". That is why, when you come to the later structural model syntax line and you mention "social," lavaan assumes it must be an observed variable--which is not present in your data set. Hence the error message about "social."
--Ed Rigdon

--

Kyung Mi Lee

unread,
Sep 4, 2022, 6:17:25 PM9/4/22
to lavaan
I really appreciate your kind explanation. 
Thanks to you I can understand what lavaan wants to say now.
Have a nice day!

2022년 9월 5일 월요일 오전 3시 57분 28초 UTC+9에 edward...@gmail.com님이 작성:
Reply all
Reply to author
Forward
0 new messages